+2008-03-16 Jürg Billeter <j@bitron.ch>
+
+ * gobject/valaccodegenerator.vala,
+ gobject/valaccodegeneratormethod.vala: fix variable
+ initialization for array types
+
2008-03-16 Jürg Billeter <j@bitron.ch>
* vapigen/valagidlparser.vala: support hidden="0" for parameters
}
/* try to initialize uninitialized variables */
- if (decl.initializer == null && decl.type_reference.data_type is Struct) {
- if (decl.type_reference.data_type.get_default_value () != null) {
- ((CCodeVariableDeclarator) decl.ccodenode).initializer = new CCodeConstant (decl.type_reference.data_type.get_default_value ());
- } else {
- // 0-initialize struct with struct initializer { 0 }
- var clist = new CCodeInitializerList ();
- clist.append (new CCodeConstant ("0"));
-
- ((CCodeVariableDeclarator) decl.ccodenode).initializer = clist;
- }
+ if (decl.initializer == null) {
+ ((CCodeVariableDeclarator) decl.ccodenode).initializer = default_value_for_type (decl.type_reference);
}
}
return new CCodeConstant ("NULL");
} else if (type.data_type != null && type.data_type.get_default_value () != null) {
return new CCodeConstant (type.data_type.get_default_value ());
+ } else if (type.data_type is Struct) {
+ // 0-initialize struct with struct initializer { 0 }
+ var clist = new CCodeInitializerList ();
+ clist.append (new CCodeConstant ("0"));
+ return clist;
} else if (type.type_parameter != null) {
return new CCodeConstant ("NULL");
} else if (type is ErrorType) {