summaryrefslogtreecommitdiff
path: root/vendor/github.com/bytedance/sonic/ast
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-03-25 10:31:19 +0000
committerLibravatar GitHub <noreply@github.com>2024-03-25 10:31:19 +0000
commit40ee47053684a87c717b941951df44d5a0ea9129 (patch)
tree84edccfe00216c10231838ea1f453542bb566e52 /vendor/github.com/bytedance/sonic/ast
parent[chore] Move local account settings to separate db table (#2770) (diff)
downloadgotosocial-40ee47053684a87c717b941951df44d5a0ea9129.tar.xz
[chore]: Bump github.com/gin-contrib/gzip from 0.0.6 to 1.0.0 (#2781)
Diffstat (limited to 'vendor/github.com/bytedance/sonic/ast')
-rw-r--r--vendor/github.com/bytedance/sonic/ast/api.go (renamed from vendor/github.com/bytedance/sonic/ast/api_amd64.go)11
-rw-r--r--vendor/github.com/bytedance/sonic/ast/api_compat.go128
-rw-r--r--vendor/github.com/bytedance/sonic/ast/b64_amd64.go31
-rw-r--r--vendor/github.com/bytedance/sonic/ast/b64_compat.go31
-rw-r--r--vendor/github.com/bytedance/sonic/ast/visitor.go2
5 files changed, 125 insertions, 78 deletions
diff --git a/vendor/github.com/bytedance/sonic/ast/api_amd64.go b/vendor/github.com/bytedance/sonic/ast/api.go
index fa4375630..373d62a9f 100644
--- a/vendor/github.com/bytedance/sonic/ast/api_amd64.go
+++ b/vendor/github.com/bytedance/sonic/ast/api.go
@@ -1,4 +1,4 @@
-// +build amd64,go1.16,!go1.23
+// +build amd64,go1.16,!go1.23 arm64,go1.20,!go1.23
/*
* Copyright 2022 ByteDance Inc.
@@ -27,7 +27,6 @@ import (
`github.com/bytedance/sonic/internal/native/types`
`github.com/bytedance/sonic/internal/rt`
uq `github.com/bytedance/sonic/unquote`
- `github.com/chenzhuoyu/base64x`
)
var typeByte = rt.UnpackEface(byte(0)).Type
@@ -77,14 +76,6 @@ func unquote(src string) (string, types.ParsingError) {
return uq.String(src)
}
-func decodeBase64(src string) ([]byte, error) {
- return base64x.StdEncoding.DecodeString(src)
-}
-
-func encodeBase64(src []byte) string {
- return base64x.StdEncoding.EncodeToString(src)
-}
-
func (self *Parser) decodeValue() (val types.JsonState) {
sv := (*rt.GoString)(unsafe.Pointer(&self.s))
flag := types.F_USE_NUMBER
diff --git a/vendor/github.com/bytedance/sonic/ast/api_compat.go b/vendor/github.com/bytedance/sonic/ast/api_compat.go
index 9244e76e1..2c889fc2a 100644
--- a/vendor/github.com/bytedance/sonic/ast/api_compat.go
+++ b/vendor/github.com/bytedance/sonic/ast/api_compat.go
@@ -1,111 +1,105 @@
-// +build !amd64 !go1.16 go1.23
+// +build !amd64,!arm64 go1.23 !go1.16 arm64,!go1.20
/*
- * Copyright 2022 ByteDance Inc.
- *
- * 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.
- */
+* Copyright 2022 ByteDance Inc.
+*
+* 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 ast
import (
- `encoding/base64`
- `encoding/json`
+ `encoding/json`
- `github.com/bytedance/sonic/internal/native/types`
- `github.com/bytedance/sonic/internal/rt`
+ `github.com/bytedance/sonic/internal/native/types`
+ `github.com/bytedance/sonic/internal/rt`
)
func init() {
- println("WARNING: sonic only supports Go1.16~1.22 && CPU amd64, but your environment is not suitable")
+ println("WARNING:(ast) sonic only supports Go1.16~1.22, but your environment is not suitable")
}
func quote(buf *[]byte, val string) {
- quoteString(buf, val)
+ quoteString(buf, val)
}
func unquote(src string) (string, types.ParsingError) {
- sp := rt.IndexChar(src, -1)
- out, ok := unquoteBytes(rt.BytesFrom(sp, len(src)+2, len(src)+2))
- if !ok {
- return "", types.ERR_INVALID_ESCAPE
- }
- return rt.Mem2Str(out), 0
+ sp := rt.IndexChar(src, -1)
+ out, ok := unquoteBytes(rt.BytesFrom(sp, len(src)+2, len(src)+2))
+ if !ok {
+ return "", types.ERR_INVALID_ESCAPE
+ }
+ return rt.Mem2Str(out), 0
}
-func decodeBase64(src string) ([]byte, error) {
- return base64.StdEncoding.DecodeString(src)
-}
-
-func encodeBase64(src []byte) string {
- return base64.StdEncoding.EncodeToString(src)
-}
func (self *Parser) decodeValue() (val types.JsonState) {
- e, v := decodeValue(self.s, self.p, self.dbuf == nil)
- if e < 0 {
- return v
- }
- self.p = e
- return v
+ e, v := decodeValue(self.s, self.p, self.dbuf == nil)
+ if e < 0 {
+ return v
+ }
+ self.p = e
+ return v
}
func (self *Parser) skip() (int, types.ParsingError) {
- e, s := skipValue(self.s, self.p)
- if e < 0 {
- return self.p, types.ParsingError(-e)
- }
- self.p = e
- return s, 0
+ e, s := skipValue(self.s, self.p)
+ if e < 0 {
+ return self.p, types.ParsingError(-e)
+ }
+ self.p = e
+ return s, 0
}
func (self *Parser) skipFast() (int, types.ParsingError) {
- e, s := skipValueFast(self.s, self.p)
- if e < 0 {
- return self.p, types.ParsingError(-e)
- }
- self.p = e
- return s, 0
+ e, s := skipValueFast(self.s, self.p)
+ if e < 0 {
+ return self.p, types.ParsingError(-e)
+ }
+ self.p = e
+ return s, 0
}
func (self *Node) encodeInterface(buf *[]byte) error {
- out, err := json.Marshal(self.packAny())
- if err != nil {
- return err
- }
- *buf = append(*buf, out...)
- return nil
+ out, err := json.Marshal(self.packAny())
+ if err != nil {
+ return err
+ }
+ *buf = append(*buf, out...)
+ return nil
}
func (self *Parser) getByPath(path ...interface{}) (int, types.ParsingError) {
- var err types.ParsingError
for _, p := range path {
if idx, ok := p.(int); ok && idx >= 0 {
- if err = self.searchIndex(idx); err != 0 {
- return -1, err
+ if err := self.searchIndex(idx); err != 0 {
+ return self.p, err
}
} else if key, ok := p.(string); ok {
- if err = self.searchKey(key); err != 0 {
- return -1, err
+ if err := self.searchKey(key); err != 0 {
+ return self.p, err
}
} else {
panic("path must be either int(>=0) or string")
}
}
-
- var start int
- if start, err = self.skip(); err != 0 {
- return -1, err
+ start, e := self.skip()
+ if e != 0 {
+ return self.p, e
}
+ // t := switchRawType(self.s[start])
+ // if t == _V_NUMBER {
+ // self.p = 1 + backward(self.s, self.p-1)
+ // }
return start, 0
}
diff --git a/vendor/github.com/bytedance/sonic/ast/b64_amd64.go b/vendor/github.com/bytedance/sonic/ast/b64_amd64.go
new file mode 100644
index 000000000..fd3d85e36
--- /dev/null
+++ b/vendor/github.com/bytedance/sonic/ast/b64_amd64.go
@@ -0,0 +1,31 @@
+// +build amd64,go1.16
+
+/**
+ * Copyright 2023 ByteDance Inc.
+ *
+ * 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 ast
+
+import (
+ `github.com/chenzhuoyu/base64x`
+)
+
+func decodeBase64(src string) ([]byte, error) {
+ return base64x.StdEncoding.DecodeString(src)
+}
+
+func encodeBase64(src []byte) string {
+ return base64x.StdEncoding.EncodeToString(src)
+}
diff --git a/vendor/github.com/bytedance/sonic/ast/b64_compat.go b/vendor/github.com/bytedance/sonic/ast/b64_compat.go
new file mode 100644
index 000000000..e8f9a72fd
--- /dev/null
+++ b/vendor/github.com/bytedance/sonic/ast/b64_compat.go
@@ -0,0 +1,31 @@
+// +build !amd64 !go1.16
+
+/*
+ * Copyright 2022 ByteDance Inc.
+ *
+ * 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 ast
+
+import (
+ `encoding/base64`
+)
+
+func decodeBase64(src string) ([]byte, error) {
+ return base64.StdEncoding.DecodeString(src)
+}
+
+func encodeBase64(src []byte) string {
+ return base64.StdEncoding.EncodeToString(src)
+}
diff --git a/vendor/github.com/bytedance/sonic/ast/visitor.go b/vendor/github.com/bytedance/sonic/ast/visitor.go
index 4019c31a2..d409509f5 100644
--- a/vendor/github.com/bytedance/sonic/ast/visitor.go
+++ b/vendor/github.com/bytedance/sonic/ast/visitor.go
@@ -25,7 +25,7 @@ import (
// Visitor handles the callbacks during preorder traversal of a JSON AST.
//
// According to the JSON RFC8259, a JSON AST can be defined by
-// the following rules without seperator / whitespace tokens.
+// the following rules without separator / whitespace tokens.
//
// JSON-AST = value
// value = false / null / true / object / array / number / string