bool in_gobject_creation_method = false;
bool in_fundamental_creation_method = false;
+ var creturn_type = current_return_type;
+
if (m is CreationMethod) {
in_creation_method = true;
var cl = current_type_symbol as Class;
in_gobject_creation_method = true;
}
}
+
+ if (cl != null) {
+ creturn_type = new ReferenceType (cl);
+ }
}
m.accept_children (this);
}
}
- function = new CCodeFunction (m.get_real_cname (), m.return_type.get_cname ());
+ function = new CCodeFunction (m.get_real_cname (), creturn_type.get_cname ());
m.ccodenode = function;
if (m.is_inline) {
}
if (m.is_abstract || m.is_virtual) {
- var vdecl = new CCodeDeclaration (m.return_type.get_cname ());
+ var vdecl = new CCodeDeclaration (creturn_type.get_cname ());
vdeclarator = new CCodeFunctionDeclarator (m.vfunc_name);
vdecl.add_declarator (vdeclarator);
type_struct.add_declaration (vdecl);
}
// return array length if appropriate
- if (!m.no_array_length && m.return_type.data_type is Array) {
- var arr = (Array) m.return_type.data_type;
+ if (!m.no_array_length && creturn_type.data_type is Array) {
+ var arr = (Array) creturn_type.data_type;
for (int dim = 1; dim <= arr.rank; dim++) {
var cparam = new CCodeFormalParameter (get_array_length_cname ("result", dim), "int*");
cinit.append (cdecl);
} else if (m.instance) {
- var ccheckstmt = create_method_type_check_statement (m, cl, true, "self");
+ var ccheckstmt = create_method_type_check_statement (m, creturn_type, cl, true, "self");
ccheckstmt.line = function.line;
cinit.append (ccheckstmt);
}
foreach (FormalParameter param in m.get_parameters ()) {
var t = param.type_reference.data_type;
if (t != null && t.is_reference_type () && !param.type_reference.is_out) {
- var type_check = create_method_type_check_statement (m, t, param.type_reference.non_null, param.name);
+ var type_check = create_method_type_check_statement (m, creturn_type, t, param.type_reference.non_null, param.name);
if (type_check != null) {
type_check.line = function.line;
cinit.append (type_check);
}
if (m.is_abstract || m.is_virtual) {
- var vfunc = new CCodeFunction (m.get_cname (), m.return_type.get_cname ());
+ var vfunc = new CCodeFunction (m.get_cname (), creturn_type.get_cname ());
vfunc.line = function.line;
var this_type = new DataType ();
}
// return array length if appropriate
- if (!m.no_array_length && m.return_type.data_type is Array) {
- var arr = (Array) m.return_type.data_type;
+ if (!m.no_array_length && creturn_type.data_type is Array) {
+ var arr = (Array) creturn_type.data_type;
for (int dim = 1; dim <= arr.rank; dim++) {
var cparam = new CCodeFormalParameter (get_array_length_cname ("result", dim), "int*");
}
CCodeStatement cstmt;
- if (m.return_type.data_type == null && m.return_type.type_parameter == null) {
+ if (creturn_type.data_type == null && creturn_type.type_parameter == null) {
cstmt = new CCodeExpressionStatement (vcall);
} else {
/* pass method return value */
}
}
- private CCodeStatement create_method_type_check_statement (Method! m, Typesymbol! t, bool non_null, string! var_name) {
- return create_type_check_statement (m, m.return_type.data_type, t, non_null, var_name);
+ private CCodeStatement create_method_type_check_statement (Method! m, DataType! return_type, Typesymbol! t, bool non_null, string! var_name) {
+ return create_type_check_statement (m, return_type.data_type, t, non_null, var_name);
}
private CCodeStatement create_property_type_check_statement (Property! prop, bool getter, Typesymbol! t, bool non_null, string! var_name) {