Files
moxa/stdlib/go1_13_encoding_gob.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

53 lines
1.6 KiB
Go

// Code generated by 'goexports encoding/gob'. DO NOT EDIT.
// +build go1.13,!go1.14
package stdlib
import (
"encoding/gob"
"fmt"
"reflect"
)
func init() {
Symbols["encoding/gob"] = map[string]reflect.Value{
// function, constant and variable definitions
"NewDecoder": reflect.ValueOf(gob.NewDecoder),
"NewEncoder": reflect.ValueOf(gob.NewEncoder),
"Register": reflect.ValueOf(gob.Register),
"RegisterName": reflect.ValueOf(gob.RegisterName),
// type definitions
"CommonType": reflect.ValueOf((*gob.CommonType)(nil)),
"Decoder": reflect.ValueOf((*gob.Decoder)(nil)),
"Encoder": reflect.ValueOf((*gob.Encoder)(nil)),
"GobDecoder": reflect.ValueOf((*gob.GobDecoder)(nil)),
"GobEncoder": reflect.ValueOf((*gob.GobEncoder)(nil)),
// interface wrapper definitions
"_GobDecoder": reflect.ValueOf((*_encoding_gob_GobDecoder)(nil)),
"_GobEncoder": reflect.ValueOf((*_encoding_gob_GobEncoder)(nil)),
}
}
// _encoding_gob_GobDecoder is an interface wrapper for GobDecoder type
type _encoding_gob_GobDecoder struct {
Val interface{}
WGobDecode func(a0 []byte) error
}
func (W _encoding_gob_GobDecoder) String() string { return fmt.Sprint(W.Val) }
func (W _encoding_gob_GobDecoder) GobDecode(a0 []byte) error { return W.WGobDecode(a0) }
// _encoding_gob_GobEncoder is an interface wrapper for GobEncoder type
type _encoding_gob_GobEncoder struct {
Val interface{}
WGobEncode func() ([]byte, error)
}
func (W _encoding_gob_GobEncoder) String() string { return fmt.Sprint(W.Val) }
func (W _encoding_gob_GobEncoder) GobEncode() ([]byte, error) { return W.WGobEncode() }