From 2bd97368f6ced0d23977ce980ac159453cc18d8c Mon Sep 17 00:00:00 2001 From: Andreas Rottmann Date: Mon, 09 Mar 2009 17:33:00 +0000 Subject: 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 --- diff --git a/giscanner/transformer.py b/giscanner/transformer.py index 8e3219a..9aebbd8 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 f427345..1af7271 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. --> - + diff --git a/tests/scanner/annotation-1.0-expected.tgir b/tests/scanner/annotation-1.0-expected.tgir index 2075143..2a1426b 100644 --- a/tests/scanner/annotation-1.0-expected.tgir +++ b/tests/scanner/annotation-1.0-expected.tgir @@ -28,7 +28,7 @@ - + diff --git a/tests/scanner/utility-1.0-expected.gir b/tests/scanner/utility-1.0-expected.gir index 0ca72cb..331979c 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. --> - + diff --git a/tests/scanner/utility-1.0-expected.tgir b/tests/scanner/utility-1.0-expected.tgir index 2653584..dfd2aa8 100644 --- a/tests/scanner/utility-1.0-expected.tgir +++ b/tests/scanner/utility-1.0-expected.tgir @@ -24,7 +24,7 @@ - + -- cgit v0.9.1