cfile.add_function (function);
}
+ public void return_default_value (DataType return_type) {
+ ccode.add_return (default_value_for_type (return_type, false));
+ }
+
public virtual string? get_custom_creturn_type (Method m) {
return null;
}
ccode.add_expression (cerrorcall);
// add return statement
- ccode.add_return (default_value_for_type (creturn_type, false));
+ return_default_value (creturn_type);
cfile.add_function (ccode);
}
propagate_error.add_argument (new CCodeIdentifier ("error"));
ccode.open_if (propagate_error);
- if (return_type is VoidType || return_type.is_real_non_null_struct_type ()) {
- ccode.add_return ();
- } else {
- ccode.add_return (default_value_for_type (return_type, false));
- }
+ return_default_value (return_type);
ccode.close ();
}
if (call_type == CallType.SYNC || call_type == CallType.FINISH) {
// return on error
ccode.open_if (new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, new CCodeIdentifier ("_reply")));
- if (m.return_type is VoidType || m.return_type.is_real_non_null_struct_type ()) {
- ccode.add_return ();
- } else {
- ccode.add_return (default_value_for_type (m.return_type, false));
- }
+ return_default_value (m.return_type);
ccode.close ();
ccode.add_declaration ("GVariantIter", new CCodeVariableDeclarator ("_reply_iter"));
// return on error
ccode.open_if (new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, new CCodeIdentifier ("_reply")));
- if (prop.property_type.is_real_non_null_struct_type ()) {
- ccode.add_return ();
- } else {
- ccode.add_return (default_value_for_type (prop.property_type, false));
- }
+ return_default_value (prop.property_type);
ccode.close ();
ccode.add_declaration ("GVariantIter", new CCodeVariableDeclarator ("_reply_iter"));
ccode.add_return (new CCodeConstant ("NULL"));
} else if (current_method != null && current_method.coroutine) {
ccode.add_return (new CCodeConstant ("FALSE"));
- } else if (current_return_type is VoidType) {
- ccode.add_return ();
} else {
- ccode.add_return (default_value_for_type (current_return_type, false));
+ return_default_value (current_return_type);
}
}
ccode.add_return (new CCodeConstant ("NULL"));
} else if (current_method != null && current_method.coroutine) {
ccode.add_return (new CCodeConstant ("FALSE"));
- } else if (current_return_type is VoidType) {
- ccode.add_return ();
} else if (current_return_type != null) {
- ccode.add_return (default_value_for_type (current_return_type, false));
+ return_default_value (current_return_type);
}
}