Re: [Vala] [newbie] Creating a VAPI for a raw C library



2011/2/28 Jens Georg <mail jensge org>:
On Mon, 2011-02-28 at 09:09 +0100, Guilhem Bonnefille wrote:
/* API */
typedef void*lib_type_t;
void init(lib_type_t *p);
void get(lib_type_t p, char **val);

/* USE */
...
lib_type_t myType;
char *val;
lib_init(&myType);
lib_get(myType, &val);

(take with a grain of salt, typed from memory)

[CCode (c_prefix="lib_")]
namespace MyLib {
   [Compact]
   [CCode (c_prefix="lib_")]
   class MyType {
       static void init (out MyType instance);
       int @get(out string val);
   }
}

MyType foo;
string val;
MyType.init(out foo);
foo.get(out val);

You should have a look at the SQLite vapi.

Thanks a lot for this quick answer.
I will try this tonight.

-- 
Guilhem BONNEFILLE
-=- JID: guyou im apinc org MSN: guilhem_bonnefille hotmail com
-=- mailto:guilhem bonnefille gmail com
-=- http://nathguil.free.fr/



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