]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girwriter: Don't write "property" attribute for non-gobject properties
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 27 Apr 2019 18:21:44 +0000 (20:21 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 28 Apr 2019 07:27:06 +0000 (09:27 +0200)
codegen/valagirwriter.vala
tests/girwriter/GirTest-1.0.gir-expected
tests/girwriter/girtest.vala
tests/girwriter/girtest.vapi-expected

index 7a0191b72365e69a754ff9668d85ce70993e698c..c125f5467058cb347acbd27896ddff0869258809 100644 (file)
@@ -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 ();
index 1bad12723454688bfd6c0938c81024e5e167594d..7825333d128d280c7a908072c27fc2a8f1fbb3b0 100644 (file)
                        </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"/>
index eb762443fd978d7d23ca2e87db5525aa92a07609..9d23113b0282712ff7b722344577124d15701a92 100644 (file)
@@ -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 ();
 
index 3dc664ab64242064eadd25c8d19f64274d0e705b..809e12cca312414f4363c42990de5312a6f20acc 100644 (file)
@@ -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);