Re: [Vala] LADSPA bindings
Hi Victor, Thank you for pointing that out. After reading the documentation for that function I believe the best way to bind it would be like so: [CCode (cname = "LADSPA_Connect_Port_Function", has_target = false)] public delegate void ConnectPortFunc(Handle instance, ulong port, [CCode (array_length = false, array_null_terminated = true)] Data[] data); You could then use the function like so: // in the case of a single value Data[] data = { 1.0f }; desc.connect_port(handle, 0, data); // in the case of multiple values Data[] data = { 1.0f, 2.0f, 3.0f }; desc.connect_port(handle, 0, data); Please consider contributing this vapi file to the vala extra vapis repository. Thank you, Aaron Quoting Victor Aurélio Santos <victoraur.san...@gmail.com>: Thank you very much, Aaron There's only a thing to change, in the connect_port delegate DataLocation is a pointer to a float not a float, but changing to "Data?" solved. 2016-09-13 14:19 GMT-03:00 Aaron Andersen <aa...@fosslib.net>: Hello Victor, You have chosen one of the more difficult C libraries to bind to Vala. The way this library is setup so contrary to the GObject way of doing things it is certainly an edge case. Unfortunately this library requires a small C header "helper" file to accompany your vapi. The main reason for this is that Vala doesn't deal with unnamed function pointers. I've gone ahead and created ladspa.vapi, ladspa-vala.h (a C header "helper" file to make Vala work with the ladspa library), and main.vala (a test program I used to ensure the vapi was correct). main.vala - http://pastebin.com/VF9AXrLY ladspa.vapi - http://pastebin.com/WeaKPHnc ladspa-vala.h - http://pastebin.com/GB4kPzw1 I placed all of these 3 files into a single directory and then ran this command to compile: valac --pkg ladspa --vapidir . main.vala --save-temps -X -L/usr/lib/ladspa/ -X -l:amp.so -X -I. and this command to run the program: LD_LIBRARY_PATH=/usr/lib/ladspa/ ./main From reading the documentation I understand that the ladspa framework intends for the user to dynamically load plugins via dlopen but I hope you get the idea from the example. Please don't hesitate to ask any questions about this code. Thank you, Aaron Quoting Al Thomas <astav...@yahoo.co.uk>: - Original Message - From: Victor Aurélio Santos <victoraur.san...@gmail.com> Sent: Tuesday, 13 September 2016, 15:55 Subject: Re: [Vala] LADSPA bindings Now... [CCode (cname = "connect_port", has_target = false)] public delegate void DescriptorConnectPort(Handle? instance, ulong port, ref double dataLocation); results in: src/CompressorBackend.c: In function ‘ajami_compressor_backend_connect’: src/CompressorBackend.c:674:2: error: unknown type name ‘connect_port’ connect_port _tmp2_ = NULL; I presume there's no typedef for it then. Instead try: [CCode (lower_case_cprefix = "", has_target = false)] public delegate void ConnectPort(Handle? instance, ulong port, ref double dataLocation); The lower_case_cprefix should remove the default namespace prefix and then ConnectPort will be converted to connect_port in C. That's my interpretation of the last paragraph of: https://wiki.gnome.org/Projects/Vala/LegacyBindings#Delegates If that doesn't work, I'm not sure what else to suggest. The paragraph could mean include an empty cname, e.g. [CCode (cname = "", has_target = false)] public delegate void DescriptorConnectPort(Handle? instance, ulong port, ref double dataLocation); Use the --ccode switch with valac to get the C code produced. Look at the code and tweak it until it works then work back to the VAPI. You can use valac to compile C. Just use valac --pkg xyz my_c_file.c ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list -- Victor Aurélio Santos ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
Thank you very much, Aaron There's only a thing to change, in the connect_port delegate DataLocation is a pointer to a float not a float, but changing to "Data?" solved. 2016-09-13 14:19 GMT-03:00 Aaron Andersen <aa...@fosslib.net>: > Hello Victor, > > You have chosen one of the more difficult C libraries to bind to Vala. The > way this library is setup so contrary to the GObject way of doing things it > is certainly an edge case. > > Unfortunately this library requires a small C header "helper" file to > accompany your vapi. The main reason for this is that Vala doesn't deal with > unnamed function pointers. > > I've gone ahead and created ladspa.vapi, ladspa-vala.h (a C header "helper" > file to make Vala work with the ladspa library), and main.vala (a test > program I used to ensure the vapi was correct). > > main.vala - http://pastebin.com/VF9AXrLY > ladspa.vapi - http://pastebin.com/WeaKPHnc > ladspa-vala.h - http://pastebin.com/GB4kPzw1 > > I placed all of these 3 files into a single directory and then ran this > command to compile: > > valac --pkg ladspa --vapidir . main.vala --save-temps -X -L/usr/lib/ladspa/ > -X -l:amp.so -X -I. > > and this command to run the program: > > LD_LIBRARY_PATH=/usr/lib/ladspa/ ./main > > From reading the documentation I understand that the ladspa framework > intends for the user to dynamically load plugins via dlopen but I hope you > get the idea from the example. > > Please don't hesitate to ask any questions about this code. > > Thank you, > Aaron > > Quoting Al Thomas <astav...@yahoo.co.uk>: > >>> - Original Message - >>> From: Victor Aurélio Santos <victoraur.san...@gmail.com> >>> Sent: Tuesday, 13 September 2016, 15:55 >>> Subject: Re: [Vala] LADSPA bindings >> >> >>> Now... >> >> >>> [CCode (cname = "connect_port", has_target = false)] >>> public delegate void DescriptorConnectPort(Handle? instance, ulong >>> port, ref double dataLocation); >> >> >>> results in: >>> src/CompressorBackend.c: In function ‘ajami_compressor_backend_connect’: >>> src/CompressorBackend.c:674:2: error: unknown type name ‘connect_port’ >>> connect_port _tmp2_ = NULL; >> >> >> >> I presume there's no typedef for it then. Instead try: >> >> [CCode (lower_case_cprefix = "", has_target = false)] >> public delegate void ConnectPort(Handle? instance, ulong >> port, ref double dataLocation); >> >> The lower_case_cprefix should remove the default namespace prefix >> and then ConnectPort will be converted to connect_port in C. >> >> That's my interpretation of the last paragraph of: >> https://wiki.gnome.org/Projects/Vala/LegacyBindings#Delegates >> >> If that doesn't work, I'm not sure what else to suggest. The paragraph >> could >> mean include an empty cname, e.g. >> >> >> [CCode (cname = "", has_target = false)] >> public delegate void DescriptorConnectPort(Handle? instance, ulong >> port, ref double dataLocation); >> >> >> Use the --ccode switch with valac to get the C code produced. Look at the >> code and tweak it until it works then work back to the VAPI. You can use >> valac to compile C. Just use valac --pkg xyz my_c_file.c >> ___ >> vala-list mailing list >> vala-list@gnome.org >> https://mail.gnome.org/mailman/listinfo/vala-list > > > > -- Victor Aurélio Santos ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
Hello Victor, You have chosen one of the more difficult C libraries to bind to Vala. The way this library is setup so contrary to the GObject way of doing things it is certainly an edge case. Unfortunately this library requires a small C header "helper" file to accompany your vapi. The main reason for this is that Vala doesn't deal with unnamed function pointers. I've gone ahead and created ladspa.vapi, ladspa-vala.h (a C header "helper" file to make Vala work with the ladspa library), and main.vala (a test program I used to ensure the vapi was correct). main.vala - http://pastebin.com/VF9AXrLY ladspa.vapi - http://pastebin.com/WeaKPHnc ladspa-vala.h - http://pastebin.com/GB4kPzw1 I placed all of these 3 files into a single directory and then ran this command to compile: valac --pkg ladspa --vapidir . main.vala --save-temps -X -L/usr/lib/ladspa/ -X -l:amp.so -X -I. and this command to run the program: LD_LIBRARY_PATH=/usr/lib/ladspa/ ./main From reading the documentation I understand that the ladspa framework intends for the user to dynamically load plugins via dlopen but I hope you get the idea from the example. Please don't hesitate to ask any questions about this code. Thank you, Aaron Quoting Al Thomas <astav...@yahoo.co.uk>: - Original Message - From: Victor Aurélio Santos <victoraur.san...@gmail.com> Sent: Tuesday, 13 September 2016, 15:55 Subject: Re: [Vala] LADSPA bindings Now... [CCode (cname = "connect_port", has_target = false)] public delegate void DescriptorConnectPort(Handle? instance, ulong port, ref double dataLocation); results in: src/CompressorBackend.c: In function ‘ajami_compressor_backend_connect’: src/CompressorBackend.c:674:2: error: unknown type name ‘connect_port’ connect_port _tmp2_ = NULL; I presume there's no typedef for it then. Instead try: [CCode (lower_case_cprefix = "", has_target = false)] public delegate void ConnectPort(Handle? instance, ulong port, ref double dataLocation); The lower_case_cprefix should remove the default namespace prefix and then ConnectPort will be converted to connect_port in C. That's my interpretation of the last paragraph of: https://wiki.gnome.org/Projects/Vala/LegacyBindings#Delegates If that doesn't work, I'm not sure what else to suggest. The paragraph could mean include an empty cname, e.g. [CCode (cname = "", has_target = false)] public delegate void DescriptorConnectPort(Handle? instance, ulong port, ref double dataLocation); Use the --ccode switch with valac to get the C code produced. Look at the code and tweak it until it works then work back to the VAPI. You can use valac to compile C. Just use valac --pkg xyz my_c_file.c ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
> - Original Message - > From: Victor Aurélio Santos <victoraur.san...@gmail.com> > Sent: Tuesday, 13 September 2016, 15:55 > Subject: Re: [Vala] LADSPA bindings > Now... > [CCode (cname = "connect_port", has_target = false)] > public delegate void DescriptorConnectPort(Handle? instance, ulong > port, ref double dataLocation); > results in: > src/CompressorBackend.c: In function ‘ajami_compressor_backend_connect’: > src/CompressorBackend.c:674:2: error: unknown type name ‘connect_port’ > connect_port _tmp2_ = NULL; I presume there's no typedef for it then. Instead try: [CCode (lower_case_cprefix = "", has_target = false)] public delegate void ConnectPort(Handle? instance, ulong port, ref double dataLocation); The lower_case_cprefix should remove the default namespace prefix and then ConnectPort will be converted to connect_port in C. That's my interpretation of the last paragraph of: https://wiki.gnome.org/Projects/Vala/LegacyBindings#Delegates If that doesn't work, I'm not sure what else to suggest. The paragraph could mean include an empty cname, e.g. [CCode (cname = "", has_target = false)] public delegate void DescriptorConnectPort(Handle? instance, ulong port, ref double dataLocation); Use the --ccode switch with valac to get the C code produced. Look at the code and tweak it until it works then work back to the VAPI. You can use valac to compile C. Just use valac --pkg xyz my_c_file.c ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
Now... [CCode (cname = "connect_port", has_target = false)] public delegate void DescriptorConnectPort(Handle? instance, ulong port, ref double dataLocation); results in: src/CompressorBackend.c: In function ‘ajami_compressor_backend_connect’: src/CompressorBackend.c:674:2: error: unknown type name ‘connect_port’ connect_port _tmp2_ = NULL; 2016-09-13 6:40 GMT-03:00 Al Thomas <astav...@yahoo.co.uk>: > > > > >> - Original Message - > >> From: Victor Aurélio Santos <victoraur.san...@gmail.com> > >> Sent: Tuesday, 13 September 2016, 3:22 > >> Subject: Re: [Vala] LADSPA bindings > >>[CCode (has_target = false)] >>public delegate void DescriptorConnectPort(Handle? instance, ulong >> port, ref double dataLocation); > > > You probably want: > [CCode (cname = "connect_port", has_target = false)] > > >> but... > >> src/CompressorBackend.c: In function ‘ajami_compressor_backend_connect’: >> src/CompressorBackend.c:674:2: error: unknown type name >> ‘LADSPA_DescriptorConnectPort’ > > > There are name conversion rules between the Vala side and C. > > I've started to document them, but not completed the examples yet: > https://wiki.gnome.org/Projects/Vala/LegacyBindings#Naming_Conventions > > For an example for delegates take a look at: > https://wiki.gnome.org/Projects/Vala/LegacyBindings#Delegates -- Victor Aurélio Santos ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
> - Original Message - > From: Victor Aurélio Santos <victoraur.san...@gmail.com> > Sent: Tuesday, 13 September 2016, 3:22 > Subject: Re: [Vala] LADSPA bindings >[CCode (has_target = false)] >public delegate void DescriptorConnectPort(Handle? instance, ulong > port, ref double dataLocation); You probably want: [CCode (cname = "connect_port", has_target = false)] > but... > src/CompressorBackend.c: In function ‘ajami_compressor_backend_connect’: > src/CompressorBackend.c:674:2: error: unknown type name > ‘LADSPA_DescriptorConnectPort’ There are name conversion rules between the Vala side and C. I've started to document them, but not completed the examples yet: https://wiki.gnome.org/Projects/Vala/LegacyBindings#Naming_Conventions For an example for delegates take a look at: https://wiki.gnome.org/Projects/Vala/LegacyBindings#Delegates ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
I think you are missing prefixes: [CCode (lower_case_cprefix="", …)] Victor Aurélio Santos <victoraur.san...@gmail.com> ezt írta (időpont: 2016. szept. 13., K, 4:23): > What I've done: > > [Compact, CCode (cname = "void")] > public class Handle { > // ... > } > > [CCode (has_target = false)] > public delegate void DescriptorConnectPort(Handle? instance, ulong > port, ref double dataLocation); > > [CCode (copy_function="", destroy_function="")] > public struct Descriptor > { > [CCode (cname = "UniqueID")] > public ulong unique_id; > [CCode (cname = "Label")] > public unowned string label; > [CCode (cname = "Properties")] > public Properties properties; > [CCode (cname = "Name")] > public unowned string name; > [CCode (cname = "Maker")] > public unowned string maker; > [CCode (cname = "Copyright")] > public unowned string copyright; > [CCode (cname = "PortCount")] > public ulong port_count; > [CCode (cname = "PortDescriptors")] > public const PortDescriptor[] port_descriptors; > [CCode (cname = "PortNames")] > public unowned string[] port_names; > [CCode (cname = "PortRangeHints")] > public const PortRangeHint[] port_range_hints; > [CCode (cname = "ImplementationData")] > public void[] implementation_data; > > public Handle? instantiate(Handle? descriptor, ulong sampleRate); > > public DescriptorConnectPort? connect_port; > > public void activate(Handle? instance); > > public void run(Handle? instance, ulong sampleCount); > > public void run_adding(Handle? instance, ulong sampleCount); > > public void set_run_adding_gain(Handle? instance, Data gain); > > public void deactivate(Handle? instance); > > public void cleanup(Handle? instance); > } > > but... > > src/CompressorBackend.c: In function ‘ajami_compressor_backend_connect’: > src/CompressorBackend.c:674:2: error: unknown type name > ‘LADSPA_DescriptorConnectPort’ > LADSPA_DescriptorConnectPort _tmp2_ = NULL; > src/CompressorBackend.c:745:2: error: called object ‘_tmp2_’ is not a > function or function pointer > _tmp2_ (_tmp4_, (gulong) AJAMI_COMPRESSOR_FLAGS_RMS_PEAK, > &(*s).rms_peak); > > 2016-09-11 14:27 GMT-03:00 Al Thomas <astav...@yahoo.co.uk>: > > > > > > > > > > - Original Message - > >> From: Victor Aurélio Santos <victoraur.san...@gmail.com> > >> Sent: Sunday, 11 September 2016, 17:08 > >> Subject: Re: [Vala] LADSPA bindings > > > >> The valac complaints: > > > >> LADSPA.vapi:52.9-52.41: error: unexpected declaration > >>public delegate void connect_port(Descriptor* instance, ulong > >> port, double* dataLocation); > > > > > > A delegate is a type, it identifies the function signature of the > callback. > > So the delegate should be defined outside of the struct. Then in the > struct > > you identify the callback with its type (the delegate name you've used) > and > > the identifier for the callback. I hope that gets you a step further > forward. > > Handling APIs in structs is something that I don't fully understand yet. > > > > -- > Victor Aurélio Santos > ___ > vala-list mailing list > vala-list@gnome.org > https://mail.gnome.org/mailman/listinfo/vala-list > ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
What I've done: [Compact, CCode (cname = "void")] public class Handle { // ... } [CCode (has_target = false)] public delegate void DescriptorConnectPort(Handle? instance, ulong port, ref double dataLocation); [CCode (copy_function="", destroy_function="")] public struct Descriptor { [CCode (cname = "UniqueID")] public ulong unique_id; [CCode (cname = "Label")] public unowned string label; [CCode (cname = "Properties")] public Properties properties; [CCode (cname = "Name")] public unowned string name; [CCode (cname = "Maker")] public unowned string maker; [CCode (cname = "Copyright")] public unowned string copyright; [CCode (cname = "PortCount")] public ulong port_count; [CCode (cname = "PortDescriptors")] public const PortDescriptor[] port_descriptors; [CCode (cname = "PortNames")] public unowned string[] port_names; [CCode (cname = "PortRangeHints")] public const PortRangeHint[] port_range_hints; [CCode (cname = "ImplementationData")] public void[] implementation_data; public Handle? instantiate(Handle? descriptor, ulong sampleRate); public DescriptorConnectPort? connect_port; public void activate(Handle? instance); public void run(Handle? instance, ulong sampleCount); public void run_adding(Handle? instance, ulong sampleCount); public void set_run_adding_gain(Handle? instance, Data gain); public void deactivate(Handle? instance); public void cleanup(Handle? instance); } but... src/CompressorBackend.c: In function ‘ajami_compressor_backend_connect’: src/CompressorBackend.c:674:2: error: unknown type name ‘LADSPA_DescriptorConnectPort’ LADSPA_DescriptorConnectPort _tmp2_ = NULL; src/CompressorBackend.c:745:2: error: called object ‘_tmp2_’ is not a function or function pointer _tmp2_ (_tmp4_, (gulong) AJAMI_COMPRESSOR_FLAGS_RMS_PEAK, &(*s).rms_peak); 2016-09-11 14:27 GMT-03:00 Al Thomas <astav...@yahoo.co.uk>: > > > > > - Original Message - >> From: Victor Aurélio Santos <victoraur.san...@gmail.com> >> Sent: Sunday, 11 September 2016, 17:08 >> Subject: Re: [Vala] LADSPA bindings > >> The valac complaints: > >> LADSPA.vapi:52.9-52.41: error: unexpected declaration >>public delegate void connect_port(Descriptor* instance, ulong >> port, double* dataLocation); > > > A delegate is a type, it identifies the function signature of the callback. > So the delegate should be defined outside of the struct. Then in the struct > you identify the callback with its type (the delegate name you've used) and > the identifier for the callback. I hope that gets you a step further forward. > Handling APIs in structs is something that I don't fully understand yet. -- Victor Aurélio Santos ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
- Original Message - > From: Victor Aurélio Santos <victoraur.san...@gmail.com> > Sent: Sunday, 11 September 2016, 17:08 > Subject: Re: [Vala] LADSPA bindings > The valac complaints: > LADSPA.vapi:52.9-52.41: error: unexpected declaration >public delegate void connect_port(Descriptor* instance, ulong > port, double* dataLocation); A delegate is a type, it identifies the function signature of the callback. So the delegate should be defined outside of the struct. Then in the struct you identify the callback with its type (the delegate name you've used) and the identifier for the callback. I hope that gets you a step further forward. Handling APIs in structs is something that I don't fully understand yet. ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
On Sun, 2016-09-11 at 16:30 +, Gergely Polonkai wrote: > Should not that be (Descriptor instance, ulong port, double? > dataLocation) > instead? Using asterisk in Vala seems unnatural to me… In general, you shouldn't use pointers in Vala. In general if you're using a pointer you're doing it wrong. The major use case for pointers is when you want to opt-out of Vala's automatic memory management, typically because the C API is too weird for Vala to handle automatically. That's why you see lots of pointers in libxml2. In general, marking a parameter as nullable (?) or as a reference (ref) or output (out) is the right way to go, but usually even that isn't necessary. Everything except SimpleType structs are passed as pointers anyways, so usually you only need to use ?/ref/out to describe the semantics of the parameter (i.e., can the value be null, or is it an in/out or out parameter). That said, LADSPA looks like somewhere a pointer would actually be appropriate, though not where you used it. The LADSPA_Handle instances should probably be a pointer because there is no way to tell Vala how to free it (you need to do something like `descriptor.cleanup(instance)`). Anyways, I would probably bind this as something like [Compact, CCode (cname = "void")] public class Handle { // ... } [CCode (has_target = false)] public delegate LADSPA.Handle* DescriptorInstantiate( Descriptor descriptor, ulong sample_rate); public struct Descriptor { [CCode (cname = "UniqueID")] public ulong unique_id; [CCode (cname = "Label")] public unowned string label; // ... public LADSPA.DescriptorInstantiate instantiate; } Note that the string is unowned; AFAICT they should all be. That means you don't need to do anything special for the copy and destroy functions. > > On Sun, Sep 11, 2016, 18:09 Victor Aurélio Santos < > victoraur.san...@gmail.com> wrote: > > > > > What I've tried: > > > > [CCode (copy_function="", destroy_function="")] > > public struct Descriptor > > { > > public ulong UniqueID; > > public const char[] Label; > > public Properties Properties; > > public const char[] Name; > > public const char[] Maker; > > public const char[] Copyright; > > public ulong PortCount; > > public const PortDescriptor[] PortDescriptors; > > public const char[,] PortNames; > > public const PortRangeHint[] PortRangeHints; > > public void[] ImplementationData; > > > > public Descriptor instantiate(Descriptor* descriptor, ulong > > sampleRate); > > > > [CCode (has_target = false)] > > public delegate void connect_port(Descriptor* instance, > > ulong > > port, double* dataLocation); > > > > public void activate(Descriptor* instance); > > > > public void run(Descriptor* instance, ulong sampleCount); > > > > public void run_adding(Descriptor* instance, ulong > > sampleCount); > > > > public void set_run_adding_gain(Descriptor* instance, Data > > gain); > > > > public void deactivate(Descriptor* instance); > > > > public void cleanup(Descriptor* instance); > > } > > > > The valac complaints: > > > > LADSPA.vapi:52.9-52.41: error: unexpected declaration > > public delegate void connect_port(Descriptor* instance, > > ulong > > port, double* dataLocation); > > > > 2016-09-10 20:18 GMT-03:00 Al Thomas <astav...@yahoo.co.uk>: > > > > > > > > > > > From: Victor Aurélio Santos <victoraur.san...@gmail.com> > > > > Sent: Saturday, 10 September 2016, 23:57 > > > > Subject: Re: [Vala] LADSPA bindings > > > > > > > > > > > I'm trying to use plugins from vala, not to write! > > > > I'm stuck at writing the vapi file, most specifically at the > > > > Descriptor > > struct. > > > > > > > > > > > > Take a look at > > https://wiki.gnome.org/Projects/Vala/LegacyBindings#Binding_a_C_Str > > uct.27s_Fields > > > > > > The function pointers are targetless delegates. There is no > > > > > > memory handling for the struct so I don't think it should be > > > > > > bound as a compact class. > > > > > > > > -- > > Victor Aurélio Santos > > ___ > > vala-list mailing list > > vala-list@gnome.org > > https://mail.gnome.org/mailman/listinfo/vala-list > > > ___ > vala-list mailing list > vala-list@gnome.org > https://mail.gnome.org/mailman/listinfo/vala-list signature.asc Description: This is a digitally signed message part ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
Try removing it everywhere. Structs are always translated into pointers, so every Descriptor * should be plain Descriptor instead. Where you need to pass pointers to simple types (e.g. double *), use “typename?” instead, like double? double_pointer_param. Another thing that is suspicious to me is char[,] PortNames, but it may be I just haven’t seen such Vala construct before. On Sun, Sep 11, 2016, 18:37 Victor Aurélio Santos < victoraur.san...@gmail.com> wrote: > Don't know.. but the error stays even changing > > Em 11 de set de 2016 13:30, "Gergely Polonkai" <gerg...@polonkai.eu> > escreveu: > >> Should not that be (Descriptor instance, ulong port, double? >> dataLocation) instead? Using asterisk in Vala seems unnatural to me… >> >> On Sun, Sep 11, 2016, 18:09 Victor Aurélio Santos < >> victoraur.san...@gmail.com> wrote: >> >>> What I've tried: >>> >>> [CCode (copy_function="", destroy_function="")] >>> public struct Descriptor >>> { >>> public ulong UniqueID; >>> public const char[] Label; >>> public Properties Properties; >>> public const char[] Name; >>> public const char[] Maker; >>> public const char[] Copyright; >>> public ulong PortCount; >>> public const PortDescriptor[] PortDescriptors; >>> public const char[,] PortNames; >>> public const PortRangeHint[] PortRangeHints; >>> public void[] ImplementationData; >>> >>> public Descriptor instantiate(Descriptor* descriptor, ulong >>> sampleRate); >>> >>> [CCode (has_target = false)] >>> public delegate void connect_port(Descriptor* instance, ulong >>> port, double* dataLocation); >>> >>> public void activate(Descriptor* instance); >>> >>> public void run(Descriptor* instance, ulong sampleCount); >>> >>> public void run_adding(Descriptor* instance, ulong sampleCount); >>> >>> public void set_run_adding_gain(Descriptor* instance, Data gain); >>> >>> public void deactivate(Descriptor* instance); >>> >>> public void cleanup(Descriptor* instance); >>> } >>> >>> The valac complaints: >>> >>> LADSPA.vapi:52.9-52.41: error: unexpected declaration >>> public delegate void connect_port(Descriptor* instance, ulong >>> port, double* dataLocation); >>> >>> 2016-09-10 20:18 GMT-03:00 Al Thomas <astav...@yahoo.co.uk>: >>> >> From: Victor Aurélio Santos <victoraur.san...@gmail.com> >>> >> Sent: Saturday, 10 September 2016, 23:57 >>> >> Subject: Re: [Vala] LADSPA bindings >>> > >>> >> I'm trying to use plugins from vala, not to write! >>> >> I'm stuck at writing the vapi file, most specifically at the >>> Descriptor struct. >>> > >>> > >>> > Take a look at >>> https://wiki.gnome.org/Projects/Vala/LegacyBindings#Binding_a_C_Struct.27s_Fields >>> > The function pointers are targetless delegates. There is no >>> > >>> > memory handling for the struct so I don't think it should be >>> > >>> > bound as a compact class. >>> >>> >>> >>> -- >>> Victor Aurélio Santos >>> ___ >>> vala-list mailing list >>> vala-list@gnome.org >>> https://mail.gnome.org/mailman/listinfo/vala-list >>> >> ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
Don't know.. but the error stays even changing Em 11 de set de 2016 13:30, "Gergely Polonkai" <gerg...@polonkai.eu> escreveu: > Should not that be (Descriptor instance, ulong port, double? dataLocation) > instead? Using asterisk in Vala seems unnatural to me… > > On Sun, Sep 11, 2016, 18:09 Victor Aurélio Santos < > victoraur.san...@gmail.com> wrote: > >> What I've tried: >> >> [CCode (copy_function="", destroy_function="")] >> public struct Descriptor >> { >> public ulong UniqueID; >> public const char[] Label; >> public Properties Properties; >> public const char[] Name; >> public const char[] Maker; >> public const char[] Copyright; >> public ulong PortCount; >> public const PortDescriptor[] PortDescriptors; >> public const char[,] PortNames; >> public const PortRangeHint[] PortRangeHints; >> public void[] ImplementationData; >> >> public Descriptor instantiate(Descriptor* descriptor, ulong >> sampleRate); >> >> [CCode (has_target = false)] >> public delegate void connect_port(Descriptor* instance, ulong >> port, double* dataLocation); >> >> public void activate(Descriptor* instance); >> >> public void run(Descriptor* instance, ulong sampleCount); >> >> public void run_adding(Descriptor* instance, ulong sampleCount); >> >> public void set_run_adding_gain(Descriptor* instance, Data gain); >> >> public void deactivate(Descriptor* instance); >> >> public void cleanup(Descriptor* instance); >> } >> >> The valac complaints: >> >> LADSPA.vapi:52.9-52.41: error: unexpected declaration >> public delegate void connect_port(Descriptor* instance, ulong >> port, double* dataLocation); >> >> 2016-09-10 20:18 GMT-03:00 Al Thomas <astav...@yahoo.co.uk>: >> >> From: Victor Aurélio Santos <victoraur.san...@gmail.com> >> >> Sent: Saturday, 10 September 2016, 23:57 >> >> Subject: Re: [Vala] LADSPA bindings >> > >> >> I'm trying to use plugins from vala, not to write! >> >> I'm stuck at writing the vapi file, most specifically at the >> Descriptor struct. >> > >> > >> > Take a look at https://wiki.gnome.org/Projects/Vala/LegacyBindings# >> Binding_a_C_Struct.27s_Fields >> > The function pointers are targetless delegates. There is no >> > >> > memory handling for the struct so I don't think it should be >> > >> > bound as a compact class. >> >> >> >> -- >> Victor Aurélio Santos >> ___ >> vala-list mailing list >> vala-list@gnome.org >> https://mail.gnome.org/mailman/listinfo/vala-list >> > ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
Should not that be (Descriptor instance, ulong port, double? dataLocation) instead? Using asterisk in Vala seems unnatural to me… On Sun, Sep 11, 2016, 18:09 Victor Aurélio Santos < victoraur.san...@gmail.com> wrote: > What I've tried: > > [CCode (copy_function="", destroy_function="")] > public struct Descriptor > { > public ulong UniqueID; > public const char[] Label; > public Properties Properties; > public const char[] Name; > public const char[] Maker; > public const char[] Copyright; > public ulong PortCount; > public const PortDescriptor[] PortDescriptors; > public const char[,] PortNames; > public const PortRangeHint[] PortRangeHints; > public void[] ImplementationData; > > public Descriptor instantiate(Descriptor* descriptor, ulong > sampleRate); > > [CCode (has_target = false)] > public delegate void connect_port(Descriptor* instance, ulong > port, double* dataLocation); > > public void activate(Descriptor* instance); > > public void run(Descriptor* instance, ulong sampleCount); > > public void run_adding(Descriptor* instance, ulong sampleCount); > > public void set_run_adding_gain(Descriptor* instance, Data gain); > > public void deactivate(Descriptor* instance); > > public void cleanup(Descriptor* instance); > } > > The valac complaints: > > LADSPA.vapi:52.9-52.41: error: unexpected declaration > public delegate void connect_port(Descriptor* instance, ulong > port, double* dataLocation); > > 2016-09-10 20:18 GMT-03:00 Al Thomas <astav...@yahoo.co.uk>: > >> From: Victor Aurélio Santos <victoraur.san...@gmail.com> > >> Sent: Saturday, 10 September 2016, 23:57 > >> Subject: Re: [Vala] LADSPA bindings > > > >> I'm trying to use plugins from vala, not to write! > >> I'm stuck at writing the vapi file, most specifically at the Descriptor > struct. > > > > > > Take a look at > https://wiki.gnome.org/Projects/Vala/LegacyBindings#Binding_a_C_Struct.27s_Fields > > The function pointers are targetless delegates. There is no > > > > memory handling for the struct so I don't think it should be > > > > bound as a compact class. > > > > -- > Victor Aurélio Santos > ___ > vala-list mailing list > vala-list@gnome.org > https://mail.gnome.org/mailman/listinfo/vala-list > ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
What I've tried: [CCode (copy_function="", destroy_function="")] public struct Descriptor { public ulong UniqueID; public const char[] Label; public Properties Properties; public const char[] Name; public const char[] Maker; public const char[] Copyright; public ulong PortCount; public const PortDescriptor[] PortDescriptors; public const char[,] PortNames; public const PortRangeHint[] PortRangeHints; public void[] ImplementationData; public Descriptor instantiate(Descriptor* descriptor, ulong sampleRate); [CCode (has_target = false)] public delegate void connect_port(Descriptor* instance, ulong port, double* dataLocation); public void activate(Descriptor* instance); public void run(Descriptor* instance, ulong sampleCount); public void run_adding(Descriptor* instance, ulong sampleCount); public void set_run_adding_gain(Descriptor* instance, Data gain); public void deactivate(Descriptor* instance); public void cleanup(Descriptor* instance); } The valac complaints: LADSPA.vapi:52.9-52.41: error: unexpected declaration public delegate void connect_port(Descriptor* instance, ulong port, double* dataLocation); 2016-09-10 20:18 GMT-03:00 Al Thomas <astav...@yahoo.co.uk>: >> From: Victor Aurélio Santos <victoraur.san...@gmail.com> >> Sent: Saturday, 10 September 2016, 23:57 >> Subject: Re: [Vala] LADSPA bindings > >> I'm trying to use plugins from vala, not to write! >> I'm stuck at writing the vapi file, most specifically at the Descriptor >> struct. > > > Take a look at > https://wiki.gnome.org/Projects/Vala/LegacyBindings#Binding_a_C_Struct.27s_Fields > The function pointers are targetless delegates. There is no > > memory handling for the struct so I don't think it should be > > bound as a compact class. -- Victor Aurélio Santos ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
> From: Victor Aurélio Santos <victoraur.san...@gmail.com> > Sent: Saturday, 10 September 2016, 23:57 > Subject: Re: [Vala] LADSPA bindings > I'm trying to use plugins from vala, not to write! > I'm stuck at writing the vapi file, most specifically at the Descriptor > struct. Take a look at https://wiki.gnome.org/Projects/Vala/LegacyBindings#Binding_a_C_Struct.27s_Fields The function pointers are targetless delegates. There is no memory handling for the struct so I don't think it should be bound as a compact class. ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
I'm trying to use plugins from vala, not to write! I'm stuck at writing the vapi file, most specifically at the Descriptor struct. Em 10 de set de 2016 19:52, "Al Thomas" <astav...@yahoo.co.uk> escreveu: > > > - Original Message - > > From: Victor Aurélio Santos <victoraur.san...@gmail.com> > > Sent: Saturday, 10 September 2016, 23:10 > > Subject: [Vala] LADSPA bindings > > > I'm trying to create LADSPA bindings but no luck. > > I'm stuck at Descriptor's function pointers, can any one help me with > this ? > > > From https://github.com/swh/ladspa/blob/master/ladspa.h this > looks to be a shared object that needs to have a function > called ladspa_descriptor that returns a constant struct > containing details of the plugin. A constant struct seems > fairly standard for plugins. By the way from what I understand > you are saying it is better to describe your problem as a LADSPA > plugin, rather than a LADSPA binding. A binding is using a > library (shared object) and involves writing a VAPI file, whereas > > a plugin is creating a shared object. > > > For an example of a constant struct with function pointers > see the example in https://bugzilla.gnome.org/show_bug.cgi?id=764439 > That example is for GStreamer, but should give you enough clues. > If not please give an example of your code that doesn't work. > > Al > ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] LADSPA bindings
- Original Message - > From: Victor Aurélio Santos <victoraur.san...@gmail.com> > Sent: Saturday, 10 September 2016, 23:10 > Subject: [Vala] LADSPA bindings > I'm trying to create LADSPA bindings but no luck. > I'm stuck at Descriptor's function pointers, can any one help me with this ? From https://github.com/swh/ladspa/blob/master/ladspa.h this looks to be a shared object that needs to have a function called ladspa_descriptor that returns a constant struct containing details of the plugin. A constant struct seems fairly standard for plugins. By the way from what I understand you are saying it is better to describe your problem as a LADSPA plugin, rather than a LADSPA binding. A binding is using a library (shared object) and involves writing a VAPI file, whereas a plugin is creating a shared object. For an example of a constant struct with function pointers see the example in https://bugzilla.gnome.org/show_bug.cgi?id=764439 That example is for GStreamer, but should give you enough clues. If not please give an example of your code that doesn't work. Al ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list