I need to use the Sqlite vapi without any depedence on GLib. SQlite is non-gobject library, so it should be possible to do that.
However, when I try to compile the following file with the --profile posix
option,
using Sqlite;
void main() {
stdout.printf("Hello, World!");
}
I get am error messages:
sqlite3.vapi:357.56-357.59: error: The symbol `GLib' could not be found
public int bind_blob (int index, void* value, int n,
GLib.DestroyNotify destroy_notify);
^^^^
sqlite3.vapi:362.68-362.71: error: The symbol `GLib' could not be found
public int bind_text (int index, owned string value, int n = -1,
GLib.DestroyNotify destroy_notify = GLib.g_free);
^^^^
sqlite3.vapi:411.42-411.45: error: The symbol `GLib' could not be found
public void result_blob (uint8[] data, GLib.DestroyNotify?
destroy_notify = GLib.g_free);
开发者_C百科 ^^^^
sqlite3.vapi:420.59-420.62: error: The symbol `GLib' could not be found
public void result_text (string value, int length = -1,
GLib.DestroyNotify? destroy_notify = GLib.g_free);
^^^^
Compilation failed: 4 error(s), 0 warning(s)
It seems that several of the functions defined in the sqlite vapi make references to the GLib.g_free
and GLib.DestroyNotify
symbols. Are there any posix alternatives to those?
That should be fairly simple to solve, and I can imagine several solutions.
It boils down to declaring a different delegate void DestroyNotify (void* data) (either in the posix.vapi or sqlite3.vapi) and bind free() in posix.vapi.
The problem is the namespace, and you might need to file a bug and discuss it with the developers. If you want to avoid this problem and are ready to go with a workaround, just create a mini glib.vapi GLib namespace, where you bind only the DestroyNotify() and g_free() (binding to libc/posix free).
I would think that sqlite3 should not use GLib, but rather libc/posix, so you should be fine by modifying only posix.vapi and sqlite3.vapi and filing a bug with your patch (awesome, a contrib!).
Note that classes are unavailable under the POSIX profile, as Vala requires a support library (i.e. GLib, Dova) to support those features. Jürg Billeter has acknowledged that support for the POSIX profile is experimental and limited:
https://bugzilla.gnome.org/show_bug.cgi?id=618348
The only way you have is re-writing the sqlite VAPI (or just the classes/methods you need) making them posix friendly (but I guess you can't use classes in that way).
if the vapi for sqlite depends on glib you could just write your own or use the sqlite c code with c and just make some extern statements for the functions you need. for example i made a tool wich mixes vala and c for linux pure c for win32 and objective c and c for mac https://github.com/boscowitch/wadoku-notify i just added the 2 functions i need at the beginning of my vala app like this:
extern void init_db(char * path,bool mm);
extern void lookup(char * str);
i added the whole sqlite source cause i needed to activate full text indexing and change a bit in the code and in the beginning of vala there was no sqlite vapi
精彩评论