Annotate constructors that return base types

Review Request #3835 — Created Feb. 14, 2025 and submitted

Information

gplugin/gplugin
default

Reviewers

In that case, annotating the actual type will help bindings use the correct type.

I'm not sure why gplugin_file_source_new was a function before, instead of the constructor it is now, but the latter seems more correct.

Compared the girs before and after:

--- GPlugin-1.0.gir 2025-02-14 02:04:07.065756077 -0500
+++ build/gplugin/GPlugin-1.0.gir   2025-02-14 02:04:25.400858480 -0500
@@ -92,9 +92,9 @@
            line="23">A [iface@GPlugin.Source] that will query plugins on disk.</doc>
       <source-position filename="gplugin/gplugin-file-source.h" line="33"/>
       <implements name="Source"/>
-      <function name="new"
-                c:identifier="gplugin_file_source_new"
-                version="0.39">
+      <constructor name="new"
+                   c:identifier="gplugin_file_source_new"
+                   version="0.39">
         <doc xml:space="preserve"
              filename="gplugin/gplugin-file-source.c"
              line="600">Creates a [iface@GPlugin.Source] that will query plugins on disk using the
@@ -104,7 +104,7 @@
           <doc xml:space="preserve"
                filename="gplugin/gplugin-file-source.c"
                line="607">The new source.</doc>
-          <type name="Source" c:type="GPluginSource*"/>
+          <type name="FileSource" c:type="GPluginSource*"/>
         </return-value>
         <parameters>
           <parameter name="manager" transfer-ownership="none">
@@ -114,7 +114,7 @@
             <type name="Manager" c:type="GPluginManager*"/>
           </parameter>
         </parameters>
-      </function>
+      </constructor>
       <property name="manager"
                 version="0.39"
                 writable="1"
--- GPluginGtk4-1.0.gir 2025-02-14 02:04:13.950794531 -0500
+++ build/gplugin-gtk4/GPluginGtk4-1.0.gir  2025-02-14 02:04:27.138868187 -0500
@@ -107,7 +107,7 @@
           <doc xml:space="preserve"
                filename="gplugin-gtk4/gplugin-gtk-plugin-page.c"
                line="365">The new widget.</doc>
-          <type name="Gtk.Widget" c:type="GtkWidget*"/>
+          <type name="PluginPage" c:type="GtkWidget*"/>
         </return-value>
       </constructor>
       <method name="get_plugin"
@@ -312,7 +312,7 @@
           <doc xml:space="preserve"
                filename="gplugin-gtk4/gplugin-gtk-plugin-row.c"
                line="234">The new widget.</doc>
-          <type name="Gtk.Widget" c:type="GtkWidget*"/>
+          <type name="PluginRow" c:type="GtkWidget*"/>
         </return-value>
       </constructor>
       <method name="get_plugin"
@@ -492,7 +492,7 @@
           <doc xml:space="preserve"
                filename="gplugin-gtk4/gplugin-gtk-plugin-settings-list.c"
                line="635">The new list.</doc>
-          <type name="Gtk.Widget" c:type="GtkWidget*"/>
+          <type name="PluginSettingsList" c:type="GtkWidget*"/>
         </return-value>
       </constructor>
       <method name="get_settings"
@@ -691,7 +691,7 @@
           <doc xml:space="preserve"
                filename="gplugin-gtk4/gplugin-gtk-view.c"
                line="387">The new view.</doc>
-          <type name="Gtk.Widget" c:type="GtkWidget*"/>
+          <type name="View" c:type="GtkWidget*"/>
         </return-value>
       </constructor>
       <method name="get_manager"
Summary ID
Annotate constructors that return base types
In that case, annotating the actual type will help bindings use the correct type.
cbaa01f821f279875804047234d33d863a7a3fa3
grim
  1. Great work, thanks!!

  2. 
      
grim
Review request changed
Status:
Completed