diff options
author | Andreas Rottmann <a.rottmann@gmx.at> | 2009-03-09 18:33:00 +0100 |
---|---|---|
committer | Andreas Rottmann <a.rottmann@gmx.at> | 2009-03-09 18:33:00 +0100 |
commit | 2bd97368f6ced0d23977ce980ac159453cc18d8c (patch) | |
tree | 4be7dad53ed3c482832547cf917d70ba3cb90a15 | |
parent | fdbe3cc3e1cfaa546648a76b1dca72beead0b65b (diff) | |
download | gobject-introspection-2bd97368f6ced0d23977ce980ac159453cc18d8c.tar.gz |
Bug 574139 – There is no way to identify 'user_data' arguments in the callback signature
Add a heuristic to the scanner that flags arguments of callbacks that
are named 'user_data' (exact match) and have a 'any (void*) type.
These arguments are marked by setting the 'closure' field of ArgBlob
to the index of themselves.
Signed-off-by: Andreas Rottmann <a.rottmann@gmx.at>
-rw-r--r-- | giscanner/transformer.py | 11 | ||||
-rw-r--r-- | tests/scanner/annotation-1.0-expected.gir | 2 | ||||
-rw-r--r-- | tests/scanner/annotation-1.0-expected.tgir | 2 | ||||
-rw-r--r-- | tests/scanner/utility-1.0-expected.gir | 2 | ||||
-rw-r--r-- | tests/scanner/utility-1.0-expected.tgir | 2 |
5 files changed, 13 insertions, 6 deletions
diff --git a/giscanner/transformer.py b/giscanner/transformer.py index 8e3219ae..9aebbd80 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -534,13 +534,20 @@ class Transformer(object): return self._create_compound(Union, symbol, anonymous) def _create_callback(self, symbol): - parameters = self._create_parameters(symbol.base_type.base_type) + parameters = list(self._create_parameters(symbol.base_type.base_type)) retval = self._create_return(symbol.base_type.base_type.base_type) + + # Mark the 'user_data' arguments + for i, param in enumerate(parameters): + if (param.type.name == 'any' and + param.name == 'user_data'): + param.closure_index = i + if symbol.ident.find('_') > 0: name = self.remove_prefix(symbol.ident, True) else: name = self.remove_prefix(symbol.ident) - callback = Callback(name, retval, list(parameters), symbol.ident) + callback = Callback(name, retval, parameters, symbol.ident) return callback diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir index f4273454..1af72719 100644 --- a/tests/scanner/annotation-1.0-expected.gir +++ b/tests/scanner/annotation-1.0-expected.gir @@ -34,7 +34,7 @@ and/or use gtk-doc annotations. --> <parameter name="item" transfer-ownership="none"> <type name="utf8" c:type="char*"/> </parameter> - <parameter name="user_data" transfer-ownership="none"> + <parameter name="user_data" transfer-ownership="none" closure="2"> <type name="any" c:type="gpointer"/> </parameter> </parameters> diff --git a/tests/scanner/annotation-1.0-expected.tgir b/tests/scanner/annotation-1.0-expected.tgir index 2075143c..2a1426b5 100644 --- a/tests/scanner/annotation-1.0-expected.tgir +++ b/tests/scanner/annotation-1.0-expected.tgir @@ -28,7 +28,7 @@ <parameter name="item" transfer-ownership="none"> <type name="utf8"/> </parameter> - <parameter name="user_data" transfer-ownership="none"> + <parameter name="user_data" transfer-ownership="none" closure="2"> <type name="any"/> </parameter> </parameters> diff --git a/tests/scanner/utility-1.0-expected.gir b/tests/scanner/utility-1.0-expected.gir index 0ca72cb8..331979c9 100644 --- a/tests/scanner/utility-1.0-expected.gir +++ b/tests/scanner/utility-1.0-expected.gir @@ -37,7 +37,7 @@ and/or use gtk-doc annotations. --> <parameter name="path" transfer-ownership="none"> <type name="utf8" c:type="char*"/> </parameter> - <parameter name="user_data" transfer-ownership="none"> + <parameter name="user_data" transfer-ownership="none" closure="1"> <type name="any" c:type="gpointer"/> </parameter> </parameters> diff --git a/tests/scanner/utility-1.0-expected.tgir b/tests/scanner/utility-1.0-expected.tgir index 26535846..dfd2aa80 100644 --- a/tests/scanner/utility-1.0-expected.tgir +++ b/tests/scanner/utility-1.0-expected.tgir @@ -24,7 +24,7 @@ <parameter name="path" transfer-ownership="none"> <type name="utf8"/> </parameter> - <parameter name="user_data" transfer-ownership="none"> + <parameter name="user_data" transfer-ownership="none" closure="1"> <type name="any"/> </parameter> </parameters> |