4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-07-03 01:27:45 +00:00

Update vendor (#852)

This commit is contained in:
Wim
2019-06-16 23:33:25 +02:00
committed by GitHub
parent f4ae610448
commit cb712ff37d
294 changed files with 71447 additions and 6861 deletions

27
vendor/github.com/d5/tengo/objects/builtin_format.go generated vendored Normal file
View File

@ -0,0 +1,27 @@
package objects
func builtinFormat(args ...Object) (Object, error) {
numArgs := len(args)
if numArgs == 0 {
return nil, ErrWrongNumArguments
}
format, ok := args[0].(*String)
if !ok {
return nil, ErrInvalidArgumentType{
Name: "format",
Expected: "string",
Found: args[0].TypeName(),
}
}
if numArgs == 1 {
return format, nil // okay to return 'format' directly as String is immutable
}
s, err := Format(format.Value, args[1:]...)
if err != nil {
return nil, err
}
return &String{Value: s}, nil
}

View File

@ -111,4 +111,8 @@ var Builtins = []*BuiltinFunction{
Name: "type_name",
Value: builtinTypeName,
},
{
Name: "format",
Value: builtinFormat,
},
}

View File

@ -57,7 +57,7 @@ func (o *Bytes) Equals(x Object) bool {
return false
}
return bytes.Compare(o.Value, t.Value) == 0
return bytes.Equal(o.Value, t.Value)
}
// IndexGet returns an element (as Int) at a given index.

View File

@ -10,6 +10,7 @@ type CompiledFunction struct {
Instructions []byte
NumLocals int // number of local variables (including function parameters)
NumParameters int
VarArgs bool
SourceMap map[int]source.Pos
}
@ -34,6 +35,7 @@ func (o *CompiledFunction) Copy() Object {
Instructions: append([]byte{}, o.Instructions...),
NumLocals: o.NumLocals,
NumParameters: o.NumParameters,
VarArgs: o.VarArgs,
}
}

View File

@ -254,7 +254,7 @@ func FromInterface(v interface{}) (Object, error) {
case []Object:
return &Array{Value: v}, nil
case []interface{}:
arr := make([]Object, len(v), len(v))
arr := make([]Object, len(v))
for i, e := range v {
vo, err := FromInterface(e)
if err != nil {

1212
vendor/github.com/d5/tengo/objects/formatter.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -76,13 +76,13 @@ func (o *Map) Equals(x Object) bool {
// IndexGet returns the value for the given key.
func (o *Map) IndexGet(index Object) (res Object, err error) {
strIdx, ok := index.(*String)
strIdx, ok := ToString(index)
if !ok {
err = ErrInvalidIndexType
return
}
val, ok := o.Value[strIdx.Value]
val, ok := o.Value[strIdx]
if !ok {
val = UndefinedValue
}

View File

@ -40,3 +40,23 @@ func (o *Undefined) Equals(x Object) bool {
func (o *Undefined) IndexGet(index Object) (Object, error) {
return UndefinedValue, nil
}
// Iterate creates a map iterator.
func (o *Undefined) Iterate() Iterator {
return o
}
// Next returns true if there are more elements to iterate.
func (o *Undefined) Next() bool {
return false
}
// Key returns the key or index value of the current element.
func (o *Undefined) Key() Object {
return o
}
// Value returns the value of the current element.
func (o *Undefined) Value() Object {
return o
}