summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/d5/tengo/objects/builtins.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/d5/tengo/objects/builtins.go')
-rw-r--r--vendor/github.com/d5/tengo/objects/builtins.go60
1 files changed, 5 insertions, 55 deletions
diff --git a/vendor/github.com/d5/tengo/objects/builtins.go b/vendor/github.com/d5/tengo/objects/builtins.go
index 42c1a759..bfd004dd 100644
--- a/vendor/github.com/d5/tengo/objects/builtins.go
+++ b/vendor/github.com/d5/tengo/objects/builtins.go
@@ -2,19 +2,7 @@ package objects
// Builtins contains all default builtin functions.
// Use GetBuiltinFunctions instead of accessing Builtins directly.
-var Builtins = []BuiltinFunction{
- {
- Name: "print",
- Value: builtinPrint,
- },
- {
- Name: "printf",
- Value: builtinPrintf,
- },
- {
- Name: "sprintf",
- Value: builtinSprintf,
- },
+var Builtins = []*BuiltinFunction{
{
Name: "len",
Value: builtinLen,
@@ -96,6 +84,10 @@ var Builtins = []BuiltinFunction{
Value: builtinIsImmutableMap,
},
{
+ Name: "is_iterable",
+ Value: builtinIsIterable,
+ },
+ {
Name: "is_time",
Value: builtinIsTime,
},
@@ -116,49 +108,7 @@ var Builtins = []BuiltinFunction{
Value: builtinIsCallable,
},
{
- Name: "to_json",
- Value: builtinToJSON,
- },
- {
- Name: "from_json",
- Value: builtinFromJSON,
- },
- {
Name: "type_name",
Value: builtinTypeName,
},
}
-
-// AllBuiltinFunctionNames returns a list of all default builtin function names.
-func AllBuiltinFunctionNames() []string {
- var names []string
- for _, bf := range Builtins {
- names = append(names, bf.Name)
- }
- return names
-}
-
-// GetBuiltinFunctions returns a slice of builtin function objects.
-// GetBuiltinFunctions removes the duplicate names, and, the returned builtin functions
-// are not guaranteed to be in the same order as names.
-func GetBuiltinFunctions(names ...string) []*BuiltinFunction {
- include := make(map[string]bool)
- for _, name := range names {
- include[name] = true
- }
-
- var builtinFuncs []*BuiltinFunction
- for _, bf := range Builtins {
- if include[bf.Name] {
- bf := bf
- builtinFuncs = append(builtinFuncs, &bf)
- }
- }
-
- return builtinFuncs
-}
-
-// GetAllBuiltinFunctions returns all builtin functions.
-func GetAllBuiltinFunctions() []*BuiltinFunction {
- return GetBuiltinFunctions(AllBuiltinFunctionNames()...)
-}