From 9efa963d05cac8b780d1cb3abbd8493a94f1db82 Mon Sep 17 00:00:00 2001 From: Conor Branagan Date: Sat, 4 Mar 2017 18:15:00 -0500 Subject: [PATCH] [vtable] Rename Context to SQLiteContext To not conflict with core "context" package naming. --- _example/vtable/vtable.go | 4 ++-- context.go => sqlite_context.go | 18 +++++++++--------- vtable.go | 4 ++-- vtable_test.go | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) rename context.go => sqlite_context.go (86%) diff --git a/_example/vtable/vtable.go b/_example/vtable/vtable.go index cc0f308..13e2624 100644 --- a/_example/vtable/vtable.go +++ b/_example/vtable/vtable.go @@ -3,7 +3,7 @@ package main import ( "encoding/json" "fmt" - "github.com/mattn/go-sqlite3" + "github.com/DataDog/go-sqlite3" "io/ioutil" "net/http" ) @@ -73,7 +73,7 @@ type ghRepoCursor struct { repos []GithubRepo } -func (vc *ghRepoCursor) Column(c *sqlite3.Context, col int) error { +func (vc *ghRepoCursor) Column(c *sqlite3.SQLiteContext, col int) error { switch col { case 0: c.ResultInt(vc.repos[vc.index].ID) diff --git a/context.go b/sqlite_context.go similarity index 86% rename from context.go rename to sqlite_context.go index ba943da..7652902 100644 --- a/context.go +++ b/sqlite_context.go @@ -35,10 +35,10 @@ import ( const i64 = unsafe.Sizeof(int(0)) > 4 type ZeroBlobLength int32 -type Context C.sqlite3_context +type SQLiteContext C.sqlite3_context // ResultBool sets the result of an SQL function. -func (c *Context) ResultBool(b bool) { +func (c *SQLiteContext) ResultBool(b bool) { if b { c.ResultInt(1) } else { @@ -48,7 +48,7 @@ func (c *Context) ResultBool(b bool) { // ResultBlob sets the result of an SQL function. // See: sqlite3_result_blob, http://sqlite.org/c3ref/result_blob.html -func (c *Context) ResultBlob(b []byte) { +func (c *SQLiteContext) ResultBlob(b []byte) { if i64 && len(b) > math.MaxInt32 { C.sqlite3_result_error_toobig((*C.sqlite3_context)(c)) return @@ -62,13 +62,13 @@ func (c *Context) ResultBlob(b []byte) { // ResultDouble sets the result of an SQL function. // See: sqlite3_result_double, http://sqlite.org/c3ref/result_blob.html -func (c *Context) ResultDouble(d float64) { +func (c *SQLiteContext) ResultDouble(d float64) { C.sqlite3_result_double((*C.sqlite3_context)(c), C.double(d)) } // ResultInt sets the result of an SQL function. // See: sqlite3_result_int, http://sqlite.org/c3ref/result_blob.html -func (c *Context) ResultInt(i int) { +func (c *SQLiteContext) ResultInt(i int) { if i64 && (i > math.MaxInt32 || i < math.MinInt32) { C.sqlite3_result_int64((*C.sqlite3_context)(c), C.sqlite3_int64(i)) } else { @@ -78,19 +78,19 @@ func (c *Context) ResultInt(i int) { // ResultInt64 sets the result of an SQL function. // See: sqlite3_result_int64, http://sqlite.org/c3ref/result_blob.html -func (c *Context) ResultInt64(i int64) { +func (c *SQLiteContext) ResultInt64(i int64) { C.sqlite3_result_int64((*C.sqlite3_context)(c), C.sqlite3_int64(i)) } // ResultNull sets the result of an SQL function. // See: sqlite3_result_null, http://sqlite.org/c3ref/result_blob.html -func (c *Context) ResultNull() { +func (c *SQLiteContext) ResultNull() { C.sqlite3_result_null((*C.sqlite3_context)(c)) } // ResultText sets the result of an SQL function. // See: sqlite3_result_text, http://sqlite.org/c3ref/result_blob.html -func (c *Context) ResultText(s string) { +func (c *SQLiteContext) ResultText(s string) { h := (*reflect.StringHeader)(unsafe.Pointer(&s)) cs, l := (*C.char)(unsafe.Pointer(h.Data)), C.int(h.Len) C.my_result_text((*C.sqlite3_context)(c), cs, l) @@ -98,6 +98,6 @@ func (c *Context) ResultText(s string) { // ResultZeroblob sets the result of an SQL function. // See: sqlite3_result_zeroblob, http://sqlite.org/c3ref/result_blob.html -func (c *Context) ResultZeroblob(n ZeroBlobLength) { +func (c *SQLiteContext) ResultZeroblob(n ZeroBlobLength) { C.sqlite3_result_zeroblob((*C.sqlite3_context)(c), C.int(n)) } diff --git a/vtable.go b/vtable.go index 907e2dc..40ce2ea 100644 --- a/vtable.go +++ b/vtable.go @@ -294,7 +294,7 @@ func goVEof(pCursor unsafe.Pointer) C.int { //export goVColumn func goVColumn(pCursor, cp unsafe.Pointer, col int) *C.char { vtc := lookupHandle(uintptr(pCursor)).(*sqliteVTabCursor) - c := (*Context)(cp) + c := (*SQLiteContext)(cp) err := vtc.vTabCursor.Column(c, col) if err != nil { return mPrintf("%s", err.Error()) @@ -349,7 +349,7 @@ type VTabCursor interface { // http://sqlite.org/vtab.html#xeof EOF() bool // http://sqlite.org/vtab.html#xcolumn - Column(c *Context, col int) error + Column(c *SQLiteContext, col int) error // http://sqlite.org/vtab.html#xrowid Rowid() (int64, error) } diff --git a/vtable_test.go b/vtable_test.go index 4c7efcb..9b97927 100644 --- a/vtable_test.go +++ b/vtable_test.go @@ -94,7 +94,7 @@ func (vc *testVTabCursor) EOF() bool { return vc.index >= len(vc.vTab.intarray) } -func (vc *testVTabCursor) Column(c *Context, col int) error { +func (vc *testVTabCursor) Column(c *SQLiteContext, col int) error { if col != 0 { return fmt.Errorf("column index out of bounds: %d", col) }