Nautilus extension modules are required to have a function with the following signature:
/**
* nautilus_module_list_types:
* @types: (out) (array length=num_types): array of GType *
* @num_types: the number of types in the array
*
* Called after the extension has been initialized and has registered all the
* types it exports, to load them into Nautilus.
*/
void nautilus_module_list_types (const GType **types,
int *num_types);
that is, types
is an output, despite being const
. I haven’t been able to come up with an appropriate Vala function signature to match this. The best I have is:
public void _nautilus_module_list_types([CCode (array_length_type = "int")] out Type[] types)
But this does not generate the const
modifier and compilation fails.
I’m wondering: is there some kind of annotation I can add here to generate the correct C function signature? The Vala bindings tutorial seems to suggest that it is possible to change the const
status, but I’m not sure exactly how.
If it’s helpful, the relevant part of the Gir file is the following:
<parameters>
<parameter name="types"
direction="out"
caller-allocates="0"
transfer-ownership="full">
<doc xml:space="preserve"
filename="../libnautilus-extension/nautilus-extension.h"
line="53">array of GType *</doc>
<array length="1" zero-terminated="0" c:type="const GType**">
<type name="GType" c:type="GType*"/>
</array>
</parameter>
<parameter name="num_types"
direction="out"
caller-allocates="0"
transfer-ownership="full">
<doc xml:space="preserve"
filename="../libnautilus-extension/nautilus-extension.h"
line="54">the number of types in the array</doc>
<type name="gint" c:type="int*"/>
</parameter>
</parameters>