Can't modify type in CCode attributes in VAPI file
I tried to compile the following code :
class TestParser: Object {
const MarkupParser parser = { start, null, null, null, null };
void start (MarkupParseContext context, string name, string[] attr_names, string[] attr_values) throws MarkupError { }
}
void main()
{
}
I got the following warning :
warning: initialization of
'void (*)(GMarkupParseContext *, const gchar *, const gchar **, const gchar **, void *, GError **)'
{aka 'void (*)(struct _GMarkupParseContext *, const char *, const char **, const char **, void *, struct _GError **)'}
from incompatible pointer type
'void (*)(GMarkupParseContext *, const gchar *, gchar **, gchar **, void *, GError **)'
{aka 'void (*)(struct _GMarkupParseContext *, const char *, char **, char **, void *, struct _GError **)'}
[-Wincompatible-pointer-types]
static const GMarkupParser TEST_PARSER_parser = {_test_parser_start_gmarkup_parser_start_element_func, NULL, NULL, NULL, NULL};
It appears that the const
keyword is missing for the third and fourth arguments.
void (*)(GMarkupParseContext *, const gchar *, const gchar **, const gchar **, void *, GError **)
void (*)(GMarkupParseContext *, const gchar *, gchar **, gchar **, void *, GError **)
I tried to modify the MarkupParserStartElementFunc
declaration in glib-2.0.vapi
by adding [type = "const gchar* const*"
] in the third and fourth parameters, like this :
public delegate void MarkupParserStartElementFunc (
MarkupParseContext context,
string element_name,
[CCode (array_length = false, array_null_terminated = true, type = "const gchar* const*")] string[] attribute_names,
[CCode (array_length = false, array_null_terminated = true, type = "const gchar* const*")] string[] attribute_values
) throws MarkupError;
But Valac ignores this modification and produces always the same code...
The type
parameter in the CCode
attribute seems to be ignore by Valac.