]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Write GIR version 1.2 instead of version 1.1
authorEvan Nemerson <evan@coeus-group.com>
Mon, 6 Sep 2010 22:40:03 +0000 (15:40 -0700)
committerJürg Billeter <j@bitron.ch>
Wed, 15 Sep 2010 19:31:24 +0000 (21:31 +0200)
Fixes bug 628927.

codegen/valagirwriter.vala
vala/valaclass.vala
vala/valastruct.vala
vala/valasymbol.vala
vapi/glib-2.0.vapi

index e1899deec58061583eb6874cbe29095143410ab1..4890aa650bb12072df7e35c0432e8ebf2a1f0705 100644 (file)
@@ -94,7 +94,7 @@ public class Vala.GIRWriter : CodeVisitor {
 
                stream.printf ("<?xml version=\"1.0\"?>\n");
 
-               stream.printf ("<repository version=\"1.1\"");
+               stream.printf ("<repository version=\"1.2\"");
                stream.printf (" xmlns=\"http://www.gtk.org/introspection/core/1.0\"");
                stream.printf (" xmlns:c=\"http://www.gtk.org/introspection/c/1.0\"");
                stream.printf (" xmlns:glib=\"http://www.gtk.org/introspection/glib/1.0\"");
@@ -231,7 +231,7 @@ public class Vala.GIRWriter : CodeVisitor {
                        buffer.append_printf ("<field name=\"priv\">\n");
                        indent++;
                        write_indent ();
-                       buffer.append_printf ("<type name=\"any\" c:type=\"%sPrivate*\"/>\n", cl.get_cname ());
+                       buffer.append_printf ("<type name=\"%sPrivate\" c:type=\"%sPrivate*\"/>\n", cl.name, cl.get_cname ());
                        indent--;
                        write_indent ();
                        buffer.append_printf("</field>\n");
@@ -286,6 +286,9 @@ public class Vala.GIRWriter : CodeVisitor {
                        indent--;
                        write_indent ();
                        buffer.append_printf ("</record>\n");
+
+                       write_indent ();
+                       buffer.append_printf ("<record name=\"%sPrivate\" c:type=\"%sPrivate\" disguised=\"1\"/>\n", cl.name, cl.get_cname ());
                } else {
                        write_indent ();
                        buffer.append_printf ("<record name=\"%s\"", cl.name);
@@ -345,30 +348,13 @@ public class Vala.GIRWriter : CodeVisitor {
 
                // write prerequisites
                if (iface.get_prerequisites ().size > 0) {
-                       write_indent ();
-                       buffer.append_printf ("<requires>\n");
-                       indent++;
-
                        foreach (DataType base_type in iface.get_prerequisites ()) {
-                               var object_type = (ObjectType) base_type;
-                               if (object_type.type_symbol is Class) {
-                                       write_indent ();
-                                       buffer.append_printf ("<object name=\"%s\"/>\n", gi_type_name (object_type.type_symbol));
-                               } else if (object_type.type_symbol is Interface) {
-                                       write_indent ();
-                                       buffer.append_printf ("<interface name=\"%s\"/>\n", gi_type_name (object_type.type_symbol));
-                               } else {
-                                       assert_not_reached ();
-                               }
+                               write_indent ();
+                               buffer.append_printf ("<prerequisite name=\"%s\"/>\n", gi_type_name (((ObjectType) base_type).type_symbol));
                        }
-
-                       indent--;
-                       write_indent ();
-                       buffer.append_printf ("</requires>\n");
                }
 
                write_annotations (iface);
-
                iface.accept_children (this);
 
                indent--;
@@ -569,7 +555,7 @@ public class Vala.GIRWriter : CodeVisitor {
                                buffer.append_printf ("<parameter name=\"user_data\" transfer-ownership=\"none\" closure=\"%d\">\n", index);
                                indent++;
                                write_indent ();
-                               buffer.append_printf ("<type name=\"any\" c:type=\"void*\"/>\n");
+                               buffer.append_printf ("<type name=\"gpointer\" c:type=\"void*\"/>\n");
                                indent--;
                                write_indent ();
                                buffer.append_printf ("</parameter>\n");
@@ -858,7 +844,7 @@ public class Vala.GIRWriter : CodeVisitor {
                        buffer.append_printf ("<type name=\"none\"/>\n");
                } else if (type is PointerType) {
                        write_indent ();
-                       buffer.append_printf ("<type name=\"any\" c:type=\"%s\"/>\n", type.get_cname ());
+                       buffer.append_printf ("<type name=\"gpointer\" c:type=\"%s\"/>\n", type.get_cname ());
                } else if (type.data_type != null) {
                        write_indent ();
                        buffer.append_printf ("<type name=\"%s\" c:type=\"%s\"", gi_type_name (type.data_type), type.get_cname ());
@@ -885,7 +871,7 @@ public class Vala.GIRWriter : CodeVisitor {
                } else if (type is GenericType) {
                        // generic type parameters not supported in GIR
                        write_indent ();
-                       buffer.append ("<type name=\"any\" c:type=\"gpointer\"/>\n");
+                       buffer.append ("<type name=\"gpointer\" c:type=\"gpointer\"/>\n");
                } else {
                        write_indent ();
                        buffer.append_printf ("<type name=\"%s\"/>\n", type.to_string ());
@@ -913,40 +899,20 @@ public class Vala.GIRWriter : CodeVisitor {
                Symbol parent = type_symbol.parent_symbol;
                if (parent is Namespace) {
                        Namespace ns = parent as Namespace;
-                       if (ns.name != null) {
+                       if (ns.gir_name != null) {
                                if (type_symbol.source_reference.file.gir_namespace != null) {
                                        GIRNamespace external = GIRNamespace (type_symbol.source_reference.file.gir_namespace, type_symbol.source_reference.file.gir_version);
                                        if (!externals.contains (external)) {
                                                externals.add (external);
                                        }
-                                       return "%s.%s".printf (type_symbol.source_reference.file.gir_namespace, type_symbol.name);
+                                       return "%s.%s".printf (type_symbol.source_reference.file.gir_namespace, type_symbol.gir_name);
                                } else {
                                        unannotated_namespaces.add(ns);
                                }
                        }
                }
 
-               return vala_to_gi_type_name (type_symbol.get_full_name());
-       }
-
-       private string vala_to_gi_type_name (string name) {
-               if (name == "bool") {
-                       return "boolean";
-               } else if (name == "string") {
-                       return "utf8";
-               } else if (!name.contains (".")) {
-                       return name;
-               } else {
-                       string[] split_name = name.split (".");
-
-                       StringBuilder type_name = new StringBuilder ();
-                       type_name.append (split_name[0]);
-                       type_name.append_unichar ('.');
-                       for (int i = 1; i < split_name.length; i++) {
-                               type_name.append (split_name[i]);
-                       }
-                       return type_name.str;
-               }
+               return type_symbol.get_full_gir_name();
        }
 
        private string? literal_expression_to_value_string (Expression literal) {
index 0380acb76b6cab60a2290d3adee8f06865d91c75..06cc7eabaf4a115dd59acc177db12ebfc82922c9 100644 (file)
@@ -627,6 +627,12 @@ public class Vala.Class : ObjectTypeSymbol {
        public override bool is_reference_type () {
                return true;
        }
+
+       private void process_gir_attribute (Attribute a) {
+               if (a.has_argument ("name")) {
+                       gir_name = a.get_string ("name");
+               }
+       }
        
        private void process_ccode_attribute (Attribute a) {
                if (a.has_argument ("ref_function")) {
@@ -703,6 +709,8 @@ public class Vala.Class : ObjectTypeSymbol {
                                is_immutable = true;
                        } else if (a.name == "Deprecated") {
                                process_deprecated_attribute (a);
+                       } else if (a.name == "GIR") {
+                               process_gir_attribute (a);
                        }
                }
        }
index 2f541197220e0709c82df84a67aef4a6fb975d23..93aac1e536774af74909cb578f138199cd7f94bf 100644 (file)
@@ -407,6 +407,12 @@ public class Vala.Struct : TypeSymbol {
                this.rank = rank;
        }
 
+       private void process_gir_attribute (Attribute a) {
+               if (a.has_argument ("name")) {
+                       gir_name = a.get_string ("name");
+               }
+       }
+
        private void process_ccode_attribute (Attribute a) {
                if (a.has_argument ("const_cname")) {
                        set_const_cname (a.get_string ("const_cname"));
@@ -499,6 +505,8 @@ public class Vala.Struct : TypeSymbol {
                                is_immutable = true;
                        } else if (a.name == "Deprecated") {
                                process_deprecated_attribute (a);
+                       } else if (a.name == "GIR") {
+                               process_gir_attribute (a);
                        }
                }
        }
index a935bcb76c6cdd6a1a00c2c341eb850ad02589c5..fd74c6ce7d856eee16419a7f32afb1f7ce353560 100644 (file)
@@ -51,7 +51,19 @@ public abstract class Vala.Symbol : CodeNode {
                        _scope.parent_scope = value;
                }
        }
-       
+
+       /**
+        * The GIR name.
+        */
+       public string? gir_name {
+               get {
+                       return _gir_name == null ? name : _gir_name;
+               }
+               set {
+                       _gir_name = value;
+               }
+       }
+
        /**
         * The symbol name.
         */
@@ -162,6 +174,7 @@ public abstract class Vala.Symbol : CodeNode {
 
        private weak Scope _owner;
        private Scope _scope;
+       private string? _gir_name = null;
 
        public Symbol (string? name, SourceReference? source_reference, Comment? comment = null) {
                this.name = name;
@@ -170,6 +183,31 @@ public abstract class Vala.Symbol : CodeNode {
                _scope = new Scope (this);
        }
        
+       /**
+        * Returns the fully expanded GIR name of this symbol
+        *
+        * @return full GIR name
+        */
+       public string get_full_gir_name () {
+               if (parent_symbol == null) {
+                       return gir_name;
+               }
+               
+               if (name == null) {
+                       return parent_symbol.get_full_gir_name ();
+               }
+
+               if (parent_symbol.get_full_gir_name () == null) {
+                       return gir_name;
+               }
+
+               if (name.has_prefix (".")) {
+                       return "%s%s".printf (parent_symbol.get_full_gir_name (), gir_name);
+               } else {
+                       return "%s.%s".printf (parent_symbol.get_full_gir_name (), gir_name);
+               }
+       }
+       
        /**
         * Returns the fully expanded name of this symbol for use in
         * human-readable messages.
index 11d77f2ae81678cbaaf5191528a65ad26000bbbe..4cf2bfc0dce44fca3d396f6f5470d448c860087f 100644 (file)
@@ -29,6 +29,7 @@
  */
 
 [SimpleType]
+[GIR (name = "gboolean")]
 [CCode (cname = "gboolean", cheader_filename = "glib.h", type_id = "G_TYPE_BOOLEAN", marshaller_type_name = "BOOLEAN", get_value_function = "g_value_get_boolean", set_value_function = "g_value_set_boolean", default_value = "FALSE", type_signature = "b")]
 [BooleanType]
 public struct bool {
@@ -87,6 +88,7 @@ public struct uchar {
 }
 
 [SimpleType]
+[GIR (name = "gint")]
 [CCode (cname = "gint", cheader_filename = "glib.h", type_id = "G_TYPE_INT", marshaller_type_name = "INT", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0", type_signature = "i")]
 [IntegerType (rank = 6)]
 public struct int {
@@ -123,6 +125,7 @@ public struct int {
 }
 
 [SimpleType]
+[GIR (name = "guint")]
 [CCode (cname = "guint", 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 uint {
@@ -156,6 +159,7 @@ public struct uint {
 }
 
 [SimpleType]
+[GIR (name = "gshort")]
 [CCode (cname = "gshort", cheader_filename = "glib.h", has_type_id = false, default_value = "0", type_signature = "n")]
 [IntegerType (rank = 4, min = -32768, max = 32767)]
 public struct short {
@@ -176,6 +180,7 @@ public struct short {
 }
 
 [SimpleType]
+[GIR (name = "gushort")]
 [CCode (cname = "gushort", cheader_filename = "glib.h", has_type_id = false, default_value = "0U", type_signature = "q")]
 [IntegerType (rank = 5, min = 0, max = 65535)]
 public struct ushort {
@@ -196,6 +201,7 @@ public struct ushort {
 }
 
 [SimpleType]
+[GIR (name = "glong")]
 [CCode (cname = "glong", cheader_filename = "glib.h", type_id = "G_TYPE_LONG", marshaller_type_name = "LONG", get_value_function = "g_value_get_long", set_value_function = "g_value_set_long", default_value = "0L")]
 [IntegerType (rank = 8)]
 public struct long {
@@ -228,6 +234,7 @@ public struct long {
 }
 
 [SimpleType]
+[GIR (name = "gulong")]
 [CCode (cname = "gulong", cheader_filename = "glib.h", type_id = "G_TYPE_ULONG", marshaller_type_name = "ULONG", get_value_function = "g_value_get_ulong", set_value_function = "g_value_set_ulong", default_value = "0UL")]
 [IntegerType (rank = 9)]
 public struct ulong {
@@ -311,6 +318,7 @@ public struct ssize_t {
 }
 
 [SimpleType]
+[GIR (name = "gint8")]
 [CCode (cname = "gint8", cheader_filename = "glib.h", type_id = "G_TYPE_CHAR", marshaller_type_name = "CHAR", get_value_function = "g_value_get_char", set_value_function = "g_value_set_char", default_value = "0", type_signature = "y")]
 [IntegerType (rank = 1, min = -128, max = 127)]
 public struct int8 {
@@ -331,6 +339,7 @@ public struct int8 {
 }
 
 [SimpleType]
+[GIR (name = "guint8")]
 [CCode (cname = "guint8", cheader_filename = "glib.h", type_id = "G_TYPE_UCHAR", marshaller_type_name = "UCHAR", get_value_function = "g_value_get_uchar", set_value_function = "g_value_set_uchar", default_value = "0U", type_signature = "y")]
 [IntegerType (rank = 3, min = 0, max = 255)]
 public struct uint8 {
@@ -351,6 +360,7 @@ public struct uint8 {
 }
 
 [SimpleType]
+[GIR (name = "gint16")]
 [CCode (cname = "gint16", cheader_filename = "glib.h", default_value = "0", type_signature = "n", has_type_id = false)]
 [IntegerType (rank = 4, min = -32768, max = 32767)]
 public struct int16 {
@@ -386,6 +396,7 @@ public struct int16 {
 }
 
 [SimpleType]
+[GIR (name = "guint16")]
 [CCode (cname = "guint16", cheader_filename = "glib.h", default_value = "0U", type_signature = "q", has_type_id = false)]
 [IntegerType (rank = 5, min = 0, max = 65535)]
 public struct uint16 {
@@ -428,6 +439,7 @@ public struct uint16 {
 }
 
 [SimpleType]
+[GIR (name = "gint32")]
 [CCode (cname = "gint32", cheader_filename = "glib.h", type_id = "G_TYPE_INT", marshaller_type_name = "INT", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0", type_signature = "i")]
 [IntegerType (rank = 6)]
 public struct int32 {
@@ -463,6 +475,7 @@ public struct int32 {
 }
 
 [SimpleType]
+[GIR (name = "guint32")]
 [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 {
@@ -505,6 +518,7 @@ public struct uint32 {
 }
 
 [SimpleType]
+[GIR (name = "gint64")]
 [CCode (cname = "gint64", cheader_filename = "glib.h", type_id = "G_TYPE_INT64", marshaller_type_name = "INT64", get_value_function = "g_value_get_int64", set_value_function = "g_value_set_int64", default_value = "0LL", type_signature = "x")]
 [IntegerType (rank = 10)]
 public struct int64 {
@@ -545,6 +559,7 @@ public struct int64 {
 }
 
 [SimpleType]
+[GIR (name = "guint64")]
 [CCode (cname = "guint64", cheader_filename = "glib.h", type_id = "G_TYPE_UINT64", marshaller_type_name = "UINT64", get_value_function = "g_value_get_uint64", set_value_function = "g_value_set_uint64", default_value = "0ULL", type_signature = "t")]
 [IntegerType (rank = 11)]
 public struct uint64 {
@@ -580,6 +595,7 @@ public struct uint64 {
 }
 
 [SimpleType]
+[GIR (name = "gfloat")]
 [CCode (cname = "float", cheader_filename = "glib.h,float.h,math.h", type_id = "G_TYPE_FLOAT", marshaller_type_name = "FLOAT", get_value_function = "g_value_get_float", set_value_function = "g_value_set_float", default_value = "0.0F")]
 [FloatingType (rank = 1)]
 public struct float {
@@ -631,6 +647,7 @@ public struct float {
 }
 
 [SimpleType]
+[GIR (name = "gdouble")]
 [CCode (cname = "double", cheader_filename = "glib.h,float.h,math.h", type_id = "G_TYPE_DOUBLE", marshaller_type_name = "DOUBLE", get_value_function = "g_value_get_double", set_value_function = "g_value_set_double", default_value = "0.0", type_signature = "d")]
 [FloatingType (rank = 2)]
 public struct double {
@@ -689,6 +706,7 @@ public struct double {
        }
 }
 
+[GIR (name = "glong")]
 [CCode (cheader_filename = "time.h", has_type_id = false)]
 [IntegerType (rank = 8)]
 public struct time_t {
@@ -708,6 +726,7 @@ public struct va_list {
 }
 
 [SimpleType]
+[GIR (name = "gunichar")]
 [CCode (cname = "gunichar", cprefix = "g_unichar_", 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 unichar {
@@ -929,6 +948,7 @@ public enum NormalizeMode {
 
 [Compact]
 [Immutable]
+[GIR (name = "utf8")]
 [CCode (cname = "char", const_cname = "const char", copy_function = "g_strdup", free_function = "g_free", cheader_filename = "stdlib.h,string.h,glib.h", type_id = "G_TYPE_STRING", marshaller_type_name = "STRING", param_spec_function = "g_param_spec_string", get_value_function = "g_value_get_string", set_value_function = "g_value_set_string", take_value_function = "g_value_take_string", type_signature = "s")]
 public class string {
        [CCode (cname = "strstr")]
@@ -3599,6 +3619,7 @@ namespace GLib {
        /* Strings */
 
        [Compact]
+       [GIR (name = "String")]
        [CCode (cname = "GString", cprefix = "g_string_", free_function = "g_string_free", type_id = "G_TYPE_GSTRING")]
        public class StringBuilder {
                public StringBuilder (string init = "");