2

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?

geoffjay
  • 413
  • 4
  • 13

2 Answers2

3

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

apmasell
  • 7,033
  • 19
  • 28
2

I have written a partial VAPI for MessagePack if you want to contribute back by using and testing it.

https://github.com/valum-framework/vala-extra-vapis/blob/msgpack/msgpack.vapi

Like already said, you need to use the [SimpleType] annotation on the class to have your type passed by value.

EDIT: Just adding that for bindings, it's a good thing to keep them in nemequ/vala-extra-vapis repository.

arteymix
  • 433
  • 4
  • 6
  • Hmm, I search github for that before starting and came up empty. I definitely wouldn't have started one had I seen it. Thanks. – geoffjay Jul 12 '16 at 18:55