Commit 1c2ce5f
Use GObject system in XML parser
Changed files (5)
modifiedlibbirdxml/Attribute.valamodifiedlibbirdxml/Attributes.valamodifiedlibbirdxml/Tag.valamodifiedlibbirdxml/Xml.valamodifiedlibbirdxml/XmlString.vala
Diff
@@ -16,9 +16,7 @@ namespace Bird { /** * Representation of one XML attribute. */-[Compact]-[CCode (ref_function = "bird_attribute_ref", unref_function = "bird_attribute_unref")]-public class Attribute {+public class Attribute : GLib.Object { public XmlString ns; public XmlString name;@@ -38,21 +36,6 @@ public class Attribute { this.content = new XmlString ("", 0); } - /** Increment the reference count.- * @return a pointer to this object- */- public unowned Attribute @ref () {- refcount++;- return this;- }- - /** Decrement the reference count and free the object when zero object are holding references to it.*/- public void unref () {- if (--refcount == 0) {- this.free ();- }- }- /** * @return namespace part for this attribute. */@@ -73,8 +56,6 @@ public class Attribute { public string get_content () { return content.to_string (); }- - private extern void free (); } }@@ -16,9 +16,7 @@ namespace Bird { /** * Iterator for XML attributes. */-[Compact]-[CCode (ref_function = "bird_attributes_ref", unref_function = "bird_attributes_unref")]-public class Attributes {+public class Attributes : GLib.Object { public Tag tag; public int refcount = 1;@@ -31,24 +29,7 @@ public class Attributes { return new Iterator (tag); } - /** Increment the reference count.- * @return a pointer to this object- */- public unowned Attributes @ref () {- refcount++;- return this;- }- - /** Decrement the reference count and free the object when zero object are holding references to it.*/- public void unref () {- if (--refcount == 0) {- this.free ();- }- }- - [Compact]- [CCode (ref_function = "bird_attributes_iterator_ref", unref_function = "bird_attributes_iterator_unref")]- public class Iterator {+ public class Iterator : GLib.Object { public Tag tag; public Attribute? next_attribute; public int iterator_refcount = 1;@@ -77,26 +58,7 @@ public class Attributes { return (!) next_attribute; }- - /** Increment the reference count.- * @return a pointer to this object- */- public unowned Iterator @ref () {- iterator_refcount++;- return this;- }- - /** Decrement the reference count and free the object when zero object are holding references to it.*/- public void unref () {- if (--iterator_refcount == 0) {- this.free ();- }- }- - private extern void free (); }- - private extern void free (); } }@@ -17,9 +17,7 @@ namespace Bird { /** * Representation of one XML tag. */-[Compact]-[CCode (ref_function = "bird_tag_ref", unref_function = "bird_tag_unref")]-public class Tag {+public class Tag : GLib.Object { public int tag_index; public int attribute_index;@@ -53,21 +51,6 @@ public class Tag { attributes = new XmlString ("", 0); name = new XmlString ("", 0); }-- /** Increment the reference count.- * @return a pointer to this object- */- public unowned Tag @ref () {- refcount++;- return this;- }- - /** Decrement the reference count and free the object when zero object are holding references to it.*/- public void unref () {- if (--refcount == 0) {- this.free ();- }- } /** * Get tag attributes for this tag. @@ -432,9 +415,7 @@ public class Tag { return new Attribute (ns, attribute_name, content); } - [Compact]- [CCode (ref_function = "bird_tag_iterator_ref", unref_function = "bird_tag_iterator_unref")]- public class Iterator {+ public class Iterator : GLib.Object { public Tag tag; public Tag? next_tag = null; public int iterator_efcount = 1;@@ -465,23 +446,6 @@ public class Tag { } return (!) next_tag; }- - /** Increment the reference count.- * @return a pointer to this object- */- public unowned Tag.Iterator @ref () {- iterator_efcount++;- return this;- }- - /** Decrement the reference count and free the object when zero object are holding references to it.*/- public void unref () {- if (--iterator_efcount == 0) {- this.free ();- }- }- - private extern void free (); } internal void warn (string message) {@@ -489,8 +453,6 @@ public class Tag { XmlParser.warning (message); } }- - private extern void free (); } }@@ -68,9 +68,7 @@ internal const int WARNINGS = 1; * }}} * */-[Compact]-[CCode (ref_function = "bird_xml_parser_ref", unref_function = "bird_xml_parser_unref")]-public class XmlParser {+public class XmlParser : GLib.Object { public Tag root; public XmlString data; public string input;@@ -86,21 +84,6 @@ public class XmlParser { this.data = new XmlString (data, data.length); reparse (NONE); }-- /** Increment the reference count.- * @return a pointer to this object- */- public unowned XmlParser @ref () {- refcount++;- return this;- }- - /** Decrement the reference count and free the object when zero object are holding references to it.*/- public void unref () {- if (--refcount == 0) {- this.free ();- }- } /** * Determine if the document can be parsed.@@ -215,8 +198,6 @@ public class XmlParser { t = t.replace ("&", "&"); return t; }- - private extern void free (); } }@@ -18,9 +18,7 @@ namespace Bird { * copies a pointer to string instead of the data. It is faster if the string is * huge. */-[Compact]-[CCode (ref_function = "bird_xml_string_ref", unref_function = "bird_xml_string_unref")]-public class XmlString {+public class XmlString : GLib.Object { public int length; public char* data;@@ -30,22 +28,6 @@ public class XmlString { this.data = data; this.length = length; }- - /** Increment the reference count.- * @return a pointer to this object- */- public unowned XmlString @ref () {- refcount++;- return this;- }- - /** Decrement the reference count and free the object when zero object are holding references to it.*/- public void unref () {- if (--refcount == 0) {- delete data;- this.free ();- }- } internal int index_of (string needle, int offset = 0) { int len = length;@@ -142,8 +124,6 @@ public class XmlString { return s.ndup (length); }- - private extern void free (); } }