]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Support inheritance for type_id, marshaller_type_name, get_value_function,
authorJuerg Billeter <j@bitron.ch>
Thu, 8 May 2008 20:19:15 +0000 (20:19 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Thu, 8 May 2008 20:19:15 +0000 (20:19 +0000)
2008-05-08  Juerg Billeter  <j@bitron.ch>

* vala/valastruct.vala:
* gobject/valaccodetypesymbolbinding.vala:

Support inheritance for type_id, marshaller_type_name,
get_value_function, and set_value_function

* vapi/glib-2.0.vapi:

Set type_id, marshaller_type_name, get_value_function, and
set_value_function for uint32, fixes bug 530603

svn path=/trunk/; revision=1344

ChangeLog
gobject/valaccodetypesymbolbinding.vala
vala/valastruct.vala
vapi/glib-2.0.vapi

index 950fdf456a72251dcda4ec3e47212dc39022d219..f9c9ddf88ae2190380828769ba16ea586be5165f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2008-05-08  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valastruct.vala:
+       * gobject/valaccodetypesymbolbinding.vala:
+
+       Support inheritance for type_id, marshaller_type_name,
+       get_value_function, and set_value_function
+
+       * vapi/glib-2.0.vapi:
+
+       Set type_id, marshaller_type_name, get_value_function, and
+       set_value_function for uint32, fixes bug 530603
+
 2008-05-08  Jürg Billeter  <j@bitron.ch>
 
        * vapi/sdl.vapi: add SDL ActiveState enum,
index 3b0d4304b65c6d5de5040ce1ff081884b686763c..c54342fb42ac909261ffd0d8ccc6edbb5156b3bc 100644 (file)
@@ -61,83 +61,87 @@ public abstract class Vala.CCodeTypesymbolBinding : CCodeBinding {
                        } else {
                                cspec.add_argument (new CCodeConstant (prop.type_reference.data_type.get_default_value ()));
                        }
-               } else if (prop.type_reference.data_type == codegen.int_type.data_type) {
-                       cspec.call = new CCodeIdentifier ("g_param_spec_int");
-                       cspec.add_argument (new CCodeConstant ("G_MININT"));
-                       cspec.add_argument (new CCodeConstant ("G_MAXINT"));
-                       if (prop.default_expression != null) {
-                               cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
-                       } else {
+               } else if (prop.type_reference.data_type is Struct) {
+                       var st = (Struct) prop.type_reference.data_type;
+                       if (st.get_type_id () == "G_TYPE_INT") {
+                               cspec.call = new CCodeIdentifier ("g_param_spec_int");
+                               cspec.add_argument (new CCodeConstant ("G_MININT"));
+                               cspec.add_argument (new CCodeConstant ("G_MAXINT"));
+                               if (prop.default_expression != null) {
+                                       cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+                               } else {
+                                       cspec.add_argument (new CCodeConstant ("0"));
+                               }
+                       } else if (st.get_type_id () == "G_TYPE_UINT") {
+                               cspec.call = new CCodeIdentifier ("g_param_spec_uint");
                                cspec.add_argument (new CCodeConstant ("0"));
-                       }
-               } else if (prop.type_reference.data_type == codegen.uint_type.data_type) {
-                       cspec.call = new CCodeIdentifier ("g_param_spec_uint");
-                       cspec.add_argument (new CCodeConstant ("0"));
-                       cspec.add_argument (new CCodeConstant ("G_MAXUINT"));
-                       if (prop.default_expression != null) {
-                               cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
-                       } else {
-                               cspec.add_argument (new CCodeConstant ("0U"));
-                       }
-               } else if (prop.type_reference.data_type == codegen.long_type.data_type) {
-                       cspec.call = new CCodeIdentifier ("g_param_spec_long");
-                       cspec.add_argument (new CCodeConstant ("G_MINLONG"));
-                       cspec.add_argument (new CCodeConstant ("G_MAXLONG"));
-                       if (prop.default_expression != null) {
-                               cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
-                       } else {
-                               cspec.add_argument (new CCodeConstant ("0L"));
-                       }
-               } else if (prop.type_reference.data_type == codegen.ulong_type.data_type) {
-                       cspec.call = new CCodeIdentifier ("g_param_spec_ulong");
-                       cspec.add_argument (new CCodeConstant ("0"));
-                       cspec.add_argument (new CCodeConstant ("G_MAXULONG"));
-                       if (prop.default_expression != null) {
-                               cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
-                       } else {
-                               cspec.add_argument (new CCodeConstant ("0UL"));
-                       }
-               } else if (prop.type_reference.data_type == codegen.bool_type.data_type) {
-                       cspec.call = new CCodeIdentifier ("g_param_spec_boolean");
-                       if (prop.default_expression != null) {
-                               cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
-                       } else {
-                               cspec.add_argument (new CCodeConstant ("FALSE"));
-                       }
-               } else if (prop.type_reference.data_type == codegen.int8_type.data_type
-                          || prop.type_reference.data_type == codegen.char_type.data_type) {
-                       cspec.call = new CCodeIdentifier ("g_param_spec_char");
-                       cspec.add_argument (new CCodeConstant ("G_MININT8"));
-                       cspec.add_argument (new CCodeConstant ("G_MAXINT8"));
-                       if (prop.default_expression != null) {
-                               cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
-                       } else {
+                               cspec.add_argument (new CCodeConstant ("G_MAXUINT"));
+                               if (prop.default_expression != null) {
+                                       cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+                               } else {
+                                       cspec.add_argument (new CCodeConstant ("0U"));
+                               }
+                       } else if (st.get_type_id () == "G_TYPE_LONG") {
+                               cspec.call = new CCodeIdentifier ("g_param_spec_long");
+                               cspec.add_argument (new CCodeConstant ("G_MINLONG"));
+                               cspec.add_argument (new CCodeConstant ("G_MAXLONG"));
+                               if (prop.default_expression != null) {
+                                       cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+                               } else {
+                                       cspec.add_argument (new CCodeConstant ("0L"));
+                               }
+                       } else if (st.get_type_id () == "G_TYPE_ULONG") {
+                               cspec.call = new CCodeIdentifier ("g_param_spec_ulong");
                                cspec.add_argument (new CCodeConstant ("0"));
-                       }
-               } else if (prop.type_reference.data_type == codegen.float_type.data_type) {
-                       cspec.call = new CCodeIdentifier ("g_param_spec_float");
-                       cspec.add_argument (new CCodeConstant ("-G_MAXFLOAT"));
-                       cspec.add_argument (new CCodeConstant ("G_MAXFLOAT"));
-                       if (prop.default_expression != null) {
-                               cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
-                       } else {
-                               cspec.add_argument (new CCodeConstant ("0.0F"));
-                       }
-               } else if (prop.type_reference.data_type == codegen.double_type.data_type) {
-                       cspec.call = new CCodeIdentifier ("g_param_spec_double");
-                       cspec.add_argument (new CCodeConstant ("-G_MAXDOUBLE"));
-                       cspec.add_argument (new CCodeConstant ("G_MAXDOUBLE"));
-                       if (prop.default_expression != null) {
-                               cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
-                       } else {
-                               cspec.add_argument (new CCodeConstant ("0.0"));
-                       }
-               } else if (prop.type_reference.data_type == codegen.gtype_type) {
-                       cspec.call = new CCodeIdentifier ("g_param_spec_gtype");
-                       if (prop.default_expression != null) {
-                               cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+                               cspec.add_argument (new CCodeConstant ("G_MAXULONG"));
+                               if (prop.default_expression != null) {
+                                       cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+                               } else {
+                                       cspec.add_argument (new CCodeConstant ("0UL"));
+                               }
+                       } else if (st.get_type_id () == "G_TYPE_BOOLEAN") {
+                               cspec.call = new CCodeIdentifier ("g_param_spec_boolean");
+                               if (prop.default_expression != null) {
+                                       cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+                               } else {
+                                       cspec.add_argument (new CCodeConstant ("FALSE"));
+                               }
+                       } else if (st.get_type_id () == "G_TYPE_CHAR") {
+                               cspec.call = new CCodeIdentifier ("g_param_spec_char");
+                               cspec.add_argument (new CCodeConstant ("G_MININT8"));
+                               cspec.add_argument (new CCodeConstant ("G_MAXINT8"));
+                               if (prop.default_expression != null) {
+                                       cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+                               } else {
+                                       cspec.add_argument (new CCodeConstant ("0"));
+                               }
+                       } else if (st.get_type_id () == "G_TYPE_FLOAT") {
+                               cspec.call = new CCodeIdentifier ("g_param_spec_float");
+                               cspec.add_argument (new CCodeConstant ("-G_MAXFLOAT"));
+                               cspec.add_argument (new CCodeConstant ("G_MAXFLOAT"));
+                               if (prop.default_expression != null) {
+                                       cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+                               } else {
+                                       cspec.add_argument (new CCodeConstant ("0.0F"));
+                               }
+                       } else if (st.get_type_id () == "G_TYPE_FLOAT") {
+                               cspec.call = new CCodeIdentifier ("g_param_spec_double");
+                               cspec.add_argument (new CCodeConstant ("-G_MAXDOUBLE"));
+                               cspec.add_argument (new CCodeConstant ("G_MAXDOUBLE"));
+                               if (prop.default_expression != null) {
+                                       cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+                               } else {
+                                       cspec.add_argument (new CCodeConstant ("0.0"));
+                               }
+                       } else if (st.get_type_id () == "G_TYPE_GTYPE") {
+                               cspec.call = new CCodeIdentifier ("g_param_spec_gtype");
+                               if (prop.default_expression != null) {
+                                       cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+                               } else {
+                                       cspec.add_argument (new CCodeConstant ("G_TYPE_NONE"));
+                               }
                        } else {
-                               cspec.add_argument (new CCodeConstant ("G_TYPE_NONE"));
+                               cspec.call = new CCodeIdentifier ("g_param_spec_pointer");
                        }
                } else {
                        cspec.call = new CCodeIdentifier ("g_param_spec_pointer");
index bd97bd06382c66754de1b5e5632f3ebda65e9c6e..4928dd2d906ed1e0ac2648e072330690c2add12b 100644 (file)
@@ -354,6 +354,12 @@ public class Vala.Struct : Typesymbol {
 
        public override string? get_type_id () {
                if (type_id == null) {
+                       foreach (DataType type in base_types) {
+                               var st = type.data_type as Struct;
+                               if (st != null) {
+                                       return st.get_type_id ();;
+                               }
+                       }
                        if (simple_type) {
                                Report.error (source_reference, "The type `%s` doesn't declare a type id".printf (get_full_name ()));
                        } else {
@@ -369,6 +375,12 @@ public class Vala.Struct : Typesymbol {
 
        public override string? get_marshaller_type_name () {
                if (marshaller_type_name == null) {
+                       foreach (DataType type in base_types) {
+                               var st = type.data_type as Struct;
+                               if (st != null) {
+                                       return st.get_marshaller_type_name ();
+                               }
+                       }
                        if (simple_type) {
                                Report.error (source_reference, "The type `%s` doesn't declare a marshaller type name".printf (get_full_name ()));
                        } else {
@@ -384,6 +396,12 @@ public class Vala.Struct : Typesymbol {
        
        public override string? get_get_value_function () {
                if (get_value_function == null) {
+                       foreach (DataType type in base_types) {
+                               var st = type.data_type as Struct;
+                               if (st != null) {
+                                       return st.get_get_value_function ();
+                               }
+                       }
                        if (simple_type) {
                                Report.error (source_reference, "The value type `%s` doesn't declare a GValue get function".printf (get_full_name ()));
                                return null;
@@ -397,6 +415,12 @@ public class Vala.Struct : Typesymbol {
        
        public override string? get_set_value_function () {
                if (set_value_function == null) {
+                       foreach (DataType type in base_types) {
+                               var st = type.data_type as Struct;
+                               if (st != null) {
+                                       return st.get_set_value_function ();
+                               }
+                       }
                        if (simple_type) {
                                Report.error (source_reference, "The value type `%s` doesn't declare a GValue set function".printf (get_full_name ()));
                                return null;
index 2fa39e1d1088b33d2d366e1d97fdd79aff45e454..3cc4e83060e44bdb4902a8556fc7cbeed9aa5698 100644 (file)
@@ -259,7 +259,7 @@ public struct int32 {
 }
 
 [SimpleType]
-[CCode (cname = "guint32", cheader_filename = "glib.h", default_value = "0U", type_signature = "u")]
+[CCode (cname = "guint32", cheader_filename = "glib.h", type_id = "G_TYPE_UINT", marshaller_type_name = "UINT", get_value_function = "g_value_get_uint", set_value_function = "g_value_set_uint", default_value = "0U", type_signature = "u")]
 [IntegerType (rank = 7)]
 public struct uint32 {
        [CCode (cname = "0U")]