Author: juergbi
Date: Fri Feb 15 12:08:48 2008
New Revision: 1011
URL: http://svn.gnome.org/viewvc/vala?rev=1011&view=rev

Log:
2008-02-15  Juerg Billeter  <[EMAIL PROTECTED]>

        * gobject/valaccodeassignmentbinding.vala,
          gobject/valaccodegenerator.vala: generate casts for property
          assignments where necessary, fixes bug 511732


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodeassignmentbinding.vala
   trunk/gobject/valaccodegenerator.vala

Modified: trunk/gobject/valaccodeassignmentbinding.vala
==============================================================================
--- trunk/gobject/valaccodeassignmentbinding.vala       (original)
+++ trunk/gobject/valaccodeassignmentbinding.vala       Fri Feb 15 12:08:48 2008
@@ -69,11 +69,12 @@
                } else {
                        CCodeExpression cexpr = (CCodeExpression) 
assignment.right.ccodenode;
 
+                       // ensure to pass the value correctly typed (especially 
important for varargs)
+                       cexpr = codegen.get_implicit_cast_expression (cexpr, 
assignment.right.static_type, prop.type_reference);
+
                        if (!prop.no_accessor_method) {
                                if (prop.type_reference.is_real_struct_type ()) 
{
-                                       cexpr = 
codegen.get_address_of_expression (assignment.right, 
codegen.get_implicit_cast_expression (cexpr, assignment.right.static_type, 
prop.type_reference));
-                               } else {
-                                       cexpr = 
codegen.get_implicit_cast_expression (cexpr, assignment.right.static_type, 
prop.type_reference);
+                                       cexpr = 
codegen.get_address_of_expression (assignment.right, cexpr);
                                }
                        }
 

Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala       (original)
+++ trunk/gobject/valaccodegenerator.vala       Fri Feb 15 12:08:48 2008
@@ -3086,8 +3086,14 @@
 
                if (context.checking && target_type.data_type != null && 
target_type.data_type.is_subtype_of (gtypeinstance_type)) {
                        return new InstanceCast (cexpr, target_type.data_type);
-               } else if (target_type.data_type != null && 
target_type.data_type.is_reference_type () && expression_type.get_cname () != 
target_type.get_cname ()) {
-                       return new CCodeCastExpression (cexpr, 
target_type.get_cname ());
+               } else if (target_type.data_type != null && 
expression_type.get_cname () != target_type.get_cname ()) {
+                       var st = target_type.data_type as Struct;
+                       if (target_type.data_type.is_reference_type () || (st 
!= null && st.is_simple_type ())) {
+                               // don't cast non-simple structs
+                               return new CCodeCastExpression (cexpr, 
target_type.get_cname ());
+                       } else {
+                               return cexpr;
+                       }
                } else if (target_type is DelegateType && expression_type is 
MethodType) {
                        var dt = (DelegateType) target_type;
                        var mt = (MethodType) expression_type;
_______________________________________________
SVN-commits-list mailing list (read only)
http://mail.gnome.org/mailman/listinfo/svn-commits-list

Want to limit the commits to a few modules? Go to above URL, log in to edit 
your options and select the modules ('topics') you want.
Module maintainer? It is possible to set the reply-to to your development 
mailing list. Email [EMAIL PROTECTED] if interested.

Reply via email to