[vala] GIR writer: Generate type structs for classes and interfaces
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [vala] GIR writer: Generate type structs for classes and interfaces
- Date: Thu, 30 Apr 2009 15:11:05 -0400 (EDT)
commit 7beb7e3df2e3f3fc42c63348768aff81b1a2a905
Author: Didier 'Ptitjes <ptitjes free fr>
Date: Fri Mar 20 16:50:43 2009 +0100
GIR writer: Generate type structs for classes and interfaces
Signed-off-by: Didier 'Ptitjes <ptitjes free fr>
---
gobject/valagirwriter.vala | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/gobject/valagirwriter.vala b/gobject/valagirwriter.vala
index c873ef3..2c9b6e3 100644
--- a/gobject/valagirwriter.vala
+++ b/gobject/valagirwriter.vala
@@ -131,9 +131,12 @@ public class Vala.GIRWriter : CodeVisitor {
}
if (cl.is_subtype_of (gobject_type)) {
+ string gtype_struct_name = cl.name + "Class";
+
write_indent ();
stream.printf ("<class name=\"%s\"", cl.name);
write_gtype_attributes (cl);
+ stream.printf (" glib:type-struct=\"%s\"", gtype_struct_name);
stream.printf (" parent=\"%s\"", cl.base_class.get_full_name ());
stream.printf (">\n");
indent++;
@@ -164,6 +167,17 @@ public class Vala.GIRWriter : CodeVisitor {
indent--;
write_indent ();
stream.printf ("</class>\n");
+
+ write_indent ();
+ stream.printf ("<record name=\"%s\"", gtype_struct_name);
+ write_ctype_attributes (cl, "Class");
+ stream.printf (" glib:is-gtype-struct-for=\"%s\"", cl.name);
+ stream.printf (">\n");
+ indent++;
+
+ indent--;
+ write_indent ();
+ stream.printf ("</record>\n");
} else {
write_indent ();
stream.printf ("<record name=\"%s\"", cl.name);
@@ -208,9 +222,12 @@ public class Vala.GIRWriter : CodeVisitor {
return;
}
+ string gtype_struct_name = iface.name + "Iface";
+
write_indent ();
stream.printf ("<interface name=\"%s\"", iface.name);
write_gtype_attributes (iface);
+ stream.printf (" glib:type-struct=\"%s\"", gtype_struct_name);
stream.printf (">\n");
indent++;
@@ -243,6 +260,17 @@ public class Vala.GIRWriter : CodeVisitor {
indent--;
write_indent ();
stream.printf ("</interface>\n");
+
+ write_indent ();
+ stream.printf ("<record name=\"%s\"", gtype_struct_name);
+ write_ctype_attributes (iface, "Iface");
+ stream.printf (" glib:is-gtype-struct-for=\"%s\"", iface.name);
+ stream.printf (">\n");
+ indent++;
+
+ indent--;
+ write_indent ();
+ stream.printf ("</record>\n");
}
public override void visit_enum (Enum en) {
@@ -525,8 +553,8 @@ public class Vala.GIRWriter : CodeVisitor {
stream.printf ("</return-value>\n");
}
- private void write_ctype_attributes (TypeSymbol symbol) {
- stream.printf (" c:type=\"%s\"", symbol.get_cname ());
+ private void write_ctype_attributes (TypeSymbol symbol, string suffix = "") {
+ stream.printf (" c:type=\"%s%s\"", symbol.get_cname (), suffix);
}
private void write_gtype_attributes (TypeSymbol symbol) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]