parse constant nodes in gir files
authorJohan Bilien <jobi@via.ecp.fr>
Sun, 12 Oct 2008 21:12:46 +0000 (21:12 +0000)
committerJohan Bilien <jobi@src.gnome.org>
Sun, 12 Oct 2008 21:12:46 +0000 (21:12 +0000)
2008-10-12  Johan Bilien  <jobi@via.ecp.fr>

* giscanner/girparser.py: parse constant nodes in gir files

svn path=/trunk/; revision=695

ChangeLog
giscanner/girparser.py

index ac946ba..20909d5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-10-12  Johan Bilien  <jobi@via.ecp.fr>
+
+       * giscanner/girparser.py: parse constant nodes in gir files
+
 2008-10-12  Johan Bilien  <jobi@via.ecp.fr>
 
        * giscanner/transformer.py: prefix for constants have an underscore,
index 640eaef..8b72ad7 100644 (file)
@@ -20,8 +20,9 @@
 
 from xml.etree.cElementTree import parse
 
-from .ast import (Alias, Array, Callback, Enum, Function, Field, Namespace,
-                  Parameter, Property, Return, Union, Struct, Type, Varargs)
+from .ast import (Alias, Array, Callback, Constant, Enum, Function, Field,
+                  Namespace, Parameter, Property, Return, Union, Struct, Type,
+                  Varargs)
 from .glibast import (GLibEnum, GLibEnumMember, GLibFlags,
                       GLibInterface, GLibObject, GLibBoxedStruct,
                       GLibBoxedUnion, GLibBoxedOther)
@@ -111,6 +112,8 @@ class GIRParser(object):
         elif node.tag in [_corens('enumeration'),
                           _corens('bitfield')]:
             self._parse_enumeration_bitfield(node)
+        elif node.tag in _corens('constant'):
+            self._parse_constant(node)
 
     def _parse_alias(self, node):
         return Alias(node.attrib['name'],
@@ -253,6 +256,12 @@ class GIRParser(object):
                               node.attrib.get(_cns('identifier')),
                               node.attrib.get(_glibns('nick')))
 
+    def _parse_constant(self, node):
+        type_node = self._parse_type(node)
+        return Constant(node.attrib['name'],
+                        type_node.name,
+                        node.attrib['value'])
+
     def _parse_enumeration_bitfield(self, node):
         name = node.attrib.get('name')
         ctype = node.attrib.get(_cns('type'))