diff options
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/ast.py | 4 | ||||
-rw-r--r-- | giscanner/maintransformer.py | 14 |
2 files changed, 13 insertions, 5 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py index b992c111..130f50c5 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -681,8 +681,8 @@ class VFunction(Callable): self.invoker = None @classmethod - def from_callback(cls, cb): - obj = cls(cb.name, cb.retval, cb.parameters[1:], + def from_callback(cls, name, cb): + obj = cls(name, cb.retval, cb.parameters[1:], cb.throws) return obj diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index c107beed..e6f04684 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -1225,16 +1225,24 @@ method or constructor of some type.""" field.writable = False for field in class_struct.fields: - if not isinstance(field.anonymous_node, ast.Callback): + callback = None + + if isinstance(field.anonymous_node, ast.Callback): + callback = field.anonymous_node + elif field.type is not None: + callback = self._transformer.lookup_typenode(field.type) + if not isinstance(callback, ast.Callback): + continue + else: continue - callback = field.anonymous_node + # Check the first parameter is the object if len(callback.parameters) == 0: continue firstparam_type = callback.parameters[0].type if firstparam_type != node_type: continue - vfunc = ast.VFunction.from_callback(callback) + vfunc = ast.VFunction.from_callback(field.name, callback) vfunc.instance_parameter = callback.parameters[0] vfunc.inherit_file_positions(callback) |