I'm playing around with libpeas and I stumbled upon a problem with the way gobject-introspection works.
In libpeas there is a type called PluginLoader (see here).
There is a method called create_extension that returns PeasExtension * which is a point to a GObject. When I add this type to gobject-introspection and I check the resulting GIR file for this method I can see that it's marked as introspectable="0":
<field name="create_extension" introspectable="0">
<callback name="create_extension" introspectable="0">
<source-position filename="../libpeas/peas-plugin-loader.h"
line="60"/>
<return-value>
<type name="Extension" c:type="PeasExtension*"/>
</return-value>
<parameters>
<parameter name="loader" transfer-ownership="none">
<type name="PluginLoader" c:type="PeasPluginLoader*"/>
</parameter>
<parameter name="info" transfer-ownership="none">
<type name="PluginInfo" c:type="PeasPluginInfo*"/>
</parameter>
<parameter name="ext_type" transfer-ownership="none">
<type name="GType" c:type="GType"/>
</parameter>
<parameter name="n_parameters" transfer-ownership="none">
<type name="guint" c:type="guint"/>
</parameter>
<parameter name="parameters" transfer-ownership="none">
<type name="GObject.Parameter" c:type="GParameter*"/>
</parameter>
</parameters>
</callback>
</field>
When I change the return value to void * and recompile the introspectable="0" attribute is gone from the GIR file. If I change it to GObject * then the introspectable="0" attribute is still present.
It looks like it becomes non-introspectable when it returns an instance of GObject (a pointer). But I don't undestand why?
By reading the gobject introspection docs it looks like returning a GObject instance is a valid use case. Maybe it has something to do with that PluginLoader type is abstract and this is a virtual method?
Could any annotations help in making this object introspectable without changing the method signature?
With the help of Philip in the comments I've managed to resolve the issue.
There was actually a message in the output of
g-ir-scannersaying:By this message I understood that to make the virtual function
create_extensionintrospectible I have to add annotations, but not at the function pointer in thePeasPluginLoaderClassdefinition, but rather next to accessor functionpeas_plugin_loader_create_extension.