[vtable] Rename Context to SQLiteContext

To not conflict with core "context" package naming.
This commit is contained in:
Conor Branagan 2017-03-04 18:15:00 -05:00
parent 618e784627
commit 9efa963d05
4 changed files with 14 additions and 14 deletions

View File

@ -3,7 +3,7 @@ package main
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/mattn/go-sqlite3" "github.com/DataDog/go-sqlite3"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
) )
@ -73,7 +73,7 @@ type ghRepoCursor struct {
repos []GithubRepo repos []GithubRepo
} }
func (vc *ghRepoCursor) Column(c *sqlite3.Context, col int) error { func (vc *ghRepoCursor) Column(c *sqlite3.SQLiteContext, col int) error {
switch col { switch col {
case 0: case 0:
c.ResultInt(vc.repos[vc.index].ID) c.ResultInt(vc.repos[vc.index].ID)

View File

@ -35,10 +35,10 @@ import (
const i64 = unsafe.Sizeof(int(0)) > 4 const i64 = unsafe.Sizeof(int(0)) > 4
type ZeroBlobLength int32 type ZeroBlobLength int32
type Context C.sqlite3_context type SQLiteContext C.sqlite3_context
// ResultBool sets the result of an SQL function. // ResultBool sets the result of an SQL function.
func (c *Context) ResultBool(b bool) { func (c *SQLiteContext) ResultBool(b bool) {
if b { if b {
c.ResultInt(1) c.ResultInt(1)
} else { } else {
@ -48,7 +48,7 @@ func (c *Context) ResultBool(b bool) {
// ResultBlob sets the result of an SQL function. // ResultBlob sets the result of an SQL function.
// See: sqlite3_result_blob, http://sqlite.org/c3ref/result_blob.html // 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 { if i64 && len(b) > math.MaxInt32 {
C.sqlite3_result_error_toobig((*C.sqlite3_context)(c)) C.sqlite3_result_error_toobig((*C.sqlite3_context)(c))
return return
@ -62,13 +62,13 @@ func (c *Context) ResultBlob(b []byte) {
// ResultDouble sets the result of an SQL function. // ResultDouble sets the result of an SQL function.
// See: sqlite3_result_double, http://sqlite.org/c3ref/result_blob.html // 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)) C.sqlite3_result_double((*C.sqlite3_context)(c), C.double(d))
} }
// ResultInt sets the result of an SQL function. // ResultInt sets the result of an SQL function.
// See: sqlite3_result_int, http://sqlite.org/c3ref/result_blob.html // 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) { if i64 && (i > math.MaxInt32 || i < math.MinInt32) {
C.sqlite3_result_int64((*C.sqlite3_context)(c), C.sqlite3_int64(i)) C.sqlite3_result_int64((*C.sqlite3_context)(c), C.sqlite3_int64(i))
} else { } else {
@ -78,19 +78,19 @@ func (c *Context) ResultInt(i int) {
// ResultInt64 sets the result of an SQL function. // ResultInt64 sets the result of an SQL function.
// See: sqlite3_result_int64, http://sqlite.org/c3ref/result_blob.html // 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)) C.sqlite3_result_int64((*C.sqlite3_context)(c), C.sqlite3_int64(i))
} }
// ResultNull sets the result of an SQL function. // ResultNull sets the result of an SQL function.
// See: sqlite3_result_null, http://sqlite.org/c3ref/result_blob.html // 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)) C.sqlite3_result_null((*C.sqlite3_context)(c))
} }
// ResultText sets the result of an SQL function. // ResultText sets the result of an SQL function.
// See: sqlite3_result_text, http://sqlite.org/c3ref/result_blob.html // 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)) h := (*reflect.StringHeader)(unsafe.Pointer(&s))
cs, l := (*C.char)(unsafe.Pointer(h.Data)), C.int(h.Len) cs, l := (*C.char)(unsafe.Pointer(h.Data)), C.int(h.Len)
C.my_result_text((*C.sqlite3_context)(c), cs, l) 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. // ResultZeroblob sets the result of an SQL function.
// See: sqlite3_result_zeroblob, http://sqlite.org/c3ref/result_blob.html // 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)) C.sqlite3_result_zeroblob((*C.sqlite3_context)(c), C.int(n))
} }

View File

@ -294,7 +294,7 @@ func goVEof(pCursor unsafe.Pointer) C.int {
//export goVColumn //export goVColumn
func goVColumn(pCursor, cp unsafe.Pointer, col int) *C.char { func goVColumn(pCursor, cp unsafe.Pointer, col int) *C.char {
vtc := lookupHandle(uintptr(pCursor)).(*sqliteVTabCursor) vtc := lookupHandle(uintptr(pCursor)).(*sqliteVTabCursor)
c := (*Context)(cp) c := (*SQLiteContext)(cp)
err := vtc.vTabCursor.Column(c, col) err := vtc.vTabCursor.Column(c, col)
if err != nil { if err != nil {
return mPrintf("%s", err.Error()) return mPrintf("%s", err.Error())
@ -349,7 +349,7 @@ type VTabCursor interface {
// http://sqlite.org/vtab.html#xeof // http://sqlite.org/vtab.html#xeof
EOF() bool EOF() bool
// http://sqlite.org/vtab.html#xcolumn // http://sqlite.org/vtab.html#xcolumn
Column(c *Context, col int) error Column(c *SQLiteContext, col int) error
// http://sqlite.org/vtab.html#xrowid // http://sqlite.org/vtab.html#xrowid
Rowid() (int64, error) Rowid() (int64, error)
} }

View File

@ -94,7 +94,7 @@ func (vc *testVTabCursor) EOF() bool {
return vc.index >= len(vc.vTab.intarray) 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 { if col != 0 {
return fmt.Errorf("column index out of bounds: %d", col) return fmt.Errorf("column index out of bounds: %d", col)
} }