diff options
author | David Anderson <dave@natulte.net> | 2015-08-20 23:08:48 -0700 |
---|---|---|
committer | David Anderson <dave@natulte.net> | 2015-08-21 13:39:50 -0700 |
commit | cf8fa0af80e0d227c79ef2b4635e8d0d77432275 (patch) | |
tree | aa5d09e0d949847240ef50f3da2ad1b99f5cefe2 /callback.go | |
parent | Merge pull request #228 from whiter4bbit/added_icu_support (diff) | |
download | golite-cf8fa0af80e0d227c79ef2b4635e8d0d77432275.tar.gz golite-cf8fa0af80e0d227c79ef2b4635e8d0d77432275.tar.xz |
Implement support for passing Go functions as custom functions to SQLite.
Fixes #226.
Diffstat (limited to '')
-rw-r--r-- | callback.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/callback.go b/callback.go new file mode 100644 index 0000000..938d7fe --- /dev/null +++ b/callback.go @@ -0,0 +1,20 @@ +// Copyright (C) 2014 Yasuhiro Matsumoto <mattn.jp@gmail.com>. +// +// Use of this source code is governed by an MIT-style +// license that can be found in the LICENSE file. + +package sqlite3 + +/* +#include <sqlite3-binding.h> +*/ +import "C" + +import "unsafe" + +//export callbackTrampoline +func callbackTrampoline(ctx *C.sqlite3_context, argc int, argv **C.sqlite3_value) { + args := (*[1 << 30]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc] + fi := (*functionInfo)(unsafe.Pointer(C.sqlite3_user_data(ctx))) + fi.Call(ctx, args) +} |