valavapi

Controlling the ref type in a Vapi file


I'm trying to write a Vapi file for MessagePack and am having a couple of issues, the first being that the resulting msgpack_object_print is incorrect because of the reference type of one of the parameters. The header file expects

void msgpack_object_print(FILE* out, msgpack_object o);

and my Vapi file contains

[CCode (instance_pos = 1.1)]
public void print (Posix.FILE out);

which generates the C output

msgpack_object_print (_tmp13_, &obj);

where obj is type msgpack_object *. This creates the error

examples/simple.c:173:34: error: incompatible type for argument 2 of ‘msgpack_object_print’

and it disappears if I remove the & from the generated C. So I'm wondering what my Vapi should contain to result in the correct output?


Solution

  • You can designated your msgpack_object class as [SimpleType] and it will be copied by value rather than by reference.