Re: [Vala] Vapi delegate problems.



That gives me the following error.

libzmq.vapi:80.34-80.41: error: The type name `GLib.Fun' could not be found
            public Msg.data(uint8[] data, GLib.Fun? ffn = null);

Although, I tried:

[CCode (cname = "zmq_free_fn", type = "void (*)(void *, void *)")]
public delegate void free_fn(void *data);

with the constructor:

[CCode (cname = "zmq_msg_init_data")]
public Msg.data(owned uint8[] data, free_fn?  ffn = null);

And it now compiles and runs. It seems to work properly now. I have the
hello world example working.

Although, in the constructor the data is type uint8[], and in it's free
function free_fn it's a void*. Is there any way to correct this?


Thanks,
~Lewis

On Wed, Apr 27, 2011 at 1:18 AM, Luca Bruno <lethalman88 gmail com> wrote:

On Tue, Apr 26, 2011 at 03:50:39PM -0600, Lewis Gunsch wrote:
Hi,

I am having trouble getting a delegate in a vapi to work correctly. My
original attempt (line 70 of the vapi) did not work because of how the
typedef is in the C header (it's not a function pointer), so instead of
using their typedef I used GLib.Func which matches the function
signature.
This is suppose to be (void*)(void*, void*), but Vala creates it to be
(void*)(const void*, void*) and then produces an error. The method that
produces this error is

ZMQ.MSG.Msg.data(uint8[] data, GLib.Func? ffn = null);

and the corresponding C method is

ZMQ_EXPORT int zmq_msg_init_data (zmq_msg_t *msg, void *data, size_t
size,
zmq_free_fn *ffn, void *hint);

The library I'm am trying to write the vapi for is ZeroMQ. Here is a link
to
zmq.h.
https://github.com/zeromq/zeromq2-1/blob/v2.1.4/include/zmq.h

You can see my attempt at the vapi below. My original delegate which I
could
not get to work is on line 70.
https://github.com/lgunsch/zmq-vala/blob/msg_refactor/libzmq.vapi

And my test is here:

https://github.com/lgunsch/zmq-vala/blob/msg_refactor/examples/delegatetest.vala

Sorry if I have not explained myself in a clear manner. Help is much
appreciated!

What happens if you add [CCode (type = "(void*)(void*, void*)")] to the
parameter?

--
http://www.debian.org - The Universal Operating System

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQIcBAEBCAAGBQJNt8NLAAoJEETrFmfSwntrCUUP/RDgIfMZj2juJXdOzF7T+M29
lXhtNi3tUP2rlEOwfeeozwQahno2v0YyNmvoKxK8WNqpMp9aK73ejH4zqeE1tb1i
Qau12DN9p3ipPF7ek07OcGqKvwQocVppVLRrefg5cMrhhoa4iFkUBm2g1FzYv89t
81D8xMMnq2NH4LNqrl3kIxUOn4e0lMfoNq3GwI+4kBgSLdIo/lEu8shfRYnW/zOv
7mjm7abWEOxXWRWLC/MMNTvMmzdPUqRY515xOKOMAzg1usUXs+GppIsLbMmpdUMT
dkwMF0qGp98TjjJlNIE2J6HpXILnqM8+1R2iudUakMkN+dCbStUs9a523qom8xUx
P6Dga/5NqJpywgyYje3rUGWm8TXppLQUr2SK71J04Qh4yeBvT3dnMK7ogUraqyQC
LgZADRE3I6fA2GWux9kEbH3TmYo/LYZYzCp7pDK+XRiKfG2ENneAbIAC+4YlXSRb
iKpNUK0+LZO5QLuVhmshJ9djP3bcNylTo90MS/ibhQ8dB0QnXNWBnPGVpFxVjR8v
/RPG1fc4ijAHdLvNQoxBdsMJkeR47n51beBBFiTJ82HsYy3cVx8u0yF/1ZXgKYaD
7jeRK5UgOiL7zQWXCQdM2l2vVMpmtDSp1rVG4BxeG0rLx7mI8qo7kJQT6B+fe7wX
dpIp/GRmNxM01EIq9aoX
=cZId
-----END PGP SIGNATURE-----




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]