Implement support for passing Go functions as custom functions to SQLite.

Fixes #226.
This commit is contained in:
David Anderson
2015-08-20 23:08:48 -07:00
parent 8897bf1452
commit cf8fa0af80
5 changed files with 342 additions and 6 deletions

20
callback.go Normal file
View File

@@ -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)
}