[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 (
"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)

View File

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

View File

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

View File

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