+2008-03-15 Jürg Billeter <j@bitron.ch>
+
+ * gobject/valaccodegenerator.vala,
+ gobject/valaccodegeneratormemberaccess.vala,
+ gobject/valaccodegeneratormethod.vala: fix runtime crash when
+ using nullable struct parameters,
+ patch by Alberto Ruiz, fixes bug 514864
+
2008-03-14 Jürg Billeter <j@bitron.ch>
* vapi/packages/gdk-2.0/, vapi/packages/gtk+-2.0/: fix gdk/gtk_init
var st = (Struct) p.type_reference.data_type;
if (!st.is_simple_type () && !p.type_reference.is_ref && !p.type_reference.is_out) {
ctypename += "*";
- cname = "_%s_p".printf (p.name);
}
}
if (expr.operator == BinaryOperator.EQUALITY ||
expr.operator == BinaryOperator.INEQUALITY) {
+ var left_type_as_struct = expr.left.static_type.data_type as Struct;
+ var right_type_as_struct = expr.right.static_type.data_type as Struct;
+
if (expr.left.static_type.data_type is Class && ((Class) expr.left.static_type.data_type).is_subtype_of (gobject_type) &&
expr.right.static_type.data_type is Class && ((Class) expr.right.static_type.data_type).is_subtype_of (gobject_type)) {
var left_cl = (Class) expr.left.static_type.data_type;
cright = new InstanceCast (cright, left_cl);
}
}
+ } else if (left_type_as_struct != null && expr.right.static_type is NullType) {
+ cleft = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cleft);
+ } else if (right_type_as_struct != null && expr.left.static_type is NullType) {
+ cright = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cright);
}
}
if (p.name == "this") {
expr.ccodenode = pub_inst;
} else {
- if (p.type_reference.is_out || p.type_reference.is_ref) {
+ var type_as_struct = p.type_reference.data_type as Struct;
+ if (p.type_reference.is_out
+ || p.type_reference.is_ref
+ || (type_as_struct != null && !type_as_struct.is_simple_type ())) {
expr.ccodenode = new CCodeIdentifier ("(*%s)".printf (p.name));
} else {
// Property setters of non simple structs shall replace all occurences
var a = new CCodeAssignment (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier (param.name)), new CCodeConstant ("NULL"));
cinit.append (new CCodeExpressionStatement (a));
}
- } else if (t is Struct) {
- var st = (Struct) t;
- if (!st.is_simple_type () && !param.type_reference.is_ref && !param.type_reference.is_out) {
- var cdecl = new CCodeDeclaration (param.type_reference.get_cname ());
- cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer (param.name, new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("_%s_p".printf (param.name)))));
- cinit.append (cdecl);
- }
}
}