mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-07 18:14:03 +00:00
60
vendor/github.com/d5/tengo/objects/builtins.go
generated
vendored
60
vendor/github.com/d5/tengo/objects/builtins.go
generated
vendored
@ -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,
|
||||
@ -95,6 +83,10 @@ var Builtins = []BuiltinFunction{
|
||||
Name: "is_immutable_map",
|
||||
Value: builtinIsImmutableMap,
|
||||
},
|
||||
{
|
||||
Name: "is_iterable",
|
||||
Value: builtinIsIterable,
|
||||
},
|
||||
{
|
||||
Name: "is_time",
|
||||
Value: builtinIsTime,
|
||||
@ -115,50 +107,8 @@ var Builtins = []BuiltinFunction{
|
||||
Name: "is_callable",
|
||||
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()...)
|
||||
}
|
||||
|
Reference in New Issue
Block a user