Re: [Vala] vala generated function naming

2014-10-13 Thread Jeremy Slater
On Sun, Oct 12, 2014 at 11:38 AM, Abderrahim Kitouni
 wrote:
>
> Hello,
>
> Le 12 oct. 2014 15:04, "Jeremy Slater"  a écrit :
> >
> > I'm having an issue with the way vala generates names for functions like
> > callback wrappers and struct array free routines.  I am writing a vapi for
> > a library that does not typedef structures, so in my vapi I have to set the
> > cname to include struct, i.e. cname="struct some_structure".  This results
> > in the generated free for an array of some_structure being generated as
> > "_vala_struct some_structure_array_free".
>
> You should use lower_case_cname as well. (not sure of the spelling though, 
> take a look at other vapid)

lower_case_cprefix (I assume is what you meant) appears to only be
used for the direct struct methods like destroy and copy.  the
array_free method for freeing the array of structs, is only
constructed directly from the cname.  The relevant code,
append_struct_array_free, appears to be around
valaccodearraymodule.vala:205.

> > In addition, the header I am wrapping defines callbacks as function
> > definitions, rather than function pointers.  So when I define my delegates
> > I have to include the * in the cname:  cname="callback_function *".  This
> > results in a wrapper function for a delegate of "test_callback" being
> > generated as "_test_callback_callback_function *".
>
> Sorry, I didn't understand this part.

So the 'normal' typedef for passing around functions, is using a
function pointer, like:

  typedef int (*get_integer)(int param);

But sometimes headers just declare the function, rather than the pointer:

  typedef int (get_integer)(int param);

This doesn't map into the delegate definition in vala however, so I
need to set the cname for the delegate as the pointer to the function
definition, i.e. cname="get_integer *".
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


[Vala] vala generated function naming

2014-10-12 Thread Jeremy Slater
I'm having an issue with the way vala generates names for functions like
callback wrappers and struct array free routines.  I am writing a vapi for
a library that does not typedef structures, so in my vapi I have to set the
cname to include struct, i.e. cname="struct some_structure".  This results
in the generated free for an array of some_structure being generated as
"_vala_struct some_structure_array_free".

In addition, the header I am wrapping defines callbacks as function
definitions, rather than function pointers.  So when I define my delegates
I have to include the * in the cname:  cname="callback_function *".  This
results in a wrapper function for a delegate of "test_callback" being
generated as "_test_callback_callback_function *".

In order to solve both these problems I have added some string replace
methods to swap spaces and *'s for underscores, although certainly not
everywhere that this issue could appear.  Is there a better solution I
should be using, like setting array copy function names in the vapi similar
to how you can set the destroy function name?

Thanks,
Jeremy
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list