summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorTorsten Schönfeld <kaffeetisch@gmx.de>2011-08-13 17:28:30 +0200
committerTorsten Schönfeld <kaffeetisch@gmx.de>2011-08-16 18:43:23 +0200
commit169b206cbb4b347e4b17854e8f0c62a40404f803 (patch)
tree929ddaefcedf7c9d4778ea355e58f0b1cc2f2f96 /giscanner
parent64848acb817369436d629d153c5750789c0addc3 (diff)
downloadgobject-introspection-169b206cbb4b347e4b17854e8f0c62a40404f803.tar.gz
Allow enums and bitfields to have static methods
This uses the same backcompat machinery that was introduced for static methods for non-class types, so this change does not break users of the existing presentations. New libgirepository API: g_enum_info_get_n_methods g_enum_info_get_method https://bugzilla.gnome.org/show_bug.cgi?id=656499
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/ast.py10
-rw-r--r--giscanner/girparser.py3
-rw-r--r--giscanner/girwriter.py4
-rw-r--r--giscanner/maintransformer.py2
4 files changed, 18 insertions, 1 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 1433422c..373daa9f 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -736,6 +736,11 @@ class Enum(Node, Registered):
self.members = members
# Associated error domain name
self.error_domain = None
+ self.static_methods = []
+
+ def _walk(self, callback, chain):
+ for meth in self.static_methods:
+ meth.walk(callback, chain)
class Bitfield(Node, Registered):
@@ -750,6 +755,11 @@ class Bitfield(Node, Registered):
self.ctype = ctype
self.c_symbol_prefix = c_symbol_prefix
self.members = members
+ self.static_methods = []
+
+ def _walk(self, callback, chain):
+ for meth in self.static_methods:
+ meth.walk(callback, chain)
class Member(Annotated):
diff --git a/giscanner/girparser.py b/giscanner/girparser.py
index 51ef9340..8568fea3 100644
--- a/giscanner/girparser.py
+++ b/giscanner/girparser.py
@@ -572,3 +572,6 @@ class GIRParser(object):
return
for member in self._find_children(node, _corens('member')):
members.append(self._parse_member(member))
+ for func_node in self._find_children(node, _corens('function')):
+ func = self._parse_function_common(func_node, ast.Function)
+ obj.static_methods.append(func)
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index f9937291..f1e150df 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -337,6 +337,8 @@ and/or use gtk-doc annotations. ''')
self._write_generic(enum)
for member in enum.members:
self._write_member(member)
+ for method in sorted(enum.static_methods):
+ self._write_static_method(method)
def _write_bitfield(self, bitfield):
attrs = [('name', bitfield.name)]
@@ -348,6 +350,8 @@ and/or use gtk-doc annotations. ''')
self._write_generic(bitfield)
for member in bitfield.members:
self._write_member(member)
+ for method in sorted(bitfield.static_methods):
+ self._write_static_method(method)
def _write_member(self, member):
attrs = [('name', member.name),
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 8c07fda5..79004199 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -1006,7 +1006,7 @@ method or constructor of some type."""
node.static_methods.append(func)
return True
elif isinstance(node, (ast.Interface, ast.Record, ast.Union,
- ast.Boxed)):
+ ast.Boxed, ast.Enum, ast.Bitfield)):
# prior to the introduction of this part of the code, only
# ast.Class could have static methods. so for backwards
# compatibility, instead of removing the func from the namespace,