+2007-04-18 Jürg Billeter <j@bitron.ch>
+
+ * vala/valacodegenerator.vala: simplify unref expression for non-null
+ types
+ * vala/valaclass.vala: don't mark fields as non-null due to
+ initialization issue
+
2007-04-12 Jürg Billeter <j@bitron.ch>
* vala/valatypereference.vala: add is_null property
* @param f a field
*/
public void add_field (Field! f) {
+ // non_null fields not yet supported due to initialization issues
+ f.type_reference.non_null = false;
fields.append (f);
if (f.access == MemberAccessibility.PRIVATE && f.instance) {
_has_private_fields = true;
if (prop.set_accessor != null && prop.set_accessor.body == null &&
source_reference != null && !source_reference.file.pkg) {
/* automatic property accessor body generation */
- var f = new Field ("_%s".printf (prop.name), prop.type_reference, null, prop.source_reference);
+ var field_type = prop.type_reference.copy ();
+ // non_null fields not yet supported due to initialization issues
+ field_type.non_null = false;
+ var f = new Field ("_%s".printf (prop.name), field_type, null, prop.source_reference);
f.access = MemberAccessibility.PRIVATE;
add_field (f);
}
* if foo is of static type non-null
*/
+ if (type.is_null) {
+ return new CCodeConstant ("NULL");
+ }
+
var cisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, cvar, new CCodeConstant ("NULL"));
if (type.data_type == null) {
if (current_class == null) {
ccomma.append_expression (new CCodeConstant ("NULL"));
var cassign = new CCodeAssignment (cvar, ccomma);
-
+
+ // g_free (NULL) is allowed
+ if (type.non_null || (type.data_type != null && !type.data_type.is_reference_counting () && type.data_type.get_free_function () == "g_free")) {
+ return new CCodeParenthesizedExpression (cassign);
+ }
+
return new CCodeConditionalExpression (cisnull, new CCodeConstant ("NULL"), new CCodeParenthesizedExpression (cassign));
}