Binding perl: add support for out parameters
* bindings/perl/lang.py: support GObject out parameters.
This commit is contained in:
parent
a45c5844dd
commit
4c72a3662e
|
@ -94,7 +94,7 @@ pv_to_xmlnode(SV *value) {
|
||||||
*
|
*
|
||||||
* Return value: a newly create #GList
|
* Return value: a newly create #GList
|
||||||
*/
|
*/
|
||||||
static GList*
|
G_GNUC_UNUSED static GList*
|
||||||
array_to_glist_string(AV *array)
|
array_to_glist_string(AV *array)
|
||||||
{
|
{
|
||||||
I32 len, i;
|
I32 len, i;
|
||||||
|
|
|
@ -260,27 +260,41 @@ INCLUDE: LassoNode.xs
|
||||||
raise
|
raise
|
||||||
self.xs.p(name + '(')
|
self.xs.p(name + '(')
|
||||||
arg_list = []
|
arg_list = []
|
||||||
|
out_list = []
|
||||||
|
arg_names = []
|
||||||
if name.endswith('_new'):
|
if name.endswith('_new'):
|
||||||
arg_list.append('char *cls')
|
arg_list.append('char *cls')
|
||||||
|
arg_names.append('cls')
|
||||||
for arg in func.args:
|
for arg in func.args:
|
||||||
decl = ''
|
decl = ''
|
||||||
if is_cstring(arg):
|
aname = arg_name(arg)
|
||||||
if is_optional(arg):
|
if is_out(arg):
|
||||||
decl = 'string_or_null %s' % arg_name(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:
|
else:
|
||||||
decl = 'string_non_null %s' % arg_name(arg)
|
raise Exception('Out arg of type: %s is not supported' % (arg,))
|
||||||
elif not is_glist(arg):
|
|
||||||
decl = '%s %s' % (unconstify(arg_type(arg)), arg_name(arg))
|
|
||||||
else:
|
else:
|
||||||
decl = '%s %s' % (self.glist_type(arg), arg_name(arg))
|
if is_cstring(arg):
|
||||||
if is_optional(arg):
|
if is_optional(arg):
|
||||||
if arg_default(arg):
|
decl = 'string_or_null %s' % aname
|
||||||
decl += ' = ' + self.default_value(arg)
|
|
||||||
else:
|
|
||||||
if is_cstring(arg) or is_glist(arg) or is_xml_node(arg) or is_object(arg):
|
|
||||||
decl += ' = NULL'
|
|
||||||
else:
|
else:
|
||||||
raise Exception('Do not know what to do for optional: %s' % arg)
|
decl = 'string_non_null %s' % aname
|
||||||
|
elif not is_glist(arg):
|
||||||
|
decl = '%s %s' % (unconstify(arg_type(arg)), aname)
|
||||||
|
else:
|
||||||
|
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:
|
||||||
|
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)
|
arg_list.append(decl)
|
||||||
# Cleanup code, for by-reference arguments
|
# Cleanup code, for by-reference arguments
|
||||||
if is_glist(arg) and not is_transfer_full(arg):
|
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))
|
cleanup.append('lasso_release_xml_node(%s)' % arg_name(arg))
|
||||||
if is_hashtable(arg):
|
if is_hashtable(arg):
|
||||||
raise Exception("No cleanup code generation for GHashTable")
|
raise Exception("No cleanup code generation for GHashTable")
|
||||||
|
self.xs.p(','.join(arg_names))
|
||||||
self.xs.p(','.join(arg_list))
|
|
||||||
self.xs.pn(')')
|
self.xs.pn(')')
|
||||||
|
for decl in arg_list:
|
||||||
|
self.xs.pn(' %s' % (decl,))
|
||||||
if name.endswith('_new'):
|
if name.endswith('_new'):
|
||||||
self.xs.pn(' INIT:')
|
self.xs.pn(' INIT:')
|
||||||
self.xs.pn(' cls = NULL;')
|
self.xs.pn(' cls = NULL;')
|
||||||
|
@ -304,6 +318,13 @@ INCLUDE: LassoNode.xs
|
||||||
'first_arg': arg_name(func.args[0]),
|
'first_arg': arg_name(func.args[0]),
|
||||||
'gtype': prefix + 'get_type()'
|
'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
|
need_prototype = False
|
||||||
for x in func.args:
|
for x in func.args:
|
||||||
if is_glist(x):
|
if is_glist(x):
|
||||||
|
|
Loading…
Reference in New Issue