}
wrapper.block = new CCodeBlock ();
- if (d.return_type is GenericType) {
- wrapper.add_parameter (new CCodeFormalParameter ("result", "void *"));
- wrapper.block.add_statement (new CCodeExpressionStatement (call));
- } else if (d.return_type is VoidType) {
+ if (d.return_type is VoidType) {
wrapper.block.add_statement (new CCodeExpressionStatement (call));
} else {
- wrapper.return_type = d.return_type.get_cname ();
- wrapper.block.add_statement (new CCodeReturnStatement (call));
+ var method_return_type = method_type.method_symbol.return_type;
+ if (d.return_type is GenericType && !(method_return_type is GenericType)) {
+ wrapper.add_parameter (new CCodeFormalParameter ("result", method_return_type.get_cname () + "*"));
+ wrapper.block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("result")), call)));
+ } else if (!(d.return_type is GenericType) && method_return_type is GenericType) {
+ wrapper.return_type = d.return_type.get_cname ();
+ var cdecl = new CCodeDeclaration (d.return_type.get_cname ());
+ cdecl.add_declarator (new CCodeVariableDeclarator ("result"));
+ call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("result")));
+ wrapper.block.add_statement (new CCodeExpressionStatement (call));
+ wrapper.block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("result")));
+ } else if (d.return_type is GenericType) {
+ wrapper.add_parameter (new CCodeFormalParameter ("result", "void *"));
+ wrapper.block.add_statement (new CCodeExpressionStatement (call));
+ } else {
+ wrapper.return_type = d.return_type.get_cname ();
+ wrapper.block.add_statement (new CCodeReturnStatement (call));
+ }
}
source_type_member_definition.append (wrapper);
/* valadovadelegatemodule.vala
*
- * Copyright (C) 2006-2009 Jürg Billeter
+ * Copyright (C) 2006-2010 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
}
CCodeFunction generate_invoke_function (Delegate d, CCodeDeclarationSpace decl_space) {
- var function = new CCodeFunction ("%s_invoke".printf (d.get_lower_case_cname ()), d.return_type.get_cname ());
+ var function = new CCodeFunction ("%s_invoke".printf (d.get_lower_case_cname ()));
if (d.is_private_symbol ()) {
function.modifiers |= CCodeModifiers.STATIC;
param_list += param.parameter_type.get_cname ();
}
+ if (d.return_type is GenericType) {
+ function.add_parameter (new CCodeFormalParameter ("result", "void *"));
+
+ if (param_list != "") {
+ param_list += ", ";
+ }
+ param_list += "void *";
+ } else {
+ function.return_type = d.return_type.get_cname ();
+ }
+
function.block = new CCodeBlock ();
var get_target = new CCodeFunctionCall (new CCodeIdentifier ("dova_delegate_get_target"));
instance_param_list += ")";
var instance_block = new CCodeBlock ();
- var instance_call = new CCodeFunctionCall (new CCodeCastExpression (new CCodeMemberAccess.pointer (priv, "method"), "%s (*) %s".printf (d.return_type.get_cname (), instance_param_list)));
+ var instance_call = new CCodeFunctionCall (new CCodeCastExpression (new CCodeMemberAccess.pointer (priv, "method"), "%s (*) %s".printf (function.return_type, instance_param_list)));
instance_call.add_argument (new CCodeIdentifier ("target"));
static_param_list += ")";
var static_block = new CCodeBlock ();
- var static_call = new CCodeFunctionCall (new CCodeCastExpression (new CCodeMemberAccess.pointer (priv, "method"), "%s (*) %s".printf (d.return_type.get_cname (), static_param_list)));
+ var static_call = new CCodeFunctionCall (new CCodeCastExpression (new CCodeMemberAccess.pointer (priv, "method"), "%s (*) %s".printf (function.return_type, static_param_list)));
foreach (FormalParameter param in d.get_parameters ()) {
instance_call.add_argument (new CCodeIdentifier (param.name));
if (d.return_type is VoidType) {
instance_block.add_statement (new CCodeExpressionStatement (instance_call));
static_block.add_statement (new CCodeExpressionStatement (static_call));
+ } else if (d.return_type is GenericType) {
+ instance_call.add_argument (new CCodeIdentifier ("result"));
+ static_call.add_argument (new CCodeIdentifier ("result"));
+ instance_block.add_statement (new CCodeExpressionStatement (instance_call));
+ static_block.add_statement (new CCodeExpressionStatement (static_call));
} else {
instance_block.add_statement (new CCodeReturnStatement (instance_call));
static_block.add_statement (new CCodeReturnStatement (static_call));