package sqlite3_wasm
import (
"bytes"
"math"
"math/bits"
"strconv"
"time"
"unsafe"
)
func _acos(x float64 ) float64 { return math .Acos (x ) }
func _acosh(x float64 ) float64 { return math .Acosh (x ) }
func _asin(x float64 ) float64 { return math .Asin (x ) }
func _asinh(x float64 ) float64 { return math .Asinh (x ) }
func _atan(x float64 ) float64 { return math .Atan (x ) }
func _atan2(y , x float64 ) float64 { return math .Atan2 (y , x ) }
func _atanh(x float64 ) float64 { return math .Atanh (x ) }
func _cos(x float64 ) float64 { return math .Cos (x ) }
func _cosh(x float64 ) float64 { return math .Cosh (x ) }
func _exp(x float64 ) float64 { return math .Exp (x ) }
func _fmod(x , y float64 ) float64 { return math .Mod (x , y ) }
func _storetime_r(buf []byte , t time .Time ) {
const size uint32 = 32 / 8
var isdst uint32
if t .IsDST () {
isdst = 1
}
_ , zone := t .Zone ()
store32 (buf , 0 *size , uint32 (t .Second ()))
store32 (buf , 1 *size , uint32 (t .Minute ()))
store32 (buf , 2 *size , uint32 (t .Hour ()))
store32 (buf , 3 *size , uint32 (t .Day ()))
store32 (buf , 4 *size , uint32 (t .Month ()-time .January ))
store32 (buf , 5 *size , uint32 (t .Year ()-1900 ))
store32 (buf , 6 *size , uint32 (t .Weekday ()-time .Sunday ))
store32 (buf , 7 *size , uint32 (t .YearDay ()-1 ))
store32 (buf , 8 *size , isdst )
store32 (buf , 9 *size , uint32 (zone ))
store32 (buf , 10 *size , 0 )
}
func (m *Module ) _localtime_r (timer , buf int32 ) int32 {
t := load64 ((*m .memory ), uint32 (timer ))
_storetime_r ((*m .memory )[uint32 (buf ):], time .Unix (int64 (t ), 0 ))
return buf
}
func _log(x float64 ) float64 { return math .Log (x ) }
func _log10(x float64 ) float64 { return math .Log10 (x ) }
func _log2(x float64 ) float64 { return math .Log2 (x ) }
func (m *Module ) _memchr (s int32 , c int32 , n int32 ) int32 {
b := (*m .memory )[uint32 (s ):]
if uint64 (uint32 (n )) < uint64 (len (b )) {
b = b [:uint32 (n )]
}
if i := bytes .IndexByte (b , byte (c )); i >= 0 {
return s + int32 (i )
}
return 0
}
func (m *Module ) _memcmp (s1 , s2 , n int32 ) int32 {
if s1 == s2 {
return 0
}
e1 , e2 := s1 +n , s2 +n
b1 := (*m .memory )[uint32 (s1 ):uint32 (e1 ):len ((*m .memory ))]
b2 := (*m .memory )[uint32 (s2 ):uint32 (e2 ):len ((*m .memory ))]
return int32 (bytes .Compare (b1 , b2 ))
}
func _pow(x , y float64 ) float64 { return math .Pow (x , y ) }
func _sin(x float64 ) float64 { return math .Sin (x ) }
func _sinh(x float64 ) float64 { return math .Sinh (x ) }
func (m *Module ) _strchrnul (s int32 , c int32 ) int32 {
for i , d := range (*m .memory )[uint32 (s ):] {
if d == 0 || d == byte (c ) {
return s + int32 (i )
}
}
return -1
}
func (m *Module ) _strchr (s int32 , c int32 ) int32 {
s = m ._strchrnul (s , c )
if (*m .memory )[uint32 (s )] == byte (c ) {
return s
}
return 0
}
func (m *Module ) _strcmp (s1 , s2 int32 ) int32 {
if s1 == s2 {
return 0
}
b1 := (*m .memory )[uint32 (s1 ):]
b2 := (*m .memory )[uint32 (s2 ):]
sz := min (len (b1 ), len (b2 ))
if i := bytes .IndexByte (b2 [:sz ], 0 ); i >= 0 {
sz = i + 1
}
return int32 (bytes .Compare (b1 [:sz ], b2 [:sz ]))
}
func _makeByteSet(chars []byte ) (set [256 / bits .UintSize ]uint ) {
for _ , c := range chars {
if c == 0 {
break
}
set [c /bits .UintSize ] |= 1 << (c % bits .UintSize )
}
return set
}
func (m *Module ) _strcspn (s , reject int32 ) int32 {
b := (*m .memory )[uint32 (s ):]
r := (*m .memory )[uint32 (reject ):]
set := _makeByteSet (r )
set [0 ] |= 1
for i , c := range b {
if set [c /bits .UintSize ]&(1 <<(c %bits .UintSize )) != 0 {
return int32 (i )
}
}
return -1
}
func (m *Module ) _strlen (s int32 ) int32 {
return int32 (bytes .IndexByte ((*m .memory )[uint32 (s ):], 0 ))
}
func (m *Module ) _strncmp (s1 , s2 , n int32 ) int32 {
if s1 == s2 {
return 0
}
b1 := (*m .memory )[uint32 (s1 ):]
b2 := (*m .memory )[uint32 (s2 ):]
sz := int (min (uint64 (len (b1 )), uint64 (len (b2 )), uint64 (uint32 (n ))))
if i := bytes .IndexByte (b2 [:sz ], 0 ); i >= 0 {
sz = i + 1
}
return int32 (bytes .Compare (b1 [:sz ], b2 [:sz ]))
}
func (m *Module ) _strrchr (s int32 , c int32 ) int32 {
b := (*m .memory )[uint32 (s ):]
b = b [: bytes .IndexByte (b , 0 )+1 : len (b )]
if i := bytes .LastIndexByte (b , byte (c )); i >= 0 {
return s + int32 (i )
}
return 0
}
func (m *Module ) _strspn (s , accept int32 ) int32 {
b := (*m .memory )[uint32 (s ):]
a := (*m .memory )[uint32 (accept ):]
set := _makeByteSet (a )
for i , c := range b {
if set [c /bits .UintSize ]&(1 <<(c %bits .UintSize )) == 0 {
return int32 (i )
}
}
return -1
}
func (m *Module ) _strstr (haystack , needle int32 ) int32 {
h := (*m .memory )[uint32 (haystack ):]
n := (*m .memory )[uint32 (needle ):]
h = h [:bytes .IndexByte (h , 0 ):len (h )]
n = n [:bytes .IndexByte (n , 0 ):len (n )]
if i := bytes .Index (h , n ); i >= 0 {
return haystack + int32 (i )
}
return 0
}
func (m *Module ) _strtoll_helper (s , endptr int32 , base int32 , bitSize int ) int64 {
m0 := (*m .memory )[uint32 (s ):]
m1 := bytes .TrimLeft (m0 , " \t\n\v\f\r" )
m2 := m1
switch {
case bytes .HasPrefix (m1 , []byte ("-" )):
fallthrough
case bytes .HasPrefix (m1 , []byte ("+" )):
m2 = m2 [1 :]
}
m2 = bytes .TrimLeft (m2 , "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" )
prefix := len (m0 ) - len (m1 )
digits := len (m1 ) - len (m2 )
var val int64
for ; digits > 0 ; digits -- {
var err error
str := unsafe .String (&m1 [0 ], digits )
val , err = strconv .ParseInt (str , int (base ), bitSize )
if e , ok := err .(*strconv .NumError ); !ok || e .Err == strconv .ErrRange {
break
}
}
if endptr != 0 {
if digits > 0 {
s += int32 (prefix + digits )
}
store32 ((*m .memory ), uint32 (endptr ), uint32 (s ))
}
return val
}
func (m *Module ) _strtol (s , endptr int32 , base int32 ) int32 {
return int32 (m ._strtoll_helper (s , endptr , base , 32 ))
}
func _tan(x float64 ) float64 { return math .Tan (x ) }
func _tanh(x float64 ) float64 { return math .Tanh (x ) }
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .