[vala/0.36] girwriter: Properly write attributes for non-GObject classes
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.36] girwriter: Properly write attributes for non-GObject classes
- Date: Tue, 13 Aug 2019 15:19:49 +0000 (UTC)
commit cb5bac833c9020a7e5f44a1945b3dbb0306e133c
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Apr 28 17:52:40 2019 +0200
girwriter: Properly write attributes for non-GObject classes
codegen/valagirwriter.vala | 40 ++++++++++++++++++++++++++++++++++++----
1 file changed, 36 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index 3696d7d14..f60d210a3 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -112,6 +112,8 @@ public class Vala.GIRWriter : CodeVisitor {
private TypeSymbol gobject_type;
private TypeSymbol ginitiallyunowned_type;
private TypeSymbol gtypeinterface_type;
+ private TypeSymbol gtypeinstance_type;
+ private TypeSymbol gtype_type;
private struct GIRNamespace {
public GIRNamespace (string ns, string version) {
@@ -155,6 +157,8 @@ public class Vala.GIRWriter : CodeVisitor {
gobject_type = (TypeSymbol) glib_ns.scope.lookup ("Object");
ginitiallyunowned_type = (TypeSymbol) glib_ns.scope.lookup ("InitiallyUnowned");
gtypeinterface_type = (TypeSymbol) glib_ns.scope.lookup ("TypeInterface");
+ gtypeinstance_type = (TypeSymbol) glib_ns.scope.lookup ("TypeInstance");
+ gtype_type = (TypeSymbol) glib_ns.scope.lookup ("Type");
write_package (package);
@@ -319,14 +323,22 @@ public class Vala.GIRWriter : CodeVisitor {
return;
}
- if (cl.is_subtype_of (gobject_type)) {
+ if (!cl.is_compact) {
string gtype_struct_name = get_gir_name (cl) + "Class";
write_indent ();
buffer.append_printf ("<class name=\"%s\"", get_gir_name (cl));
write_gtype_attributes (cl);
buffer.append_printf (" glib:type-struct=\"%s\"", gtype_struct_name);
- buffer.append_printf (" parent=\"%s\"", gi_type_name (cl.base_class));
+ if (cl.base_class == null) {
+ buffer.append_printf (" glib:fundamental=\"1\"");
+ buffer.append_printf (" glib:ref-func=\"%s\"",
CCodeBaseModule.get_ccode_ref_function (cl));
+ buffer.append_printf (" glib:unref-func=\"%s\"",
CCodeBaseModule.get_ccode_unref_function (cl));
+ buffer.append_printf (" glib:set-value-func=\"%s\"",
CCodeBaseModule.get_ccode_set_value_function (cl));
+ buffer.append_printf (" glib:get-value-func=\"%s\"",
CCodeBaseModule.get_ccode_get_value_function (cl));
+ } else {
+ buffer.append_printf (" parent=\"%s\"", gi_type_name (cl.base_class));
+ }
if (cl.is_abstract) {
buffer.append_printf (" abstract=\"1\"");
}
@@ -349,11 +361,26 @@ public class Vala.GIRWriter : CodeVisitor {
buffer.append_printf ("<field name=\"parent_instance\">\n");
indent++;
write_indent ();
- buffer.append_printf ("<type name=\"%s\" c:type=\"%s\"/>\n", gi_type_name
(cl.base_class), CCodeBaseModule.get_ccode_name (cl.base_class));
+ if (cl.base_class == null) {
+ buffer.append_printf ("<type name=\"%s\" c:type=\"%s\"/>\n", gi_type_name
(gtypeinstance_type), CCodeBaseModule.get_ccode_name (gtypeinstance_type));
+ } else {
+ buffer.append_printf ("<type name=\"%s\" c:type=\"%s\"/>\n", gi_type_name
(cl.base_class), CCodeBaseModule.get_ccode_name (cl.base_class));
+ }
indent--;
write_indent ();
buffer.append_printf("</field>\n");
+ if (cl.base_class == null) {
+ write_indent ();
+ buffer.append_printf ("<field name=\"ref_count\">\n");
+ indent++;
+ write_indent ();
+ buffer.append_printf ("<type name=\"gint\" c:type=\"volatile int\"/>\n");
+ indent--;
+ write_indent ();
+ buffer.append_printf("</field>\n");
+ }
+
write_indent ();
buffer.append_printf ("<field name=\"priv\">\n");
indent++;
@@ -382,7 +409,12 @@ public class Vala.GIRWriter : CodeVisitor {
buffer.append_printf ("<field name=\"parent_class\">\n");
indent++;
write_indent ();
- buffer.append_printf ("<type name=\"%sClass\" c:type=\"%sClass\"/>\n", gi_type_name
(cl.base_class), CCodeBaseModule.get_ccode_name (cl.base_class));
+ if (cl.base_class == null) {
+ //FIXME GObject.TypeClass vs GType
+ buffer.append_printf ("<type name=\"%sClass\" c:type=\"%sClass\"/>\n",
"GObject.Type", CCodeBaseModule.get_ccode_name (gtype_type));
+ } else {
+ buffer.append_printf ("<type name=\"%sClass\" c:type=\"%sClass\"/>\n",
gi_type_name (cl.base_class), CCodeBaseModule.get_ccode_name (cl.base_class));
+ }
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]