diff options
author | Colin Walters <walters@verbum.org> | 2009-02-27 19:02:48 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2009-03-05 15:52:12 -0500 |
commit | fdbe3cc3e1cfaa546648a76b1dca72beead0b65b (patch) | |
tree | 01156e22ec59d29c642d59ce7ad75f383d77466a /giscanner/ast.py | |
parent | b8e3172424ba956a0d18eae8deb305310b2cab74 (diff) | |
download | gobject-introspection-fdbe3cc3e1cfaa546648a76b1dca72beead0b65b.tar.gz |
Bug 557383 - Virtual method support
Broadly speaking, this change adds the concept of <vfunc> to the .gir.
The typelib already had most of the infrastructure for virtual functions,
though there is one API addition.
The scanner assumes that any class callback slot that doesn't match
a signal name is a virtual. In the .gir, we write out *both* the <method>
wrapper and a <vfunc>. If we can determine an association between
them (based on the names matching, or a new Virtual: annotation),
then we notate that in the .gir.
The typelib gains an association from the vfunc to the function, if
it exists. This will be useful for bindings since they already know
how to consume FunctionInfo.
Diffstat (limited to 'giscanner/ast.py')
-rw-r--r-- | giscanner/ast.py | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py index d2bae873..0f0d1bb5 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -196,15 +196,25 @@ class Include(Node): def __str__(self): return '%s-%s' % (self.name, self.version) +class Callable(Node): -class Function(Node): - - def __init__(self, name, retval, parameters, symbol, throws=None): + def __init__(self, name, retval, parameters, throws): Node.__init__(self, name) self.retval = retval self.parameters = parameters - self.symbol = symbol self.throws = not not throws + self.doc = None + + def __repr__(self): + return '%s(%r, %r, %r)' % (self.__class__.__name__, + self.name, self.retval, + self.parameters) + +class Function(Callable): + + def __init__(self, name, retval, parameters, symbol, throws=None): + Callable.__init__(self, name, retval, parameters, throws) + self.symbol = symbol self.is_method = False self.doc = None @@ -218,14 +228,18 @@ class Function(Node): if parameter.name == name: return parameter - def __repr__(self): - return '%s(%r, %r, %r)' % (self.__class__.__name__, - self.name, self.retval, - self.parameters) +class VFunction(Callable): -class VFunction(Function): - pass + def __init__(self, name, retval, parameters, throws): + Callable.__init__(self, name, retval, parameters, throws) + self.invoker = None + + @classmethod + def from_callback(cls, cb): + obj = cls(cb.name, cb.retval, cb.parameters[1:], + cb.throws) + return obj class Type(Node): @@ -411,6 +425,7 @@ class Class(Node): self.glib_type_struct = None self.is_abstract = is_abstract self.methods = [] + self.virtual_methods = [] self.static_methods = [] self.interfaces = [] self.constructors = [] @@ -430,6 +445,7 @@ class Interface(Node): Node.__init__(self, name) self.parent = parent self.methods = [] + self.virtual_methods = [] self.glib_type_struct = None self.properties = [] self.fields = [] |