[vala/staging: 3/4] girwriter: Write glib-type attributes for Enums/Structs with type_id
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 3/4] girwriter: Write glib-type attributes for Enums/Structs with type_id
- Date: Sun, 18 Nov 2018 19:57:39 +0000 (UTC)
commit 21a2a70abfe3d338e1e64f9b06b0d4f145380493
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Nov 18 20:37:38 2018 +0100
girwriter: Write glib-type attributes for Enums/Structs with type_id
codegen/valagirwriter.vala | 11 ++++++++++-
tests/girwriter/GirTest-1.0.gir-expected | 27 ++++++++++++++++++++++++++-
tests/girwriter/girtest.vala | 18 ++++++++++++++++++
tests/girwriter/girtest.vapi-expected | 12 ++++++++++++
4 files changed, 66 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index a35036a06..c01912167 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -474,6 +474,11 @@ public class Vala.GIRWriter : CodeVisitor {
write_indent ();
buffer.append_printf ("<record name=\"%s\"", get_gir_name (st));
+ if (get_ccode_has_type_id (st)) {
+ write_gtype_attributes (st);
+ } else {
+ write_ctype_attributes (st);
+ }
write_symbol_attributes (st);
buffer.append_printf (">\n");
indent++;
@@ -664,7 +669,11 @@ public class Vala.GIRWriter : CodeVisitor {
write_indent ();
buffer.append_printf ("<%s name=\"%s\"", element_name, get_gir_name (en));
- write_gtype_attributes (en);
+ if (get_ccode_has_type_id (en)) {
+ write_gtype_attributes (en);
+ } else {
+ write_ctype_attributes (en);
+ }
write_symbol_attributes (en);
buffer.append_printf (">\n");
indent++;
diff --git a/tests/girwriter/GirTest-1.0.gir-expected b/tests/girwriter/GirTest-1.0.gir-expected
index 52be88f50..72705c6fd 100644
--- a/tests/girwriter/GirTest-1.0.gir-expected
+++ b/tests/girwriter/GirTest-1.0.gir-expected
@@ -16,6 +16,11 @@
<member name="value2" c:identifier="GIR_TEST_FLAGS_TEST_VALUE2" value="2"/>
<member name="value3" c:identifier="GIR_TEST_FLAGS_TEST_VALUE3" value="4"/>
</bitfield>
+ <enumeration name="PlainEnumTest" c:type="GirTestPlainEnumTest">
+ <member name="value1" c:identifier="GIR_TEST_PLAIN_ENUM_TEST_VALUE1" value="0"/>
+ <member name="value2" c:identifier="GIR_TEST_PLAIN_ENUM_TEST_VALUE2" value="1"/>
+ <member name="value3" c:identifier="GIR_TEST_PLAIN_ENUM_TEST_VALUE3" value="4711"/>
+ </enumeration>
<enumeration name="SkippedEnum" c:type="GirTestSkippedEnum" glib:type-name="GirTestSkippedEnum"
glib:get-type="gir_test_skipped_enum_get_type" introspectable="0">
<member name="value1" c:identifier="GIR_TEST_SKIPPED_ENUM_VALUE1" value="0"/>
</enumeration>
@@ -928,7 +933,7 @@
<type name="GObject.TypeInterface" c:type="GTypeInterface"/>
</field>
</record>
- <record name="BoxedStruct">
+ <record name="BoxedStruct" c:type="GirTestBoxedStruct" glib:type-name="GirTestBoxedStruct"
glib:get-type="gir_test_boxed_struct_get_type">
<field name="field_name">
<type name="gint" c:type="gint"/>
</field>
@@ -948,6 +953,26 @@
</return-value>
</method>
</record>
+ <record name="Struct" c:type="GirTestStruct">
+ <field name="field_name">
+ <type name="gint" c:type="gint"/>
+ </field>
+ <function name="init" c:identifier="gir_test_struct_init">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="result" direction="out" transfer-ownership="full"
caller-allocates="1">
+ <type name="GirTest.Struct" c:type="GirTestStruct*"/>
+ </parameter>
+ </parameters>
+ </function>
+ <method name="inv" c:identifier="gir_test_struct_inv">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ </method>
+ </record>
<callback name="DelegateTest" c:type="GirTestDelegateTest">
<return-value transfer-ownership="full">
<type name="gboolean" c:type="gboolean"/>
diff --git a/tests/girwriter/girtest.vala b/tests/girwriter/girtest.vala
index 806b3312a..4f04d9296 100644
--- a/tests/girwriter/girtest.vala
+++ b/tests/girwriter/girtest.vala
@@ -10,6 +10,17 @@ namespace GirTest {
}
}
+ [CCode (has_type_id = false)]
+ public struct Struct {
+ public int field_name;
+
+ public Struct () {
+ }
+
+ public void inv () {
+ }
+ }
+
[GIR (visible = false)]
public class SkippedStruct {
}
@@ -30,6 +41,13 @@ namespace GirTest {
VALUE3
}
+ [CCode (has_type_id = false)]
+ public enum PlainEnumTest {
+ VALUE1,
+ VALUE2,
+ VALUE3 = 4711
+ }
+
[GIR (visible = false)]
public enum SkippedEnum {
VALUE1
diff --git a/tests/girwriter/girtest.vapi-expected b/tests/girwriter/girtest.vapi-expected
index 2b5a9a466..d89338f8e 100644
--- a/tests/girwriter/girtest.vapi-expected
+++ b/tests/girwriter/girtest.vapi-expected
@@ -93,6 +93,12 @@ namespace GirTest {
public BoxedStruct ();
public void inv ();
}
+ [CCode (cheader_filename = "girtest.h", has_type_id = false)]
+ public struct Struct {
+ public int field_name;
+ public Struct ();
+ public void inv ();
+ }
[CCode (cheader_filename = "girtest.h")]
public enum EnumTest {
VALUE1,
@@ -106,6 +112,12 @@ namespace GirTest {
VALUE2,
VALUE3
}
+ [CCode (cheader_filename = "girtest.h", has_type_id = false)]
+ public enum PlainEnumTest {
+ VALUE1,
+ VALUE2,
+ VALUE3
+ }
[CCode (cheader_filename = "girtest.h")]
[GIR (visible = false)]
public enum SkippedEnum {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]