[vala/staging] girwriter: Don't emit invoker for methods attributed with NoWrapper



commit 4f692cb71577ebef2dc2240300cc2e01ca962b25
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Jan 30 11:44:17 2021 +0100

    girwriter: Don't emit invoker for methods attributed with NoWrapper

 codegen/valagirwriter.vala               |  8 +++-
 tests/girwriter/GirTest-1.0.gir-expected | 66 ++++++++++++++++++++++++++++++++
 tests/girwriter/girtest.vala             | 10 +++++
 tests/girwriter/girtest.vapi-expected    |  6 +++
 tests/girwriter/girtest.vapigen-expected |  6 +++
 5 files changed, 94 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index 0ad27ed24..afcab6ea9 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -1276,7 +1276,9 @@ public class Vala.GIRWriter : CodeVisitor {
                        tag_name = "function";
                }
 
-               write_signature (m, tag_name, true);
+               if (m.get_attribute ("NoWrapper") == null) {
+                       write_signature (m, tag_name, true);
+               }
 
                if (m.is_abstract || m.is_virtual) {
                        write_signature (m, "virtual-method", true, false);
@@ -1343,7 +1345,9 @@ public class Vala.GIRWriter : CodeVisitor {
                write_indent ();
                buffer.append_printf ("<%s name=\"%s\"", tag_name, name);
                if (tag_name == "virtual-method") {
-                       buffer.append_printf (" invoker=\"%s\"", name);
+                       if (m.get_attribute ("NoWrapper") == null) {
+                               buffer.append_printf (" invoker=\"%s\"", name);
+                       }
                } else if (tag_name == "callback") {
                        /* this is only used for vfuncs */
                        buffer.append_printf (" c:type=\"%s\"", name);
diff --git a/tests/girwriter/GirTest-1.0.gir-expected b/tests/girwriter/GirTest-1.0.gir-expected
index 75a6c51d0..129cdd0e3 100644
--- a/tests/girwriter/GirTest-1.0.gir-expected
+++ b/tests/girwriter/GirTest-1.0.gir-expected
@@ -838,6 +838,16 @@
                                </instance-parameter>
                        </parameters>
                </method>
+               <virtual-method name="no_wrapper_method">
+                       <return-value transfer-ownership="full">
+                               <type name="none" c:type="void"/>
+                       </return-value>
+                       <parameters>
+                               <instance-parameter name="self" transfer-ownership="none">
+                                       <type name="GirTest.ObjectTest" c:type="GirTestObjectTest*"/>
+                               </instance-parameter>
+                       </parameters>
+               </virtual-method>
                <property name="some-property" writable="1" construct="1">
                        <type name="utf8" c:type="gchar*"/>
                </property>
@@ -1058,6 +1068,18 @@
                                </parameters>
                        </callback>
                </field>
+               <field name="no_wrapper_method">
+                       <callback name="no_wrapper_method" c:type="no_wrapper_method">
+                               <return-value transfer-ownership="full">
+                                       <type name="none" c:type="void"/>
+                               </return-value>
+                               <parameters>
+                                       <instance-parameter name="self" transfer-ownership="none">
+                                               <type name="GirTest.ObjectTest" c:type="GirTestObjectTest*"/>
+                                       </instance-parameter>
+                               </parameters>
+                       </callback>
+               </field>
                <field name="signal_with_default_handlder">
                        <callback name="object_test_signal_with_default_handlder" 
c:type="object_test_signal_with_default_handlder">
                                <return-value transfer-ownership="full">
@@ -1302,6 +1324,16 @@
                                </parameter>
                        </parameters>
                </virtual-method>
+               <virtual-method name="no_wrapper_method">
+                       <return-value transfer-ownership="full">
+                               <type name="none" c:type="void"/>
+                       </return-value>
+                       <parameters>
+                               <instance-parameter name="self" transfer-ownership="none">
+                                       <type name="GirTest.AbstractObjectTest" 
c:type="GirTestAbstractObjectTest*"/>
+                               </instance-parameter>
+                       </parameters>
+               </virtual-method>
        </class>
        <record name="AbstractObjectTestClass" c:type="GirTestAbstractObjectTestClass" 
glib:is-gtype-struct-for="AbstractObjectTest">
                <field name="parent_class" readable="0" private="1">
@@ -1433,6 +1465,18 @@
                                </parameters>
                        </callback>
                </field>
+               <field name="no_wrapper_method">
+                       <callback name="no_wrapper_method" c:type="no_wrapper_method">
+                               <return-value transfer-ownership="full">
+                                       <type name="none" c:type="void"/>
+                               </return-value>
+                               <parameters>
+                                       <instance-parameter name="self" transfer-ownership="none">
+                                               <type name="GirTest.AbstractObjectTest" 
c:type="GirTestAbstractObjectTest*"/>
+                                       </instance-parameter>
+                               </parameters>
+                       </callback>
+               </field>
        </record>
        <record name="AbstractObjectTestPrivate" c:type="GirTestAbstractObjectTestPrivate" disguised="1"/>
        <class name="ImplementionTest" c:type="GirTestImplementionTest" c:symbol-prefix="implemention_test" 
glib:type-name="GirTestImplementionTest" glib:get-type="gir_test_implemention_test_get_type" 
glib:type-struct="ImplementionTestClass" parent="GObject.Object">
@@ -1911,6 +1955,16 @@
                                </instance-parameter>
                        </parameters>
                </virtual-method>
+               <virtual-method name="no_wrapper_method">
+                       <return-value transfer-ownership="full">
+                               <type name="none" c:type="void"/>
+                       </return-value>
+                       <parameters>
+                               <instance-parameter name="self" transfer-ownership="none">
+                                       <type name="GirTest.InterfaceTest" c:type="GirTestInterfaceTest*"/>
+                               </instance-parameter>
+                       </parameters>
+               </virtual-method>
                <property name="property" writable="1" construct="1">
                        <type name="gint" c:type="gint"/>
                </property>
@@ -2079,6 +2133,18 @@
                                </parameters>
                        </callback>
                </field>
+               <field name="no_wrapper_method">
+                       <callback name="no_wrapper_method" c:type="no_wrapper_method">
+                               <return-value transfer-ownership="full">
+                                       <type name="none" c:type="void"/>
+                               </return-value>
+                               <parameters>
+                                       <instance-parameter name="self" transfer-ownership="none">
+                                               <type name="GirTest.InterfaceTest" 
c:type="GirTestInterfaceTest*"/>
+                                       </instance-parameter>
+                               </parameters>
+                       </callback>
+               </field>
                <field name="get_property">
                        <callback name="get_property" c:type="get_property">
                                <return-value transfer-ownership="none">
diff --git a/tests/girwriter/girtest.vala b/tests/girwriter/girtest.vala
index 18c3ba80e..72d3e8866 100644
--- a/tests/girwriter/girtest.vala
+++ b/tests/girwriter/girtest.vala
@@ -81,6 +81,9 @@ namespace GirTest {
                }
                internal virtual void internal_method () {
                }
+               [NoWrapper]
+               public virtual void no_wrapper_method () {
+               }
        }
 
        [GIR (visible = false)]
@@ -280,6 +283,10 @@ namespace GirTest {
                [GIR (visible = false)]
                public void skipped_method () {
                }
+
+               [NoWrapper]
+               public virtual void no_wrapper_method () {
+               }
        }
 
        public abstract class AbstractObjectTest : Object {
@@ -297,6 +304,9 @@ namespace GirTest {
                public abstract async void skipped_coroutine_method (int param);
 
                internal abstract void internal_method (int8 param);
+
+               [NoWrapper]
+               public abstract void no_wrapper_method ();
        }
 
        public interface PrerequisiteTest : InterfaceTest {
diff --git a/tests/girwriter/girtest.vapi-expected b/tests/girwriter/girtest.vapi-expected
index 7e78a87c0..672e0de4b 100644
--- a/tests/girwriter/girtest.vapi-expected
+++ b/tests/girwriter/girtest.vapi-expected
@@ -12,6 +12,8 @@ namespace GirTest {
                public abstract void method_int8_out (out int8 param);
                public abstract void method_throw () throws GirTest.ErrorTest;
                public abstract void method_valist (int param, va_list vargs);
+               [NoWrapper]
+               public abstract void no_wrapper_method ();
                [GIR (visible = false)]
                public abstract async void skipped_coroutine_method (int param);
        }
@@ -76,6 +78,8 @@ namespace GirTest {
                public virtual void method_with_default_impl (int8 param);
                public ObjectTest.new_valist (int param, va_list vargs);
                public ObjectTest.newv (int param, ...);
+               [NoWrapper]
+               public virtual void no_wrapper_method ();
                public void none_in ();
                public static void none_inout (ref unowned GirTest.ObjectTest obj);
                public static void none_out (out unowned GirTest.ObjectTest obj);
@@ -119,6 +123,8 @@ namespace GirTest {
                public virtual async void coroutine_async ();
                public virtual void int8_in (int8 param);
                public virtual void method_valist (int param, va_list vargs);
+               [NoWrapper]
+               public virtual void no_wrapper_method ();
                [GIR (visible = false)]
                public virtual async void skipped_coroutine_method (int param);
                public abstract int property { get; set construct; }
diff --git a/tests/girwriter/girtest.vapigen-expected b/tests/girwriter/girtest.vapigen-expected
index 68bb68f90..6b66c49d9 100644
--- a/tests/girwriter/girtest.vapigen-expected
+++ b/tests/girwriter/girtest.vapigen-expected
@@ -14,6 +14,8 @@ namespace GirTest {
                public abstract void method_int8_out (out int8 param);
                public abstract void method_throw () throws GLib.Error;
                public abstract void method_valist (int param, va_list vargs);
+               [NoWrapper]
+               public abstract void no_wrapper_method ();
        }
        [CCode (cheader_filename = "girtest.h", has_type_id = false)]
        [Compact]
@@ -104,6 +106,8 @@ namespace GirTest {
                public virtual void method_throw () throws GLib.Error;
                public void method_with_default (int i);
                public virtual void method_with_default_impl (int8 param);
+               [NoWrapper]
+               public virtual void no_wrapper_method ();
                public void none_in ();
                public static void none_inout (ref unowned GirTest.ObjectTest obj);
                public static void none_out (out unowned GirTest.ObjectTest obj);
@@ -149,6 +153,8 @@ namespace GirTest {
                public virtual int get_property ();
                public virtual void int8_in (int8 param);
                public virtual void internal_method ();
+               [NoWrapper]
+               public virtual void no_wrapper_method ();
                public virtual void set_property (int value);
                public abstract int property { get; set construct; }
        }


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