[Vala] Manual VAPI writing
- From: Harry Van Haaren <harryhaaren gmail com>
- To: vala-list gnome org
- Subject: [Vala] Manual VAPI writing
- Date: Tue, 29 Jun 2010 19:17:21 +0100
Hey all,
I'm attempting to learn how to write .vapi files manually. I've looked
trough
the Jack binding, the GTK+ binding and the sfml bindings.
Yet im stumped as to how to write a wrapper for the dead-simple function
(declared in a file called bindMe.h):
*int add (int a, int b)
{
return (a + b);
}*
In my attempt I've tried the following:
*[CCode (cheader_filename="bindMe.h")]
namespace Math
{
public class AddStuff
{
public AddStuff();
[CCode (cname="add")]
public static int add (int a, int b);
}
}*
And to see if the binding worked had a .vala file (test.vala) which contains
the following:
*int main()
{
var func = new Math.AddStuff();
return 0;
}*
I have the bindMe.h installed in /usr/include, the .vapi is in the same dir
as test.vala
Command used to compile:* valac --save-temps --vapidir=./ --pkg binding
test.vala*
And its output:
test.vala:4.6-4.31: warning: local variable `func' declared but never used
var func = new Math.AddStuff();
^^^^^^^^^^^^^^^^^^^
/home/harry/programming/vala/bindingTrial/test.c: In function ‘_vala_main’:
/home/harry/programming/vala/bindingTrial/test.c:19: error: ‘MathAddStuff’
undeclared (first use in this function)
/home/harry/programming/vala/bindingTrial/test.c:19: error: (Each undeclared
identifier is reported only once
/home/harry/programming/vala/bindingTrial/test.c:19: error: for each
function it appears in.)
/home/harry/programming/vala/bindingTrial/test.c:19: error: ‘func’
undeclared (first use in this function)
Am I doing something fundamentally wrong? Or would this approach usually be
ok?
Hope somebody can help me learn how to write bindings,I'm eyeing up some
nice audio libraries.. ;-) -Harry
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]