From 7aa8b985109cde6e92e7960d1bd6f9a985897ac5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 4 Apr 2009 13:37:12 +0200 Subject: [PATCH] Optimize gst-gapi-cleanup a bit --- fixup/gst-gapi-fixup.cs | 5 +--- gtk-sharp-gapi-fixup.diff | 59 ----------------------------------------------- 2 files changed, 1 insertion(+), 63 deletions(-) delete mode 100644 gtk-sharp-gapi-fixup.diff diff --git a/fixup/gst-gapi-fixup.cs b/fixup/gst-gapi-fixup.cs index 87e017f..d8810c8 100644 --- a/fixup/gst-gapi-fixup.cs +++ b/fixup/gst-gapi-fixup.cs @@ -167,11 +167,8 @@ namespace GtkSharp.Parsing { bool matched = false; while (api_iter.MoveNext ()) { XmlElement node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement; - XmlAttribute attr = node.Attributes[name]; - Console.WriteLine (attr); - if (attr != null) - node.Attributes.Remove (attr); + node.RemoveAttribute (name); matched = true; } if (!matched) diff --git a/gtk-sharp-gapi-fixup.diff b/gtk-sharp-gapi-fixup.diff deleted file mode 100644 index 513c945..0000000 --- a/gtk-sharp-gapi-fixup.diff +++ /dev/null @@ -1,59 +0,0 @@ -Index: parser/gapi-fixup.cs -=================================================================== ---- parser/gapi-fixup.cs (revision 60863) -+++ parser/gapi-fixup.cs (working copy) -@@ -136,6 +136,21 @@ - Console.WriteLine ("Warning: matched no nodes", path); - } - -+ XPathNodeIterator remove_attr_iter = meta_nav.Select ("/metadata/remove-attr"); -+ while (remove_attr_iter.MoveNext ()) { -+ string path = remove_attr_iter.Current.GetAttribute ("path", ""); -+ string attr_name = remove_attr_iter.Current.GetAttribute ("name", ""); -+ XPathNodeIterator api_iter = api_nav.Select (path); -+ bool matched = false; -+ while (api_iter.MoveNext ()) { -+ XmlElement node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement; -+ node.RemoveAttribute (attr_name); -+ matched = true; -+ } -+ if (!matched) -+ Console.WriteLine ("Warning: matched no nodes", path); -+ } -+ - XPathNodeIterator move_iter = meta_nav.Select ("/metadata/move-node"); - while (move_iter.MoveNext ()) { - string path = move_iter.Current.GetAttribute ("path", ""); -@@ -157,6 +172,32 @@ - Console.WriteLine ("Warning: matched no nodes", path); - } - -+ XPathNodeIterator change_iter = meta_nav.Select ("/metadata/change-node-type"); -+ while (change_iter.MoveNext ()) { -+ string path = change_iter.Current.GetAttribute ("path", ""); -+ XPathNodeIterator api_iter = api_nav.Select (path); -+ bool matched = false; -+ while (api_iter.MoveNext ()) { -+ XmlElement node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement; -+ XmlElement new_node = api_doc.CreateElement (change_iter.Current.Value); -+ foreach (XmlNode child in node.ChildNodes) -+ { -+ XmlNode new_child = child.CloneNode (true); -+ new_node.AppendChild (new_child); -+ } -+ -+ foreach (XmlAttribute attr in node.Attributes) -+ { -+ new_node.SetAttribute (attr.Name, attr.Value); -+ } -+ -+ node.ParentNode.ReplaceChild (new_node, node); -+ matched = true; -+ } -+ if (!matched) -+ Console.WriteLine ("Warning: matched no nodes", path); -+ } -+ - if (symbol_doc != null) { - XPathNavigator symbol_nav = symbol_doc.CreateNavigator (); - XPathNodeIterator iter = symbol_nav.Select ("/api/*"); -- 2.7.4