[vala/staging] girwriter: Don't write "property" attribute for non-gobject properties



commit 3fa987e9501e222e0fc44839f1d492f450b2e7af
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Apr 27 20:21:44 2019 +0200

    girwriter: Don't write "property" attribute for non-gobject properties

 codegen/valagirwriter.vala               | 44 +++++++++++++++++---------------
 tests/girwriter/GirTest-1.0.gir-expected | 22 ++++++++++++++++
 tests/girwriter/girtest.vala             |  4 +++
 tests/girwriter/girtest.vapi-expected    |  5 ++++
 4 files changed, 54 insertions(+), 21 deletions(-)
---
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index 7a0191b72..c125f5467 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -1147,32 +1147,34 @@ public class Vala.GIRWriter : CodeVisitor {
                        return;
                }
 
-               write_indent ();
-               buffer.append_printf ("<property name=\"%s\"", get_ccode_name (prop));
-               if (prop.get_accessor == null) {
-                       buffer.append_printf (" readable=\"0\"");
-               }
-               if (prop.set_accessor != null) {
-                       buffer.append_printf (" writable=\"1\"");
-                       if (prop.set_accessor.construction) {
-                               if (!prop.set_accessor.writable) {
-                                       buffer.append_printf (" construct-only=\"1\"");
-                               } else {
-                                       buffer.append_printf (" construct=\"1\"");
+               if (context.analyzer.is_gobject_property (prop)) {
+                       write_indent ();
+                       buffer.append_printf ("<property name=\"%s\"", get_ccode_name (prop));
+                       if (prop.get_accessor == null) {
+                               buffer.append_printf (" readable=\"0\"");
+                       }
+                       if (prop.set_accessor != null) {
+                               buffer.append_printf (" writable=\"1\"");
+                               if (prop.set_accessor.construction) {
+                                       if (!prop.set_accessor.writable) {
+                                               buffer.append_printf (" construct-only=\"1\"");
+                                       } else {
+                                               buffer.append_printf (" construct=\"1\"");
+                                       }
                                }
                        }
-               }
-               write_symbol_attributes (prop);
-               buffer.append_printf (">\n");
-               indent++;
+                       write_symbol_attributes (prop);
+                       buffer.append_printf (">\n");
+                       indent++;
 
-               write_doc (get_property_comment (prop));
+                       write_doc (get_property_comment (prop));
 
-               write_type (prop.property_type);
+                       write_type (prop.property_type);
 
-               indent--;
-               write_indent ();
-               buffer.append_printf ("</property>\n");
+                       indent--;
+                       write_indent ();
+                       buffer.append_printf ("</property>\n");
+               }
 
                if (prop.get_accessor != null) {
                        var m = prop.get_accessor.get_method ();
diff --git a/tests/girwriter/GirTest-1.0.gir-expected b/tests/girwriter/GirTest-1.0.gir-expected
index 1bad12723..7825333d1 100644
--- a/tests/girwriter/GirTest-1.0.gir-expected
+++ b/tests/girwriter/GirTest-1.0.gir-expected
@@ -40,6 +40,28 @@
                        </return-value>
                </constructor>
        </record>
+       <record name="TypeTest">
+               <constructor name="new" c:identifier="gir_test_typetest_new">
+                       <return-value transfer-ownership="full">
+                               <type name="GirTest.TypeTest" c:type="GirTestTypeTest*"/>
+                       </return-value>
+               </constructor>
+               <method name="get_some_property" c:identifier="gir_test_typetest_get_some_property">
+                       <return-value transfer-ownership="none">
+                               <type name="utf8" c:type="const gchar*"/>
+                       </return-value>
+               </method>
+               <method name="set_some_property" c:identifier="gir_test_typetest_set_some_property">
+                       <return-value transfer-ownership="none">
+                               <type name="none"/>
+                       </return-value>
+                       <parameters>
+                               <parameter name="value" transfer-ownership="none">
+                                       <type name="utf8" c:type="const gchar*"/>
+                               </parameter>
+                       </parameters>
+               </method>
+       </record>
        <class name="ObjectTest" c:type="GirTestObjectTest" glib:type-name="GirTestObjectTest" 
glib:get-type="gir_test_object_test_get_type" glib:type-struct="ObjectTestClass" parent="GObject.Object">
                <field name="parent_instance">
                        <type name="GObject.Object" c:type="GObject"/>
diff --git a/tests/girwriter/girtest.vala b/tests/girwriter/girtest.vala
index eb762443f..9d23113b0 100644
--- a/tests/girwriter/girtest.vala
+++ b/tests/girwriter/girtest.vala
@@ -81,6 +81,10 @@ namespace GirTest {
        [GIR (visible = false)]
        public delegate void SkippedDelegate ();
 
+       public class TypeTest {
+               public string some_property { get; set; }
+       }
+
        public class ObjectTest : Object {
                private static ObjectTest global_instance = new ObjectTest ();
 
diff --git a/tests/girwriter/girtest.vapi-expected b/tests/girwriter/girtest.vapi-expected
index 3dc664ab6..809e12cca 100644
--- a/tests/girwriter/girtest.vapi-expected
+++ b/tests/girwriter/girtest.vapi-expected
@@ -81,6 +81,11 @@ namespace GirTest {
                public SkippedStruct ();
        }
        [CCode (cheader_filename = "girtest.h")]
+       public class TypeTest {
+               public TypeTest ();
+               public string some_property { get; set; }
+       }
+       [CCode (cheader_filename = "girtest.h")]
        public interface InterfaceTest : GLib.Object {
                public virtual async void coroutine_async ();
                public virtual void int8_in (int8 param);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]