2008-04-14 Jürg Billeter <j@bitron.ch>
+ * vala/valaclass.vala, vala/valainterface.vala,
+ vala/valatypesymbol.vala, vala/valavaluetype.vala,
+ gobject/valaccodegenerator.vala: prepare support for nullable and
+ boxed value types
+
+2008-04-14 Jürg Billeter <j@bitron.ch>
+
* vala/Makefile.am, vala/valaarraytype.vala,
vala/valaclasstype.vala, vala/valacodenode.vala,
vala/valadatatype.vala, vala/valaerrortype.vala,
// pass non-simple structs always by reference
if (p.type_reference.data_type is Struct) {
var st = (Struct) p.type_reference.data_type;
- if (!st.is_simple_type () && !p.type_reference.is_ref && !p.type_reference.is_out) {
+ if (!st.is_simple_type () && !p.type_reference.is_ref && !p.type_reference.is_out && !p.type_reference.nullable) {
ctypename += "*";
}
}
}
public CCodeExpression get_implicit_cast_expression (CCodeExpression cexpr, DataType? expression_type, DataType target_type) {
- if (null == expression_type) {
+ if (expression_type == null) {
return cexpr;
}
return get_ref_function () != null;
}
- public override string get_ref_function () {
+ public override string? get_ref_function () {
if (ref_function == null && base_class != null) {
return base_class.get_ref_function ();
} else {
}
}
- public void set_ref_function (string name) {
+ public void set_ref_function (string? name) {
this.ref_function = name;
}
- public override string get_unref_function () {
+ public override string? get_unref_function () {
if (unref_function == null && base_class != null) {
return base_class.get_unref_function ();
} else {
}
}
- public void set_unref_function (string name) {
+ public void set_unref_function (string? name) {
this.unref_function = name;
}
- public override string get_dup_function () {
+ public override string? get_dup_function () {
return copy_function;
}
- public void set_dup_function (string name) {
+ public void set_dup_function (string? name) {
this.copy_function = name;
}
return get_lower_case_cprefix () + "free";
}
- public override string get_free_function () {
+ public override string? get_free_function () {
if (free_function == null) {
free_function = get_default_free_function ();
}
return true;
}
- public override string get_ref_function () {
+ public override string? get_ref_function () {
return "g_object_ref";
}
- public override string get_unref_function () {
+ public override string? get_unref_function () {
return "g_object_unref";
}
/* valatype.vala
*
- * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
+ * Copyright (C) 2006-2008 Jürg Billeter, Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* @return the name of the C function if supported or null otherwise
*/
- public virtual string get_dup_function () {
+ public virtual string? get_dup_function () {
return null;
}
/**
* Returns the C function name that frees instances of this data type.
- * This is only valid for data types with reference type semantics that
- * do not support reference counting. The specified C function must
- * accept one argument pointing to the instance to be freed.
+ * The specified C function must accept one argument pointing to the
+ * instance to be freed.
*
- * @return the name of the C function or null if this data type is not a
- * reference type or if it supports reference counting
+ * @return the name of the C function if supported or null otherwise
*/
- public virtual string get_free_function () {
+ public virtual string? get_free_function () {
return null;
}
-
+
+ /**
+ * Returns the C function name that copies contents of instances of
+ * this data type. This is only applicable to structs. The specified
+ * C function must accept two arguments, the first is the source value
+ * and the second is the destination value.
+ *
+ * @return the name of the C function if supported or null otherwise
+ */
+ public virtual string? get_copy_function () {
+ return null;
+ }
+
+ /**
+ * Returns the C function name that destroys the contents of instances
+ * of this data type. This is only applicable to structs. The specified
+ * C function must accept one argument pointing to the instance to be
+ * destroyed.
+ *
+ * @return the name of the C function if supported or null otherwise
+ */
+ public virtual string? get_destroy_function () {
+ return null;
+ }
+
/**
* Checks whether this data type supports reference counting. This is
* only valid for reference types.
* @return the name of the C function or null if this data type does not
* support reference counting
*/
- public virtual string get_ref_function () {
+ public virtual string? get_ref_function () {
return null;
}
* @return the name of the C function or null if this data type does not
* support reference counting
*/
- public virtual string get_unref_function () {
+ public virtual string? get_unref_function () {
return null;
}
return result;
}
+
+ public override string get_cname (bool var_type, bool const_type) {
+ string ptr = "";
+ if (is_ref || is_out) {
+ ptr += "*";
+ }
+ if (nullable) {
+ ptr += "*";
+ }
+ return type_symbol.get_cname (const_type) + ptr;
+ }
}