summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/d5/tengo/objects/builtins.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-04-06 22:18:25 +0200
committerGitHub <noreply@github.com>2019-04-06 22:18:25 +0200
commit115d20373c21b107a428a55247c64f900e116038 (patch)
treec7299b3d3be2a48c0f2d5bfbd856cbd1b27d2e55 /vendor/github.com/d5/tengo/objects/builtins.go
parentcdf33e5748c110e12097130bdb44637e3d14b229 (diff)
downloadmatterbridge-msglm-115d20373c21b107a428a55247c64f900e116038.tar.gz
matterbridge-msglm-115d20373c21b107a428a55247c64f900e116038.tar.bz2
matterbridge-msglm-115d20373c21b107a428a55247c64f900e116038.zip
Update tengo vendor and load the stdlib. Fixes #789 (#792)
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()...)
-}