summaryrefslogtreecommitdiffstats
path: root/bindings/perl
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-02-22 15:18:29 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-02-22 15:18:29 +0000
commit4c72a3662e56777bc416e7886f8ed95996b2b53e (patch)
tree6b89b1f3c5b0758f6eed1528f7ddfdceb179fa4f /bindings/perl
parenta45c5844ddbcf87cbf65d0cf2fa61b22c2cb8ac5 (diff)
downloadlasso-4c72a3662e56777bc416e7886f8ed95996b2b53e.tar.gz
lasso-4c72a3662e56777bc416e7886f8ed95996b2b53e.tar.xz
lasso-4c72a3662e56777bc416e7886f8ed95996b2b53e.zip
Binding perl: add support for out parameters
* bindings/perl/lang.py: support GObject out parameters.
Diffstat (limited to 'bindings/perl')
-rw-r--r--bindings/perl/glist_handling.c2
-rw-r--r--bindings/perl/lang.py53
2 files changed, 38 insertions, 17 deletions
diff --git a/bindings/perl/glist_handling.c b/bindings/perl/glist_handling.c
index 88eba152..d36c59b0 100644
--- a/bindings/perl/glist_handling.c
+++ b/bindings/perl/glist_handling.c
@@ -94,7 +94,7 @@ pv_to_xmlnode(SV *value) {
*
* Return value: a newly create #GList
*/
-static GList*
+G_GNUC_UNUSED static GList*
array_to_glist_string(AV *array)
{
I32 len, i;
diff --git a/bindings/perl/lang.py b/bindings/perl/lang.py
index ee5f9f80..64e9d189 100644
--- a/bindings/perl/lang.py
+++ b/bindings/perl/lang.py
@@ -260,27 +260,41 @@ INCLUDE: LassoNode.xs
raise
self.xs.p(name + '(')
arg_list = []
+ out_list = []
+ arg_names = []
if name.endswith('_new'):
arg_list.append('char *cls')
+ arg_names.append('cls')
for arg in func.args:
decl = ''
- if is_cstring(arg):
- if is_optional(arg):
- decl = 'string_or_null %s' % arg_name(arg)
+ aname = arg_name(arg)
+ if is_out(arg):
+ arg_names.append(aname)
+ if not is_int(arg, self.binding_data) and is_object(arg):
+ decl = unconstify(arg_type(arg))[:-1] + ' &' + aname + ' = NO_INIT'
+ out_list.append(aname)
else:
- decl = 'string_non_null %s' % arg_name(arg)
- elif not is_glist(arg):
- decl = '%s %s' % (unconstify(arg_type(arg)), arg_name(arg))
+ raise Exception('Out arg of type: %s is not supported' % (arg,))
else:
- decl = '%s %s' % (self.glist_type(arg), arg_name(arg))
- if is_optional(arg):
- if arg_default(arg):
- decl += ' = ' + self.default_value(arg)
+ if is_cstring(arg):
+ if is_optional(arg):
+ decl = 'string_or_null %s' % aname
+ else:
+ decl = 'string_non_null %s' % aname
+ elif not is_glist(arg):
+ decl = '%s %s' % (unconstify(arg_type(arg)), aname)
else:
- if is_cstring(arg) or is_glist(arg) or is_xml_node(arg) or is_object(arg):
- decl += ' = NULL'
+ decl = '%s %s' % (self.glist_type(arg), aname)
+ if is_optional(arg):
+ if arg_default(arg):
+ arg_names.append(aname + ' = ' + self.default_value(arg))
else:
- raise Exception('Do not know what to do for optional: %s' % arg)
+ if is_cstring(arg) or is_glist(arg) or is_xml_node(arg) or is_object(arg):
+ arg_names.append(aname + ' = NULL')
+ else:
+ raise Exception('Do not know what to do for optional: %s' % arg)
+ else:
+ arg_names.append(aname)
arg_list.append(decl)
# Cleanup code, for by-reference arguments
if is_glist(arg) and not is_transfer_full(arg):
@@ -289,10 +303,10 @@ INCLUDE: LassoNode.xs
cleanup.append('lasso_release_xml_node(%s)' % arg_name(arg))
if is_hashtable(arg):
raise Exception("No cleanup code generation for GHashTable")
-
- self.xs.p(','.join(arg_list))
+ self.xs.p(','.join(arg_names))
self.xs.pn(')')
-
+ for decl in arg_list:
+ self.xs.pn(' %s' % (decl,))
if name.endswith('_new'):
self.xs.pn(' INIT:')
self.xs.pn(' cls = NULL;')
@@ -304,6 +318,13 @@ INCLUDE: LassoNode.xs
'first_arg': arg_name(func.args[0]),
'gtype': prefix + 'get_type()'
} )
+ if out_list:
+ self.xs.pn(' INIT:')
+ for o in out_list:
+ self.xs.pn(' %s = NULL;' % o)
+ self.xs.pn(' OUTPUT:')
+ for o in out_list:
+ self.xs.pn(' %s' % o)
need_prototype = False
for x in func.args:
if is_glist(x):