Files
moxa/stdlib/go1_14_encoding_binary.go
Marc Vertes a3b2737b5c fix: make interpreter methods discoverable by runtime (#722)
* 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
2020-06-29 14:25:14 +02:00

59 lines
2.3 KiB
Go

// Code generated by 'goexports encoding/binary'. DO NOT EDIT.
// +build go1.14,!go1.15
package stdlib
import (
"encoding/binary"
"go/constant"
"go/token"
"reflect"
)
func init() {
Symbols["encoding/binary"] = map[string]reflect.Value{
// function, constant and variable definitions
"BigEndian": reflect.ValueOf(&binary.BigEndian).Elem(),
"LittleEndian": reflect.ValueOf(&binary.LittleEndian).Elem(),
"MaxVarintLen16": reflect.ValueOf(constant.MakeFromLiteral("3", token.INT, 0)),
"MaxVarintLen32": reflect.ValueOf(constant.MakeFromLiteral("5", token.INT, 0)),
"MaxVarintLen64": reflect.ValueOf(constant.MakeFromLiteral("10", token.INT, 0)),
"PutUvarint": reflect.ValueOf(binary.PutUvarint),
"PutVarint": reflect.ValueOf(binary.PutVarint),
"Read": reflect.ValueOf(binary.Read),
"ReadUvarint": reflect.ValueOf(binary.ReadUvarint),
"ReadVarint": reflect.ValueOf(binary.ReadVarint),
"Size": reflect.ValueOf(binary.Size),
"Uvarint": reflect.ValueOf(binary.Uvarint),
"Varint": reflect.ValueOf(binary.Varint),
"Write": reflect.ValueOf(binary.Write),
// type definitions
"ByteOrder": reflect.ValueOf((*binary.ByteOrder)(nil)),
// interface wrapper definitions
"_ByteOrder": reflect.ValueOf((*_encoding_binary_ByteOrder)(nil)),
}
}
// _encoding_binary_ByteOrder is an interface wrapper for ByteOrder type
type _encoding_binary_ByteOrder struct {
Val interface{}
WPutUint16 func(a0 []byte, a1 uint16)
WPutUint32 func(a0 []byte, a1 uint32)
WPutUint64 func(a0 []byte, a1 uint64)
WString func() string
WUint16 func(a0 []byte) uint16
WUint32 func(a0 []byte) uint32
WUint64 func(a0 []byte) uint64
}
func (W _encoding_binary_ByteOrder) PutUint16(a0 []byte, a1 uint16) { W.WPutUint16(a0, a1) }
func (W _encoding_binary_ByteOrder) PutUint32(a0 []byte, a1 uint32) { W.WPutUint32(a0, a1) }
func (W _encoding_binary_ByteOrder) PutUint64(a0 []byte, a1 uint64) { W.WPutUint64(a0, a1) }
func (W _encoding_binary_ByteOrder) String() string { return W.WString() }
func (W _encoding_binary_ByteOrder) Uint16(a0 []byte) uint16 { return W.WUint16(a0) }
func (W _encoding_binary_ByteOrder) Uint32(a0 []byte) uint32 { return W.WUint32(a0) }
func (W _encoding_binary_ByteOrder) Uint64(a0 []byte) uint64 { return W.WUint64(a0) }