generate_method_declaration (m, source_declarations);
- creation_call = new CCodeFunctionCall (new CCodeIdentifier (m.get_cname ()));
+ var cl = expr.type_reference.data_type as Class;
+
+ if (!m.has_new_function) {
+ // use construct function directly
+ creation_call = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname ()));
+ creation_call.add_argument (new CCodeIdentifier (cl.get_type_id ()));
+ } else {
+ creation_call = new CCodeFunctionCall (new CCodeIdentifier (m.get_cname ()));
+ }
if ((st != null && !st.is_simple_type ()) && !(m.cinstance_parameter_position < 0)) {
creation_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, instance));
generate_type_declaration (expr.type_reference, source_declarations);
- var cl = expr.type_reference.data_type as Class;
if (cl != null && !cl.is_compact) {
add_generic_type_arguments (creation_call, expr.type_reference.get_type_arguments (), expr);
}
return get_cname ();
}
+ var ccode_attribute = get_attribute ("CCode");
+ if (ccode_attribute != null && ccode_attribute.has_argument ("construct_function")) {
+ return ccode_attribute.get_string ("construct_function");
+ }
+
string infix = "construct";
if (name == ".new") {
*/
public bool scanf_format { get; set; }
+ /**
+ * Specifies whether a new function without a GType parameter is
+ * available. This is only applicable to creation methods.
+ */
+ public bool has_new_function { get; set; default = true; }
+
/**
* Specifies whether a construct function with a GType parameter is
* available. This is only applicable to creation methods.
if (a.has_argument ("delegate_target_pos")) {
cdelegate_target_parameter_position = a.get_double ("delegate_target_pos");
}
+ if (a.has_argument ("has_new_function")) {
+ has_new_function = a.get_bool ("has_new_function");
+ }
if (a.has_argument ("has_construct_function")) {
has_construct_function = a.get_bool ("has_construct_function");
}
public class Object {
public uint ref_count;
- [CCode (has_construct_function = false)]
- public Object (Type type = typeof (Object), ...);
+ [CCode (has_new_function = false, construct_function = "g_object_new")]
+ public Object (...);
#if VALA_0_7_6_NEW_METHODS
public static Object @new (Type type, ...);