mv x/ => c/

This commit is contained in:
xushiwei
2024-05-17 22:33:57 +08:00
parent 367743530f
commit 087ba0d81d
20 changed files with 195 additions and 312 deletions

View File

@@ -1,35 +0,0 @@
LLGo wrapper of DaveGamble/cJSON
=====
[![Build Status](https://github.com/goplus/cjson/actions/workflows/go.yml/badge.svg)](https://github.com/goplus/cjson/actions/workflows/go.yml)
[![GitHub release](https://img.shields.io/github/v/tag/goplus/cjson.svg?label=release)](https://github.com/goplus/cjson/releases)
[![GoDoc](https://pkg.go.dev/badge/github.com/goplus/cjson.svg)](https://pkg.go.dev/github.com/goplus/cjson)
[![Compiler](https://img.shields.io/badge/compiler-llgo-darkgreen.svg)](https://github.com/goplus/llgo)
[![Language](https://img.shields.io/badge/language-Go+-blue.svg)](https://github.com/goplus/gop)
## How to install
```sh
git clone https://github.com/goplus/cjson.git
cd cjson
git submodule init
git submodule update
mkdir build.dir
cd build.dir
cmake ../cJSON
sudo make install
```
## Demos
The `_demo` directory contains our demos (it start with `_` to prevent the `go` command from compiling it):
* [mkjson](_demo/mkjson/mkjson.go): create a json object and print it
### How to run demos
To run the demos in directory `_demo`:
```sh
cd <demo-directory> # eg. cd _demo/mkjson
llgo run .
```

View File

@@ -1,27 +0,0 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/x/cjson"
)
func main() {
mod := cjson.Object()
mod.SetItem(c.Str("name"), cjson.String(c.Str("math")))
syms := cjson.Array()
fn := cjson.Object()
fn.SetItem(c.Str("name"), cjson.String(c.Str("sqrt")))
fn.SetItem(c.Str("sig"), cjson.String(c.Str("(x, /)")))
syms.AddItem(fn)
v := cjson.Object()
v.SetItem(c.Str("name"), cjson.String(c.Str("pi")))
syms.AddItem(v)
mod.SetItem(c.Str("items"), syms)
c.Printf(c.Str("%s\n"), mod.CStr())
mod.Delete()
}

View File

@@ -1,121 +0,0 @@
/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cjson
import (
_ "unsafe"
"github.com/goplus/llgo/c"
)
const (
LLGoPackage = "link: cjson"
)
// llgo:type C
type JSON struct {
Unused [0]byte
}
//go:linkname Null C.cJSON_CreateNull
func Null() *JSON
//go:linkname True C.cJSON_CreateTrue
func True() *JSON
//go:linkname False C.cJSON_CreateFalse
func False() *JSON
//go:linkname Bool C.cJSON_CreateBool
func Bool(boolean c.Int) *JSON
//go:linkname Number C.cJSON_CreateNumber
func Number(num float64) *JSON
//go:linkname String C.cJSON_CreateString
func String(str *c.Char) *JSON
//go:linkname Array C.cJSON_CreateArray
func Array() *JSON
//go:linkname Object C.cJSON_CreateObject
func Object() *JSON
// raw json
//
//go:linkname Raw C.cJSON_CreateRaw
func Raw(raw *c.Char) *JSON
// Create a string where valuestring references a string so
// it will not be freed by Delete
//
//go:linkname StringRef C.cJSON_CreateStringReference
func StringRef(str *c.Char) *JSON
// Create an object that only references it's elements so
// they will not be freed by Delete
//
//go:linkname ObjectRef C.cJSON_CreateObjectReference
func ObjectRef(child *JSON) *JSON
// Create an array that only references it's elements so
// they will not be freed by Delete
//
//go:linkname ArrayRef C.cJSON_CreateArrayReference
func ArrayRef(child *JSON) *JSON
// Delete a JSON entity and all subentities.
//
// llgo:link (*JSON).Delete C.cJSON_Delete
func (o *JSON) Delete() {}
// Append item to the specified array.
//
// llgo:link (*JSON).AddItem C.cJSON_AddItemToArray
func (o *JSON) AddItem(item *JSON) c.Int { return 0 }
// Append item to the specified object.
//
// llgo:link (*JSON).SetItem C.cJSON_AddItemToObject
func (o *JSON) SetItem(key *c.Char, item *JSON) c.Int { return 0 }
// llgo:link (*JSON).CStr C.cJSON_PrintUnformatted
func (o *JSON) CStr() *c.Char { return nil }
// Same as CStr. Provided for Go+.
//
// llgo:link (*JSON).Cstr C.cJSON_PrintUnformatted
func (o *JSON) Cstr() *c.Char { return nil }
// Render a JSON entity to text for transfer/storage.
//
// llgo:link (*JSON).Print C.cJSON_Print
func (o *JSON) Print() *c.Char { return nil }
// Render a JSON entity to text for transfer/storage without any formatting.
//
// llgo:link (*JSON).PrintUnformatted C.cJSON_PrintUnformatted
func (o *JSON) PrintUnformatted() *c.Char { return nil }
// Render a JSON entity to text using a buffered strategy.
//
// prebuffer is a guess at the final size. guessing well reduces reallocation.
//
// fmt=0 gives unformatted, =1 gives formatted.
//
// llgo:link (*JSON).PrintBuffered C.cJSON_PrintBuffered
func (o *JSON) PrintBuffered(prebuffer c.Int, fmt c.Int) *c.Char { return nil }

Binary file not shown.

26
x/llama2/.gitignore vendored
View File

@@ -1,26 +0,0 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
stories*.bin
.DS_Store
err.log
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
*.swp
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace file
go.work*

View File

@@ -1,268 +0,0 @@
/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package llama2
import (
_ "unsafe"
"github.com/goplus/llgo/c"
)
const (
LLGoPackage = "link"
)
type (
Char = c.Char
Int = c.Int
Uint = c.Uint
Float = c.Float
)
// -----------------------------------------------------------------------------
/*
typedef struct {
char *str;
int id;
} TokenIndex;
typedef struct {
char** vocab;
float* vocab_scores;
TokenIndex *sorted_vocab;
int vocab_size;
unsigned int max_token_length;
unsigned char byte_pieces[512]; // stores all single-byte strings
} Tokenizer;
void build_tokenizer(Tokenizer* t, char* tokenizer_path, int vocab_size);
void free_tokenizer(Tokenizer* t);
typedef struct {
int dim; // transformer dimension
int hidden_dim; // for ffn layers
int n_layers; // number of layers
int n_heads; // number of query heads
int n_kv_heads; // number of key/value heads (can be < query heads because of multiquery)
int vocab_size; // vocabulary size, usually 256 (byte-level)
int seq_len; // max sequence length
} Config;
typedef struct {
// token embedding table
float* token_embedding_table; // (vocab_size, dim)
// weights for rmsnorms
float* rms_att_weight; // (layer, dim) rmsnorm weights
float* rms_ffn_weight; // (layer, dim)
// weights for matmuls. note dim == n_heads * head_size
float* wq; // (layer, dim, n_heads * head_size)
float* wk; // (layer, dim, n_kv_heads * head_size)
float* wv; // (layer, dim, n_kv_heads * head_size)
float* wo; // (layer, n_heads * head_size, dim)
// weights for ffn
float* w1; // (layer, hidden_dim, dim)
float* w2; // (layer, dim, hidden_dim)
float* w3; // (layer, hidden_dim, dim)
// final rmsnorm
float* rms_final_weight; // (dim,)
// (optional) classifier weights for the logits, on the last layer
float* wcls;
} TransformerWeights;
typedef struct {
// current wave of activations
float *x; // activation at current time stamp (dim,)
float *xb; // same, but inside a residual branch (dim,)
float *xb2; // an additional buffer just for convenience (dim,)
float *hb; // buffer for hidden dimension in the ffn (hidden_dim,)
float *hb2; // buffer for hidden dimension in the ffn (hidden_dim,)
float *q; // query (dim,)
float *k; // key (dim,)
float *v; // value (dim,)
float *att; // buffer for scores/attention values (n_heads, seq_len)
float *logits; // output logits
// kv cache
float* key_cache; // (layer, seq_len, dim)
float* value_cache; // (layer, seq_len, dim)
} RunState;
typedef struct {
Config config; // the hyperparameters of the architecture (the blueprint)
TransformerWeights weights; // the weights of the model
RunState state; // buffers for the "wave" of activations in the forward pass
// some more state needed to properly clean up the memory mapping (sigh)
int fd; // file descriptor for memory mapping
float* data; // memory mapped data pointer
ssize_t file_size; // size of the checkpoint file in bytes
} Transformer;
void build_transformer(Transformer *t, char* checkpoint_path);
void free_transformer(Transformer* t);
typedef struct {
float prob;
int index;
} ProbIndex; // struct used when sorting probabilities during top-p sampling
typedef struct {
int vocab_size;
ProbIndex* probindex; // buffer used in top-p sampling
float temperature;
float topp;
unsigned long long rng_state;
} Sampler;
void build_sampler(Sampler* sampler, int vocab_size, float temperature, float topp, unsigned long long rng_seed);
void free_sampler(Sampler* sampler);
void generate(Transformer *transformer, Tokenizer *tokenizer, Sampler *sampler, char *prompt, int steps);
*/
// -----------------------------------------------------------------------------
// llgo:type C
type TokenIndex struct {
Str *Char
Id Int
}
// llgo:type C
type Tokenizer struct {
Vocab **Char
VocabScores *Float
SortedVocab *TokenIndex
VocabSize Int
MaxTokenLength Uint
BytePieces [512]uint8 // stores all single-byte strings
}
//go:linkname BuildTokenizer C.build_tokenizer
func BuildTokenizer(t *Tokenizer, tokenizerPath *Char, vocabSize Int)
//go:linkname FreeTokenizer C.free_tokenizer
func FreeTokenizer(t *Tokenizer)
// -----------------------------------------------------------------------------
// llgo:type C
type Config struct {
Dim Int // transformer dimension
HiddenDim Int // for ffn layers
NLayers Int // number of layers
NHeads Int // number of query heads
NKVHeads Int // number of key/value heads (can be < query heads because of multiquery)
VocabSize Int // vocabulary size, usually 256 (byte-level)
SeqLen Int // max sequence length
}
// llgo:type C
type TransformerWeights struct {
// token embedding table
TokenEmbeddingTable *Float // (vocab_size, dim)
// weights for rmsnorms
RmsAttWeight *Float // (layer, dim) rmsnorm weights
RmsFfnWeight *Float // (layer, dim)
// weights for matmuls. note dim == n_heads * head_size
Wq *Float // (layer, dim, n_heads * head_size)
Wk *Float // (layer, dim, n_kv_heads * head_size)
Wv *Float // (layer, dim, n_kv_heads * head_size)
Wo *Float // (layer, n_heads * head_size, dim)
// weights for ffn
W1 *Float // (layer, hidden_dim, dim)
W2 *Float // (layer, dim, hidden_dim)
W3 *Float // (layer, hidden_dim, dim)
// final rmsnorm
RmsFinalWeight *Float // (dim,)
// (optional) classifier weights for the logits, on the last layer
Wcls *Float
}
// llgo:type C
type RunState struct {
// current wave of activations
X *Float // activation at current time stamp (dim,)
Xb *Float // same, but inside a residual branch (dim,)
Xb2 *Float // an additional buffer just for convenience (dim,)
Hb *Float // buffer for hidden dimension in the ffn (hidden_dim,)
Hb2 *Float // buffer for hidden dimension in the ffn (hidden_dim,)
Q *Float // query (dim,)
K *Float // key (dim,)
V *Float // value (dim,)
Att *Float // buffer for scores/attention values (n_heads, seq_len)
Logits *Float // output logits
// kv cache
KeyCache *Float // (layer, seq_len, dim)
ValueCache *Float // (layer, seq_len, dim)
}
// llgo:type C
type Transformer struct {
Config Config // the hyperparameters of the architecture (the blueprint)
Weights TransformerWeights // the weights of the model
State RunState // buffers for the "wave" of activations in the forward pass
// some more state needed to properly clean up the memory mapping (sigh)
Fd Int // file descriptor for memory mapping
Data *Float // memory mapped data pointer
FileSize uintptr // size of the checkpoint file in bytes
}
//go:linkname BuildTransformer C.build_transformer
func BuildTransformer(t *Transformer, checkpointPath *Char)
//go:linkname FreeTransformer C.free_transformer
func FreeTransformer(t *Transformer)
// -----------------------------------------------------------------------------
// llgo:type C
type ProbIndex struct {
Prob Float
Index Int
} // struct used when sorting probabilities during top-p sampling
// llgo:type C
type Sampler struct {
VocabSize Int
Probindex *ProbIndex // buffer used in top-p sampling
Temperature Float
Topp Float
RngState uint64
}
//go:linkname BuildSampler C.build_sampler
func BuildSampler(sampler *Sampler, vocabSize Int, temperature Float, topp Float, rngSeed uint64)
//go:linkname FreeSampler C.free_sampler
func FreeSampler(sampler *Sampler)
// -----------------------------------------------------------------------------
//go:linkname Generate C.generate
func Generate(
transformer *Transformer, tokenizer *Tokenizer, sampler *Sampler,
prompt *Char, steps Int)
//go:linkname Chat C.chat
func Chat(
transformer *Transformer, tokenizer *Tokenizer, sampler *Sampler,
cliUserPrompt *Char, cliSystemPrompt *Char, steps Int)
// -----------------------------------------------------------------------------

View File

@@ -1,2 +0,0 @@
#define TESTING
#include "../llama2.c/run.c"

View File

@@ -1,6 +0,0 @@
{
"cl": [
"clang -emit-llvm -S -o llgo_autogen.ll -c llama2/run.c",
"zip llgo_autogen.lla llgo_autogen.ll"
]
}

Binary file not shown.

View File

@@ -1,35 +0,0 @@
LLGo wrapper of sqlite
=====
[![Build Status](https://github.com/goplus/sqlite/actions/workflows/go.yml/badge.svg)](https://github.com/goplus/sqlite/actions/workflows/go.yml)
[![GitHub release](https://img.shields.io/github/v/tag/goplus/sqlite.svg?label=release)](https://github.com/goplus/sqlite/releases)
[![GoDoc](https://pkg.go.dev/badge/github.com/goplus/sqlite.svg)](https://pkg.go.dev/github.com/goplus/sqlite)
[![Compiler](https://img.shields.io/badge/compiler-llgo-darkgreen.svg)](https://github.com/goplus/llgo)
[![Language](https://img.shields.io/badge/language-Go+-blue.svg)](https://github.com/goplus/gop)
## How to install
```sh
git clone https://github.com/goplus/sqlite.git
cd sqlite
git submodule init
git submodule update
mkdir build.dir
cd build.dir
../sqlite/configure --enable-shared
sudo make install
```
## Demos
The `_demo` directory contains our demos (it start with `_` to prevent the `go` command from compiling it):
* [sqlitedemo](_demo/sqlitedemo/demo.go): a basic sqlite demo
### How to run demos
To run the demos in directory `_demo`:
```sh
cd <demo-directory> # eg. cd _demo/sqlitedemo
llgo run .
```

View File

@@ -1,61 +0,0 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/x/sqlite"
)
func main() {
c.Remove(c.Str("test.db"))
db, err := sqlite.Open(c.Str("test.db"))
check(err, db, "sqlite: Open")
err = db.Exec(c.Str("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)"), nil, nil, nil)
check(err, db, "sqlite: Exec CREATE TABLE")
stmt, err := db.PrepareV3("INSERT INTO users (id, name) VALUES (?, ?)", 0, nil)
check(err, db, "sqlite: PrepareV3 INSERT")
stmt.BindInt(1, 100)
stmt.BindText(2, c.Str("Hello World"), -1, nil)
err = stmt.Step()
checkDone(err, db, "sqlite: Step INSERT 1")
stmt.Reset()
stmt.BindInt(1, 200)
stmt.BindText(2, c.Str("This is llgo"), -1, nil)
err = stmt.Step()
checkDone(err, db, "sqlite: Step INSERT 2")
stmt.Close()
stmt, err = db.PrepareV3("SELECT * FROM users", 0, nil)
check(err, db, "sqlite: PrepareV3 SELECT")
for {
if err = stmt.Step(); err != sqlite.HasRow {
break
}
c.Printf(c.Str("==> id=%d, name=%s\n"), stmt.ColumnInt(0), stmt.ColumnText(1))
}
checkDone(err, db, "sqlite: Step done")
stmt.Close()
db.Close()
}
func check(err sqlite.Errno, db *sqlite.Sqlite3, at string) {
if err != sqlite.OK {
c.Printf(c.Str("==> %s Error: (%d) %s\n"), c.AllocaCStr(at), err, db.Errmsg())
c.Exit(1)
}
}
func checkDone(err sqlite.Errno, db *sqlite.Sqlite3, at string) {
if err != sqlite.Done {
check(err, db, at)
}
}

Binary file not shown.

View File

@@ -1,266 +0,0 @@
/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sqlite
import (
_ "unsafe"
"github.com/goplus/llgo/c"
)
type (
Char = c.Char
Int = c.Int
Pointer = c.Pointer
)
const (
LLGoPackage = "link: sqlite3"
)
// llgo:type C
type Sqlite3 struct {
Unused [8]byte
}
// llgo:type C
type Stmt struct {
Unused [8]byte
}
// -----------------------------------------------------------------------------
type Errno Int
const (
OK Errno = 0 // Successful result
Error Errno = 1 // Generic error
ErrInternal Errno = 2 // Internal logic error in SQLite
ErrPerm Errno = 3 // Access permission denied
ErrAbort Errno = 4 // Callback routine requested an abort
ErrBusy Errno = 5 // The database file is locked
ErrLocked Errno = 6 // A table in the database is locked
ErrNomem Errno = 7 // A malloc() failed
ErrReadOnly Errno = 8 // Attempt to write a readonly database
ErrInterrupt Errno = 9 // Operation terminated by sqlite3_interrupt()
ErrIo Errno = 10 // Some kind of disk I/O error occurred
ErrCorrupt Errno = 11 // The database disk image is malformed
ErrNotfound Errno = 12 // Unknown opcode in sqlite3_file_control()
ErrFull Errno = 13 // Insertion failed because database is full
ErrCantopen Errno = 14 // Unable to open the database file
ErrProtocol Errno = 15 // Database lock protocol error
_ErrEmpty Errno = 16 // Internal use only
ErrSchema Errno = 17 // The database schema changed
ErrToobig Errno = 18 // String or BLOB exceeds size limit
ErrConstraint Errno = 19 // Abort due to constraint violation
ErrMismatch Errno = 20 // Data type mismatch
ErrMisuse Errno = 21 // Library used incorrectly
ErrNolfs Errno = 22 // Uses OS features not supported on host
ErrAuth Errno = 23 // Authorization denied
_ErrFormat Errno = 24 // Not used
ErrRange Errno = 25 // 2nd parameter to sqlite3_bind out of range
ErrNotadb Errno = 26 // File opened that is not a database file
ErrNotice Errno = 27 // Notifications from sqlite3_log()
ErrWarning Errno = 28 // Warnings from sqlite3_log()
HasRow Errno = 100 // sqlite3_step() has another row ready
Done Errno = 101 // sqlite3_step() has finished executing
)
// llgo:link (Errno).Errstr C.sqlite3_errstr
func (err Errno) Errstr() *Char { return nil }
// llgo:link (*Sqlite3).Errmsg C.sqlite3_errmsg
func (db *Sqlite3) Errmsg() *Char { return nil }
// llgo:link (*Sqlite3).Errcode C.sqlite3_errcode
func (db *Sqlite3) Errcode() Errno { return 0 }
// llgo:link (*Sqlite3).ExtendedErrcode C.sqlite3_extended_errcode
func (db *Sqlite3) ExtendedErrcode() Errno { return 0 }
// -----------------------------------------------------------------------------
//go:linkname doOpen C.sqlite3_open
func doOpen(filename *Char, ppDb **Sqlite3) Errno
//go:linkname doOpenV2 C.sqlite3_open_v2
func doOpenV2(filename *Char, ppDb **Sqlite3, flags OpenFlags, zVfs *Char) Errno
// OpenFlags represents SQLite open flags.
type OpenFlags Int
const (
OpenReadOnly OpenFlags = 0x00000001
OpenReadWrite OpenFlags = 0x00000002
OpenCreate OpenFlags = 0x00000004
OpenDeleteOnClose OpenFlags = 0x00000008 // VFS only
OpenExclusive OpenFlags = 0x00000010 // VFS only
OpenAutoProxy OpenFlags = 0x00000020 // VFS only
OpenUri OpenFlags = 0x00000040
OpenMemory OpenFlags = 0x00000080
OpenMainDb OpenFlags = 0x00000100 // VFS only
OpenTempDb OpenFlags = 0x00000200 // VFS only
OpenTransientDb OpenFlags = 0x00000400 // VFS only
OpenMainJournal OpenFlags = 0x00000800 // VFS only
OpenTempJournal OpenFlags = 0x00001000 // VFS only
OpenSubJournal OpenFlags = 0x00002000 // VFS only
OpenSuperJournal OpenFlags = 0x00004000 // VFS only
OpenNoMutex OpenFlags = 0x00008000
OpenFullMutex OpenFlags = 0x00010000
OpenSharedCache OpenFlags = 0x00020000
OpenPrivateCache OpenFlags = 0x00040000
OpenWal OpenFlags = 0x00080000 // VFS only
OpenNoFollow OpenFlags = 0x01000000
OpenExResCode OpenFlags = 0x02000000 // Extended result codes
)
// Opening A New Database Connection
// filename: Database filename (UTF-8)
func Open(filename *Char) (db *Sqlite3, err Errno) {
err = doOpen(filename, &db)
return
}
// Opening A New Database Connection
// filename: Database filename (UTF-8)
// zVfs: Name of VFS module to use
func OpenV2(filename *Char, flags OpenFlags, zVfs *Char) (db *Sqlite3, err Errno) {
err = doOpenV2(filename, &db, flags, zVfs)
return
}
// Closing A Database Connection
//
// llgo:link (*Sqlite3).Close C.sqlite3_close
func (db *Sqlite3) Close() Errno { return 0 }
// Closing A Database Connection
//
// llgo:link (*Sqlite3).CloseV2 C.sqlite3_close_v2
func (db *Sqlite3) CloseV2() Errno { return 0 }
// -----------------------------------------------------------------------------
// llgo:link (*Sqlite3).doPrepare C.sqlite3_prepare
func (*Sqlite3) doPrepare(*Char, Int, **Stmt, **Char) Errno {
return 0
}
// llgo:link (*Sqlite3).doPrepareV2 C.sqlite3_prepare_v2
func (*Sqlite3) doPrepareV2(*Char, Int, **Stmt, **Char) Errno {
return 0
}
// llgo:link (*Sqlite3).doPrepareV3 C.sqlite3_prepare_v3
func (*Sqlite3) doPrepareV3(*Char, Int, PrepareFlags, **Stmt, **Char) Errno {
return 0
}
// PrepareFlags represents SQLite prepare flags.
type PrepareFlags Int
const (
PreparePersistent PrepareFlags = 0x01
PrepareNormalize PrepareFlags = 0x02
PrepareNoVtab PrepareFlags = 0x04
)
// Compiling An SQL Statement
// tail: Pointer to unused portion of sql
func (db *Sqlite3) Prepare(sql string, tail **Char) (stmt *Stmt, err Errno) {
err = db.doPrepare(c.GoStringData(sql), c.Int(len(sql)), &stmt, tail)
return
}
func (db *Sqlite3) PrepareV2(sql string, tail **Char) (stmt *Stmt, err Errno) {
err = db.doPrepareV2(c.GoStringData(sql), c.Int(len(sql)), &stmt, tail)
return
}
func (db *Sqlite3) PrepareV3(sql string, flags PrepareFlags, tail **Char) (stmt *Stmt, err Errno) {
err = db.doPrepareV3(c.GoStringData(sql), c.Int(len(sql)), flags, &stmt, tail)
return
}
// Destroy A Prepared Statement Object
//
// llgo:link (*Stmt).Close C.sqlite3_finalize
func (stmt *Stmt) Close() Errno { return 0 }
// -----------------------------------------------------------------------------
// llgo:link (*Stmt).BindInt C.sqlite3_bind_int
func (*Stmt) BindInt(idx Int, val Int) Errno { return 0 }
// llgo:link (*Stmt).BindInt64 C.sqlite3_bind_int64
func (*Stmt) BindInt64(idx Int, val int64) Errno { return 0 }
/*
const (
Static = (func(Pointer))(nil) // val is a static string
Transient = (func(Pointer))(-1) // val is a transient (temporary) string
)
*/
// llgo:link (*Stmt).BindText C.sqlite3_bind_text
func (*Stmt) BindText(idx Int, val *Char, nByte Int, destructor func(Pointer)) Errno { return 0 }
// -----------------------------------------------------------------------------
// Reset A Prepared Statement Object
//
// llgo:link (*Stmt).Reset C.sqlite3_reset
func (stmt *Stmt) Reset() Errno {
return 0
}
// Evaluate An SQL Statement
//
// llgo:link (*Stmt).Step C.sqlite3_step
func (*Stmt) Step() Errno { return 0 }
// -----------------------------------------------------------------------------
// llgo:link (*Stmt).ColumnCount C.sqlite3_column_count
func (stmt *Stmt) ColumnCount() Int { return 0 }
// llgo:link (*Stmt).ColumnName C.sqlite3_column_name
func (stmt *Stmt) ColumnName(idx Int) *Char { return nil }
// llgo:link (*Stmt).ColumnInt C.sqlite3_column_int
func (stmt *Stmt) ColumnInt(idx Int) Int { return 0 }
// llgo:link (*Stmt).ColumnInt64 C.sqlite3_column_int64
func (stmt *Stmt) ColumnInt64(idx Int) int64 { return 0 }
// llgo:link (*Stmt).ColumnText C.sqlite3_column_text
func (stmt *Stmt) ColumnText(idx Int) *Char { return nil }
// -----------------------------------------------------------------------------
// One-Step Query Execution Interface
//
// llgo:link (*Sqlite3).Exec C.sqlite3_exec
func (*Sqlite3) Exec(
sql *Char, callback func(arg Pointer, resultCols Int, colVals, colNames **Char) Int,
arg Pointer, errmsg **Char) Errno {
return 0
}
// -----------------------------------------------------------------------------