[vala/0.10-gir] Write GIR version 1.2 instead of version 1.1
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.10-gir] Write GIR version 1.2 instead of version 1.1
- Date: Wed, 15 Sep 2010 18:28:28 +0000 (UTC)
commit 273605b942dde594a3cd1a103c28fe5350fb2d5f
Author: Evan Nemerson <evan coeus-group com>
Date: Mon Sep 6 15:40:03 2010 -0700
Write GIR version 1.2 instead of version 1.1
Fixes bug 628927.
codegen/valagirwriter.vala | 60 +++++++++----------------------------------
vala/valaclass.vala | 8 ++++++
vala/valastruct.vala | 8 ++++++
vala/valasymbol.vala | 40 ++++++++++++++++++++++++++++-
vapi/glib-2.0.vapi | 21 +++++++++++++++
5 files changed, 89 insertions(+), 48 deletions(-)
---
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index e1899de..4890aa6 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -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) {
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index 0380acb..06cc7ea 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -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);
}
}
}
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index 2f54119..93aac1e 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -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);
}
}
}
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index a935bcb..fd74c6c 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -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;
@@ -171,6 +184,31 @@ public abstract class Vala.Symbol : CodeNode {
}
/**
+ * 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.
*
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index 11d77f2..4cf2bfc 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -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 = "");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]