Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
scanner: Add c_type for callbacks
Browse files Browse the repository at this point in the history
We weren't doing this consistently, which broke nsname != cprefix
cases.

https://bugzilla.gnome.org/show_bug.cgi?id=629683
  • Loading branch information
cgwalters committed Sep 14, 2010
1 parent c29368b commit d8c4caf
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion giscanner/girwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def _write_vfunc(self, vf):
def _write_callback(self, callback):
attrs = []
if callback.namespace:
attrs.append(('c:type', callback.c_name))
attrs.append(('c:type', callback.ctype or callback.c_name))
self._write_callable(callback, 'callback', attrs)

def _write_record(self, record, extra_attrs=[]):
Expand Down
3 changes: 2 additions & 1 deletion giscanner/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,8 @@ def _create_callback(self, symbol, member=False):
except TransformerException, e:
message.warn(e)
return None
callback = ast.Callback(name, retval, parameters, False)
callback = ast.Callback(name, retval, parameters, False,
ctype=symbol.ident)
callback.add_symbol_reference(symbol)

return callback
Expand Down
19 changes: 19 additions & 0 deletions tests/scanner/Regress-1.0-expected.gir
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,25 @@ use it should be.</doc>
<type name="gint" c:type="int"/>
</return-value>
</callback>
<callback name="TestCallbackFull" c:type="RegressTestCallbackFull">
<return-value transfer-ownership="none">
<type name="gint" c:type="int"/>
</return-value>
<parameters>
<parameter name="foo" transfer-ownership="none">
<doc xml:whitespace="preserve">the investment rate</doc>
<type name="gint" c:type="int"/>
</parameter>
<parameter name="bar" transfer-ownership="none">
<doc xml:whitespace="preserve">how much money</doc>
<type name="gdouble" c:type="double"/>
</parameter>
<parameter name="path" transfer-ownership="none">
<doc xml:whitespace="preserve">Path to file</doc>
<type name="filename"/>
</parameter>
</parameters>
</callback>
<callback name="TestCallbackUserData" c:type="RegressTestCallbackUserData">
<return-value transfer-ownership="none">
<type name="gint" c:type="int"/>
Expand Down
7 changes: 7 additions & 0 deletions tests/scanner/regress.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,13 @@ regress_test_fundamental_sub_object_new (const char *data);
typedef void (*RegressTestSimpleCallback) (void);
typedef int (*RegressTestCallback) (void);
typedef int (*RegressTestCallbackUserData) (gpointer user_data);
/**
* RegressTestCallbackFull:
* @foo: the investment rate
* @bar: how much money
* @path: (type filename): Path to file
*/
typedef int (*RegressTestCallbackFull) (int foo, double bar, char *path);

void regress_test_simple_callback (RegressTestSimpleCallback callback);
int regress_test_callback (RegressTestCallback callback);
Expand Down

0 comments on commit d8c4caf

Please sign in to comment.