* fix: make interpreter methods discoverable by runtime When generating an interface wrapper, lookup existing wrappers by method to get the one with the biggest set of methods implemented by interpreter. A string method is also added to wrappers, in order to provide a string representation of the interpreter value rather than the wrapper itself (at least for %s and %v verbs). This allows the runtime to pickup an interpreter method automatically even if the conversion to the interface is not specified in the script. As in Go spec, it is enough for the type to implement the required methods. A current limitation is that only single wrappers can be instantiated, not allowing to compose interfaces. This limitation can be removed when the Go reflect issue https://github.com/golang/go/issues/15924 is fixed. Fixes #435. * test: add a simpler test
77 lines
3.0 KiB
Go
77 lines
3.0 KiB
Go
// Code generated by 'goexports encoding/json'. DO NOT EDIT.
|
|
|
|
// +build go1.13,!go1.14
|
|
|
|
package stdlib
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"reflect"
|
|
)
|
|
|
|
func init() {
|
|
Symbols["encoding/json"] = map[string]reflect.Value{
|
|
// function, constant and variable definitions
|
|
"Compact": reflect.ValueOf(json.Compact),
|
|
"HTMLEscape": reflect.ValueOf(json.HTMLEscape),
|
|
"Indent": reflect.ValueOf(json.Indent),
|
|
"Marshal": reflect.ValueOf(json.Marshal),
|
|
"MarshalIndent": reflect.ValueOf(json.MarshalIndent),
|
|
"NewDecoder": reflect.ValueOf(json.NewDecoder),
|
|
"NewEncoder": reflect.ValueOf(json.NewEncoder),
|
|
"Unmarshal": reflect.ValueOf(json.Unmarshal),
|
|
"Valid": reflect.ValueOf(json.Valid),
|
|
|
|
// type definitions
|
|
"Decoder": reflect.ValueOf((*json.Decoder)(nil)),
|
|
"Delim": reflect.ValueOf((*json.Delim)(nil)),
|
|
"Encoder": reflect.ValueOf((*json.Encoder)(nil)),
|
|
"InvalidUTF8Error": reflect.ValueOf((*json.InvalidUTF8Error)(nil)),
|
|
"InvalidUnmarshalError": reflect.ValueOf((*json.InvalidUnmarshalError)(nil)),
|
|
"Marshaler": reflect.ValueOf((*json.Marshaler)(nil)),
|
|
"MarshalerError": reflect.ValueOf((*json.MarshalerError)(nil)),
|
|
"Number": reflect.ValueOf((*json.Number)(nil)),
|
|
"RawMessage": reflect.ValueOf((*json.RawMessage)(nil)),
|
|
"SyntaxError": reflect.ValueOf((*json.SyntaxError)(nil)),
|
|
"Token": reflect.ValueOf((*json.Token)(nil)),
|
|
"UnmarshalFieldError": reflect.ValueOf((*json.UnmarshalFieldError)(nil)),
|
|
"UnmarshalTypeError": reflect.ValueOf((*json.UnmarshalTypeError)(nil)),
|
|
"Unmarshaler": reflect.ValueOf((*json.Unmarshaler)(nil)),
|
|
"UnsupportedTypeError": reflect.ValueOf((*json.UnsupportedTypeError)(nil)),
|
|
"UnsupportedValueError": reflect.ValueOf((*json.UnsupportedValueError)(nil)),
|
|
|
|
// interface wrapper definitions
|
|
"_Marshaler": reflect.ValueOf((*_encoding_json_Marshaler)(nil)),
|
|
"_Token": reflect.ValueOf((*_encoding_json_Token)(nil)),
|
|
"_Unmarshaler": reflect.ValueOf((*_encoding_json_Unmarshaler)(nil)),
|
|
}
|
|
}
|
|
|
|
// _encoding_json_Marshaler is an interface wrapper for Marshaler type
|
|
type _encoding_json_Marshaler struct {
|
|
Val interface{}
|
|
WMarshalJSON func() ([]byte, error)
|
|
}
|
|
|
|
func (W _encoding_json_Marshaler) String() string { return fmt.Sprint(W.Val) }
|
|
|
|
func (W _encoding_json_Marshaler) MarshalJSON() ([]byte, error) { return W.WMarshalJSON() }
|
|
|
|
// _encoding_json_Token is an interface wrapper for Token type
|
|
type _encoding_json_Token struct {
|
|
Val interface{}
|
|
}
|
|
|
|
func (W _encoding_json_Token) String() string { return fmt.Sprint(W.Val) }
|
|
|
|
// _encoding_json_Unmarshaler is an interface wrapper for Unmarshaler type
|
|
type _encoding_json_Unmarshaler struct {
|
|
Val interface{}
|
|
WUnmarshalJSON func(a0 []byte) error
|
|
}
|
|
|
|
func (W _encoding_json_Unmarshaler) String() string { return fmt.Sprint(W.Val) }
|
|
|
|
func (W _encoding_json_Unmarshaler) UnmarshalJSON(a0 []byte) error { return W.WUnmarshalJSON(a0) }
|