This is an automated email from the ASF dual-hosted git repository. lcwik pushed a commit to branch go-sdk in repository https://gitbox.apache.org/repos/asf/beam.git
commit c67de937c7d732d68ef363ff46c18b77916938d5 Author: Henning Rohde <hero...@google.com> AuthorDate: Fri Jan 12 15:13:26 2018 -0800 Renamed Go runtime Caller to Func and added name --- sdks/go/pkg/beam/core/runtime/exec/callers.go | 400 ++++++---- sdks/go/pkg/beam/core/runtime/exec/callers.tmpl | 18 +- sdks/go/pkg/beam/core/runtime/exec/combine.go | 4 +- sdks/go/pkg/beam/core/util/reflectx/call.go | 51 +- sdks/go/pkg/beam/core/util/reflectx/calls.go | 968 ++++++++++++++---------- sdks/go/pkg/beam/core/util/reflectx/calls.tmpl | 38 +- sdks/go/pkg/beam/core/util/reflectx/json.go | 2 +- sdks/go/pkg/beam/transforms/filter/filter.go | 4 +- 8 files changed, 858 insertions(+), 627 deletions(-) diff --git a/sdks/go/pkg/beam/core/runtime/exec/callers.go b/sdks/go/pkg/beam/core/runtime/exec/callers.go index 8c374bf..b47751d 100644 --- a/sdks/go/pkg/beam/core/runtime/exec/callers.go +++ b/sdks/go/pkg/beam/core/runtime/exec/callers.go @@ -35,510 +35,598 @@ import ( // For now, we just do #2. func init() { - reflectx.RegisterCaller(reflect.TypeOf((*func([]byte, []byte) []byte)(nil)).Elem(), callMakerByteSliceM) - reflectx.RegisterCaller(reflect.TypeOf((*func(bool, bool) bool)(nil)).Elem(), callMakerBoolM) - reflectx.RegisterCaller(reflect.TypeOf((*func(string, string) string)(nil)).Elem(), callMakerStringM) - reflectx.RegisterCaller(reflect.TypeOf((*func(int, int) int)(nil)).Elem(), callMakerIntM) - reflectx.RegisterCaller(reflect.TypeOf((*func(int8, int8) int8)(nil)).Elem(), callMakerInt8M) - reflectx.RegisterCaller(reflect.TypeOf((*func(int16, int16) int16)(nil)).Elem(), callMakerInt16M) - reflectx.RegisterCaller(reflect.TypeOf((*func(int32, int32) int32)(nil)).Elem(), callMakerInt32M) - reflectx.RegisterCaller(reflect.TypeOf((*func(int64, int64) int64)(nil)).Elem(), callMakerInt64M) - reflectx.RegisterCaller(reflect.TypeOf((*func(uint, uint) uint)(nil)).Elem(), callMakerUintM) - reflectx.RegisterCaller(reflect.TypeOf((*func(uint8, uint8) uint8)(nil)).Elem(), callMakerUint8M) - reflectx.RegisterCaller(reflect.TypeOf((*func(uint16, uint16) uint16)(nil)).Elem(), callMakerUint16M) - reflectx.RegisterCaller(reflect.TypeOf((*func(uint32, uint32) uint32)(nil)).Elem(), callMakerUint32M) - reflectx.RegisterCaller(reflect.TypeOf((*func(uint64, uint64) uint64)(nil)).Elem(), callMakerUint64M) - reflectx.RegisterCaller(reflect.TypeOf((*func(float32, float32) float32)(nil)).Elem(), callMakerFloat32M) - reflectx.RegisterCaller(reflect.TypeOf((*func(float64, float64) float64)(nil)).Elem(), callMakerFloat64M) - reflectx.RegisterCaller(reflect.TypeOf((*func(typex.T, typex.T) typex.T)(nil)).Elem(), callMakerTypex_TM) - reflectx.RegisterCaller(reflect.TypeOf((*func(typex.U, typex.U) typex.U)(nil)).Elem(), callMakerTypex_UM) - reflectx.RegisterCaller(reflect.TypeOf((*func(typex.V, typex.V) typex.V)(nil)).Elem(), callMakerTypex_VM) - reflectx.RegisterCaller(reflect.TypeOf((*func(typex.W, typex.W) typex.W)(nil)).Elem(), callMakerTypex_WM) - reflectx.RegisterCaller(reflect.TypeOf((*func(typex.X, typex.X) typex.X)(nil)).Elem(), callMakerTypex_XM) - reflectx.RegisterCaller(reflect.TypeOf((*func(typex.Y, typex.Y) typex.Y)(nil)).Elem(), callMakerTypex_YM) - reflectx.RegisterCaller(reflect.TypeOf((*func(typex.Z, typex.Z) typex.Z)(nil)).Elem(), callMakerTypex_ZM) -} - -type nativeByteSliceMCaller struct { + reflectx.RegisterFunc(reflect.TypeOf((*func([]byte, []byte) []byte)(nil)).Elem(), funcMakerByteSliceM) + reflectx.RegisterFunc(reflect.TypeOf((*func(bool, bool) bool)(nil)).Elem(), funcMakerBoolM) + reflectx.RegisterFunc(reflect.TypeOf((*func(string, string) string)(nil)).Elem(), funcMakerStringM) + reflectx.RegisterFunc(reflect.TypeOf((*func(int, int) int)(nil)).Elem(), funcMakerIntM) + reflectx.RegisterFunc(reflect.TypeOf((*func(int8, int8) int8)(nil)).Elem(), funcMakerInt8M) + reflectx.RegisterFunc(reflect.TypeOf((*func(int16, int16) int16)(nil)).Elem(), funcMakerInt16M) + reflectx.RegisterFunc(reflect.TypeOf((*func(int32, int32) int32)(nil)).Elem(), funcMakerInt32M) + reflectx.RegisterFunc(reflect.TypeOf((*func(int64, int64) int64)(nil)).Elem(), funcMakerInt64M) + reflectx.RegisterFunc(reflect.TypeOf((*func(uint, uint) uint)(nil)).Elem(), funcMakerUintM) + reflectx.RegisterFunc(reflect.TypeOf((*func(uint8, uint8) uint8)(nil)).Elem(), funcMakerUint8M) + reflectx.RegisterFunc(reflect.TypeOf((*func(uint16, uint16) uint16)(nil)).Elem(), funcMakerUint16M) + reflectx.RegisterFunc(reflect.TypeOf((*func(uint32, uint32) uint32)(nil)).Elem(), funcMakerUint32M) + reflectx.RegisterFunc(reflect.TypeOf((*func(uint64, uint64) uint64)(nil)).Elem(), funcMakerUint64M) + reflectx.RegisterFunc(reflect.TypeOf((*func(float32, float32) float32)(nil)).Elem(), funcMakerFloat32M) + reflectx.RegisterFunc(reflect.TypeOf((*func(float64, float64) float64)(nil)).Elem(), funcMakerFloat64M) + reflectx.RegisterFunc(reflect.TypeOf((*func(typex.T, typex.T) typex.T)(nil)).Elem(), funcMakerTypex_TM) + reflectx.RegisterFunc(reflect.TypeOf((*func(typex.U, typex.U) typex.U)(nil)).Elem(), funcMakerTypex_UM) + reflectx.RegisterFunc(reflect.TypeOf((*func(typex.V, typex.V) typex.V)(nil)).Elem(), funcMakerTypex_VM) + reflectx.RegisterFunc(reflect.TypeOf((*func(typex.W, typex.W) typex.W)(nil)).Elem(), funcMakerTypex_WM) + reflectx.RegisterFunc(reflect.TypeOf((*func(typex.X, typex.X) typex.X)(nil)).Elem(), funcMakerTypex_XM) + reflectx.RegisterFunc(reflect.TypeOf((*func(typex.Y, typex.Y) typex.Y)(nil)).Elem(), funcMakerTypex_YM) + reflectx.RegisterFunc(reflect.TypeOf((*func(typex.Z, typex.Z) typex.Z)(nil)).Elem(), funcMakerTypex_ZM) +} + +type nativeByteSliceMFunc struct { fn func([]byte, []byte) []byte } -func callMakerByteSliceM(fn interface{}) reflectx.Caller { +func funcMakerByteSliceM(fn interface{}) reflectx.Func { f := fn.(func([]byte, []byte) []byte) - return &nativeByteSliceMCaller{fn: f} + return &nativeByteSliceMFunc{fn: f} } -func (c *nativeByteSliceMCaller) Type() reflect.Type { +func (c *nativeByteSliceMFunc) Name() string { + return reflectx.FunctionName(c.fn) +} + +func (c *nativeByteSliceMFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeByteSliceMCaller) Call(args []interface{}) []interface{} { +func (c *nativeByteSliceMFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].([]byte), args[1].([]byte)) return []interface{}{out} } -func (c *nativeByteSliceMCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeByteSliceMFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.([]byte), b.([]byte)) } -type nativeBoolMCaller struct { +type nativeBoolMFunc struct { fn func(bool, bool) bool } -func callMakerBoolM(fn interface{}) reflectx.Caller { +func funcMakerBoolM(fn interface{}) reflectx.Func { f := fn.(func(bool, bool) bool) - return &nativeBoolMCaller{fn: f} + return &nativeBoolMFunc{fn: f} +} + +func (c *nativeBoolMFunc) Name() string { + return reflectx.FunctionName(c.fn) } -func (c *nativeBoolMCaller) Type() reflect.Type { +func (c *nativeBoolMFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeBoolMCaller) Call(args []interface{}) []interface{} { +func (c *nativeBoolMFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(bool), args[1].(bool)) return []interface{}{out} } -func (c *nativeBoolMCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeBoolMFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(bool), b.(bool)) } -type nativeStringMCaller struct { +type nativeStringMFunc struct { fn func(string, string) string } -func callMakerStringM(fn interface{}) reflectx.Caller { +func funcMakerStringM(fn interface{}) reflectx.Func { f := fn.(func(string, string) string) - return &nativeStringMCaller{fn: f} + return &nativeStringMFunc{fn: f} +} + +func (c *nativeStringMFunc) Name() string { + return reflectx.FunctionName(c.fn) } -func (c *nativeStringMCaller) Type() reflect.Type { +func (c *nativeStringMFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeStringMCaller) Call(args []interface{}) []interface{} { +func (c *nativeStringMFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(string), args[1].(string)) return []interface{}{out} } -func (c *nativeStringMCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeStringMFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(string), b.(string)) } -type nativeIntMCaller struct { +type nativeIntMFunc struct { fn func(int, int) int } -func callMakerIntM(fn interface{}) reflectx.Caller { +func funcMakerIntM(fn interface{}) reflectx.Func { f := fn.(func(int, int) int) - return &nativeIntMCaller{fn: f} + return &nativeIntMFunc{fn: f} } -func (c *nativeIntMCaller) Type() reflect.Type { +func (c *nativeIntMFunc) Name() string { + return reflectx.FunctionName(c.fn) +} + +func (c *nativeIntMFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeIntMCaller) Call(args []interface{}) []interface{} { +func (c *nativeIntMFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(int), args[1].(int)) return []interface{}{out} } -func (c *nativeIntMCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeIntMFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(int), b.(int)) } -type nativeInt8MCaller struct { +type nativeInt8MFunc struct { fn func(int8, int8) int8 } -func callMakerInt8M(fn interface{}) reflectx.Caller { +func funcMakerInt8M(fn interface{}) reflectx.Func { f := fn.(func(int8, int8) int8) - return &nativeInt8MCaller{fn: f} + return &nativeInt8MFunc{fn: f} } -func (c *nativeInt8MCaller) Type() reflect.Type { +func (c *nativeInt8MFunc) Name() string { + return reflectx.FunctionName(c.fn) +} + +func (c *nativeInt8MFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeInt8MCaller) Call(args []interface{}) []interface{} { +func (c *nativeInt8MFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(int8), args[1].(int8)) return []interface{}{out} } -func (c *nativeInt8MCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeInt8MFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(int8), b.(int8)) } -type nativeInt16MCaller struct { +type nativeInt16MFunc struct { fn func(int16, int16) int16 } -func callMakerInt16M(fn interface{}) reflectx.Caller { +func funcMakerInt16M(fn interface{}) reflectx.Func { f := fn.(func(int16, int16) int16) - return &nativeInt16MCaller{fn: f} + return &nativeInt16MFunc{fn: f} +} + +func (c *nativeInt16MFunc) Name() string { + return reflectx.FunctionName(c.fn) } -func (c *nativeInt16MCaller) Type() reflect.Type { +func (c *nativeInt16MFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeInt16MCaller) Call(args []interface{}) []interface{} { +func (c *nativeInt16MFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(int16), args[1].(int16)) return []interface{}{out} } -func (c *nativeInt16MCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeInt16MFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(int16), b.(int16)) } -type nativeInt32MCaller struct { +type nativeInt32MFunc struct { fn func(int32, int32) int32 } -func callMakerInt32M(fn interface{}) reflectx.Caller { +func funcMakerInt32M(fn interface{}) reflectx.Func { f := fn.(func(int32, int32) int32) - return &nativeInt32MCaller{fn: f} + return &nativeInt32MFunc{fn: f} +} + +func (c *nativeInt32MFunc) Name() string { + return reflectx.FunctionName(c.fn) } -func (c *nativeInt32MCaller) Type() reflect.Type { +func (c *nativeInt32MFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeInt32MCaller) Call(args []interface{}) []interface{} { +func (c *nativeInt32MFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(int32), args[1].(int32)) return []interface{}{out} } -func (c *nativeInt32MCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeInt32MFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(int32), b.(int32)) } -type nativeInt64MCaller struct { +type nativeInt64MFunc struct { fn func(int64, int64) int64 } -func callMakerInt64M(fn interface{}) reflectx.Caller { +func funcMakerInt64M(fn interface{}) reflectx.Func { f := fn.(func(int64, int64) int64) - return &nativeInt64MCaller{fn: f} + return &nativeInt64MFunc{fn: f} } -func (c *nativeInt64MCaller) Type() reflect.Type { +func (c *nativeInt64MFunc) Name() string { + return reflectx.FunctionName(c.fn) +} + +func (c *nativeInt64MFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeInt64MCaller) Call(args []interface{}) []interface{} { +func (c *nativeInt64MFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(int64), args[1].(int64)) return []interface{}{out} } -func (c *nativeInt64MCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeInt64MFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(int64), b.(int64)) } -type nativeUintMCaller struct { +type nativeUintMFunc struct { fn func(uint, uint) uint } -func callMakerUintM(fn interface{}) reflectx.Caller { +func funcMakerUintM(fn interface{}) reflectx.Func { f := fn.(func(uint, uint) uint) - return &nativeUintMCaller{fn: f} + return &nativeUintMFunc{fn: f} } -func (c *nativeUintMCaller) Type() reflect.Type { +func (c *nativeUintMFunc) Name() string { + return reflectx.FunctionName(c.fn) +} + +func (c *nativeUintMFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeUintMCaller) Call(args []interface{}) []interface{} { +func (c *nativeUintMFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(uint), args[1].(uint)) return []interface{}{out} } -func (c *nativeUintMCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeUintMFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(uint), b.(uint)) } -type nativeUint8MCaller struct { +type nativeUint8MFunc struct { fn func(uint8, uint8) uint8 } -func callMakerUint8M(fn interface{}) reflectx.Caller { +func funcMakerUint8M(fn interface{}) reflectx.Func { f := fn.(func(uint8, uint8) uint8) - return &nativeUint8MCaller{fn: f} + return &nativeUint8MFunc{fn: f} +} + +func (c *nativeUint8MFunc) Name() string { + return reflectx.FunctionName(c.fn) } -func (c *nativeUint8MCaller) Type() reflect.Type { +func (c *nativeUint8MFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeUint8MCaller) Call(args []interface{}) []interface{} { +func (c *nativeUint8MFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(uint8), args[1].(uint8)) return []interface{}{out} } -func (c *nativeUint8MCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeUint8MFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(uint8), b.(uint8)) } -type nativeUint16MCaller struct { +type nativeUint16MFunc struct { fn func(uint16, uint16) uint16 } -func callMakerUint16M(fn interface{}) reflectx.Caller { +func funcMakerUint16M(fn interface{}) reflectx.Func { f := fn.(func(uint16, uint16) uint16) - return &nativeUint16MCaller{fn: f} + return &nativeUint16MFunc{fn: f} +} + +func (c *nativeUint16MFunc) Name() string { + return reflectx.FunctionName(c.fn) } -func (c *nativeUint16MCaller) Type() reflect.Type { +func (c *nativeUint16MFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeUint16MCaller) Call(args []interface{}) []interface{} { +func (c *nativeUint16MFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(uint16), args[1].(uint16)) return []interface{}{out} } -func (c *nativeUint16MCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeUint16MFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(uint16), b.(uint16)) } -type nativeUint32MCaller struct { +type nativeUint32MFunc struct { fn func(uint32, uint32) uint32 } -func callMakerUint32M(fn interface{}) reflectx.Caller { +func funcMakerUint32M(fn interface{}) reflectx.Func { f := fn.(func(uint32, uint32) uint32) - return &nativeUint32MCaller{fn: f} + return &nativeUint32MFunc{fn: f} } -func (c *nativeUint32MCaller) Type() reflect.Type { +func (c *nativeUint32MFunc) Name() string { + return reflectx.FunctionName(c.fn) +} + +func (c *nativeUint32MFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeUint32MCaller) Call(args []interface{}) []interface{} { +func (c *nativeUint32MFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(uint32), args[1].(uint32)) return []interface{}{out} } -func (c *nativeUint32MCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeUint32MFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(uint32), b.(uint32)) } -type nativeUint64MCaller struct { +type nativeUint64MFunc struct { fn func(uint64, uint64) uint64 } -func callMakerUint64M(fn interface{}) reflectx.Caller { +func funcMakerUint64M(fn interface{}) reflectx.Func { f := fn.(func(uint64, uint64) uint64) - return &nativeUint64MCaller{fn: f} + return &nativeUint64MFunc{fn: f} +} + +func (c *nativeUint64MFunc) Name() string { + return reflectx.FunctionName(c.fn) } -func (c *nativeUint64MCaller) Type() reflect.Type { +func (c *nativeUint64MFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeUint64MCaller) Call(args []interface{}) []interface{} { +func (c *nativeUint64MFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(uint64), args[1].(uint64)) return []interface{}{out} } -func (c *nativeUint64MCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeUint64MFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(uint64), b.(uint64)) } -type nativeFloat32MCaller struct { +type nativeFloat32MFunc struct { fn func(float32, float32) float32 } -func callMakerFloat32M(fn interface{}) reflectx.Caller { +func funcMakerFloat32M(fn interface{}) reflectx.Func { f := fn.(func(float32, float32) float32) - return &nativeFloat32MCaller{fn: f} + return &nativeFloat32MFunc{fn: f} +} + +func (c *nativeFloat32MFunc) Name() string { + return reflectx.FunctionName(c.fn) } -func (c *nativeFloat32MCaller) Type() reflect.Type { +func (c *nativeFloat32MFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeFloat32MCaller) Call(args []interface{}) []interface{} { +func (c *nativeFloat32MFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(float32), args[1].(float32)) return []interface{}{out} } -func (c *nativeFloat32MCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeFloat32MFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(float32), b.(float32)) } -type nativeFloat64MCaller struct { +type nativeFloat64MFunc struct { fn func(float64, float64) float64 } -func callMakerFloat64M(fn interface{}) reflectx.Caller { +func funcMakerFloat64M(fn interface{}) reflectx.Func { f := fn.(func(float64, float64) float64) - return &nativeFloat64MCaller{fn: f} + return &nativeFloat64MFunc{fn: f} } -func (c *nativeFloat64MCaller) Type() reflect.Type { +func (c *nativeFloat64MFunc) Name() string { + return reflectx.FunctionName(c.fn) +} + +func (c *nativeFloat64MFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeFloat64MCaller) Call(args []interface{}) []interface{} { +func (c *nativeFloat64MFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(float64), args[1].(float64)) return []interface{}{out} } -func (c *nativeFloat64MCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeFloat64MFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(float64), b.(float64)) } -type nativeTypex_TMCaller struct { +type nativeTypex_TMFunc struct { fn func(typex.T, typex.T) typex.T } -func callMakerTypex_TM(fn interface{}) reflectx.Caller { +func funcMakerTypex_TM(fn interface{}) reflectx.Func { f := fn.(func(typex.T, typex.T) typex.T) - return &nativeTypex_TMCaller{fn: f} + return &nativeTypex_TMFunc{fn: f} } -func (c *nativeTypex_TMCaller) Type() reflect.Type { +func (c *nativeTypex_TMFunc) Name() string { + return reflectx.FunctionName(c.fn) +} + +func (c *nativeTypex_TMFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeTypex_TMCaller) Call(args []interface{}) []interface{} { +func (c *nativeTypex_TMFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(typex.T), args[1].(typex.T)) return []interface{}{out} } -func (c *nativeTypex_TMCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeTypex_TMFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(typex.T), b.(typex.T)) } -type nativeTypex_UMCaller struct { +type nativeTypex_UMFunc struct { fn func(typex.U, typex.U) typex.U } -func callMakerTypex_UM(fn interface{}) reflectx.Caller { +func funcMakerTypex_UM(fn interface{}) reflectx.Func { f := fn.(func(typex.U, typex.U) typex.U) - return &nativeTypex_UMCaller{fn: f} + return &nativeTypex_UMFunc{fn: f} +} + +func (c *nativeTypex_UMFunc) Name() string { + return reflectx.FunctionName(c.fn) } -func (c *nativeTypex_UMCaller) Type() reflect.Type { +func (c *nativeTypex_UMFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeTypex_UMCaller) Call(args []interface{}) []interface{} { +func (c *nativeTypex_UMFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(typex.U), args[1].(typex.U)) return []interface{}{out} } -func (c *nativeTypex_UMCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeTypex_UMFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(typex.U), b.(typex.U)) } -type nativeTypex_VMCaller struct { +type nativeTypex_VMFunc struct { fn func(typex.V, typex.V) typex.V } -func callMakerTypex_VM(fn interface{}) reflectx.Caller { +func funcMakerTypex_VM(fn interface{}) reflectx.Func { f := fn.(func(typex.V, typex.V) typex.V) - return &nativeTypex_VMCaller{fn: f} + return &nativeTypex_VMFunc{fn: f} +} + +func (c *nativeTypex_VMFunc) Name() string { + return reflectx.FunctionName(c.fn) } -func (c *nativeTypex_VMCaller) Type() reflect.Type { +func (c *nativeTypex_VMFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeTypex_VMCaller) Call(args []interface{}) []interface{} { +func (c *nativeTypex_VMFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(typex.V), args[1].(typex.V)) return []interface{}{out} } -func (c *nativeTypex_VMCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeTypex_VMFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(typex.V), b.(typex.V)) } -type nativeTypex_WMCaller struct { +type nativeTypex_WMFunc struct { fn func(typex.W, typex.W) typex.W } -func callMakerTypex_WM(fn interface{}) reflectx.Caller { +func funcMakerTypex_WM(fn interface{}) reflectx.Func { f := fn.(func(typex.W, typex.W) typex.W) - return &nativeTypex_WMCaller{fn: f} + return &nativeTypex_WMFunc{fn: f} } -func (c *nativeTypex_WMCaller) Type() reflect.Type { +func (c *nativeTypex_WMFunc) Name() string { + return reflectx.FunctionName(c.fn) +} + +func (c *nativeTypex_WMFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeTypex_WMCaller) Call(args []interface{}) []interface{} { +func (c *nativeTypex_WMFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(typex.W), args[1].(typex.W)) return []interface{}{out} } -func (c *nativeTypex_WMCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeTypex_WMFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(typex.W), b.(typex.W)) } -type nativeTypex_XMCaller struct { +type nativeTypex_XMFunc struct { fn func(typex.X, typex.X) typex.X } -func callMakerTypex_XM(fn interface{}) reflectx.Caller { +func funcMakerTypex_XM(fn interface{}) reflectx.Func { f := fn.(func(typex.X, typex.X) typex.X) - return &nativeTypex_XMCaller{fn: f} + return &nativeTypex_XMFunc{fn: f} } -func (c *nativeTypex_XMCaller) Type() reflect.Type { +func (c *nativeTypex_XMFunc) Name() string { + return reflectx.FunctionName(c.fn) +} + +func (c *nativeTypex_XMFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeTypex_XMCaller) Call(args []interface{}) []interface{} { +func (c *nativeTypex_XMFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(typex.X), args[1].(typex.X)) return []interface{}{out} } -func (c *nativeTypex_XMCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeTypex_XMFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(typex.X), b.(typex.X)) } -type nativeTypex_YMCaller struct { +type nativeTypex_YMFunc struct { fn func(typex.Y, typex.Y) typex.Y } -func callMakerTypex_YM(fn interface{}) reflectx.Caller { +func funcMakerTypex_YM(fn interface{}) reflectx.Func { f := fn.(func(typex.Y, typex.Y) typex.Y) - return &nativeTypex_YMCaller{fn: f} + return &nativeTypex_YMFunc{fn: f} +} + +func (c *nativeTypex_YMFunc) Name() string { + return reflectx.FunctionName(c.fn) } -func (c *nativeTypex_YMCaller) Type() reflect.Type { +func (c *nativeTypex_YMFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeTypex_YMCaller) Call(args []interface{}) []interface{} { +func (c *nativeTypex_YMFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(typex.Y), args[1].(typex.Y)) return []interface{}{out} } -func (c *nativeTypex_YMCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeTypex_YMFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(typex.Y), b.(typex.Y)) } -type nativeTypex_ZMCaller struct { +type nativeTypex_ZMFunc struct { fn func(typex.Z, typex.Z) typex.Z } -func callMakerTypex_ZM(fn interface{}) reflectx.Caller { +func funcMakerTypex_ZM(fn interface{}) reflectx.Func { f := fn.(func(typex.Z, typex.Z) typex.Z) - return &nativeTypex_ZMCaller{fn: f} + return &nativeTypex_ZMFunc{fn: f} +} + +func (c *nativeTypex_ZMFunc) Name() string { + return reflectx.FunctionName(c.fn) } -func (c *nativeTypex_ZMCaller) Type() reflect.Type { +func (c *nativeTypex_ZMFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *nativeTypex_ZMCaller) Call(args []interface{}) []interface{} { +func (c *nativeTypex_ZMFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].(typex.Z), args[1].(typex.Z)) return []interface{}{out} } -func (c *nativeTypex_ZMCaller) Call2x1(a, b interface{}) interface{} { +func (c *nativeTypex_ZMFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.(typex.Z), b.(typex.Z)) } diff --git a/sdks/go/pkg/beam/core/runtime/exec/callers.tmpl b/sdks/go/pkg/beam/core/runtime/exec/callers.tmpl index 36d427b..10de8a0 100644 --- a/sdks/go/pkg/beam/core/runtime/exec/callers.tmpl +++ b/sdks/go/pkg/beam/core/runtime/exec/callers.tmpl @@ -34,30 +34,34 @@ import ( func init() { {{- range $x := .X}} - reflectx.RegisterCaller(reflect.TypeOf((*func ({{$x.Type}}, {{$x.Type}}){{$x.Type}})(nil)).Elem(), callMaker{{$x.Name}}M) + reflectx.RegisterFunc(reflect.TypeOf((*func ({{$x.Type}}, {{$x.Type}}){{$x.Type}})(nil)).Elem(), funcMaker{{$x.Name}}M) {{- end}} } {{range $x := .X}} -type native{{$x.Name}}MCaller struct { +type native{{$x.Name}}MFunc struct { fn func ({{$x.Type}}, {{$x.Type}}){{$x.Type}} } -func callMaker{{$x.Name}}M(fn interface{}) reflectx.Caller { +func funcMaker{{$x.Name}}M(fn interface{}) reflectx.Func { f := fn.(func ({{$x.Type}}, {{$x.Type}}){{$x.Type}}) - return &native{{$x.Name}}MCaller{fn: f} + return &native{{$x.Name}}MFunc{fn: f} } -func (c *native{{$x.Name}}MCaller) Type() reflect.Type { +func (c *native{{$x.Name}}MFunc) Name() string { + return reflectx.FunctionName(c.fn) +} + +func (c *native{{$x.Name}}MFunc) Type() reflect.Type { return reflect.TypeOf(c.fn) } -func (c *native{{$x.Name}}MCaller) Call(args []interface{}) []interface{} { +func (c *native{{$x.Name}}MFunc) Call(args []interface{}) []interface{} { out := c.fn(args[0].({{$x.Type}}), args[1].({{$x.Type}})) return []interface{}{out} } -func (c *native{{$x.Name}}MCaller) Call2x1(a, b interface{}) interface{} { +func (c *native{{$x.Name}}MFunc) Call2x1(a, b interface{}) interface{} { return c.fn(a.({{$x.Type}}), b.({{$x.Type}})) } {{end}} diff --git a/sdks/go/pkg/beam/core/runtime/exec/combine.go b/sdks/go/pkg/beam/core/runtime/exec/combine.go index 84c064a..83b42d2 100644 --- a/sdks/go/pkg/beam/core/runtime/exec/combine.go +++ b/sdks/go/pkg/beam/core/runtime/exec/combine.go @@ -39,7 +39,7 @@ type Combine struct { first bool isPerKey, usesKey bool - mergeFn reflectx.Caller2x1 // optimized caller in the case of binary merge accumulators + mergeFn reflectx.Func2x1 // optimized caller in the case of binary merge accumulators status Status err errorx.GuardedError @@ -60,7 +60,7 @@ func (n *Combine) Up(ctx context.Context) error { } if n.Edge.CombineFn.AddInputFn() == nil { - n.mergeFn = reflectx.MakeCaller2x1(n.Edge.CombineFn.MergeAccumulatorsFn().Fn.Interface()) + n.mergeFn = reflectx.MakeFunc2x1(n.Edge.CombineFn.MergeAccumulatorsFn().Fn.Interface()) } // TODO(herohde) 6/28/2017: maybe record the per-key mode in the Edge diff --git a/sdks/go/pkg/beam/core/util/reflectx/call.go b/sdks/go/pkg/beam/core/util/reflectx/call.go index ebac4da..05b40ef 100644 --- a/sdks/go/pkg/beam/core/util/reflectx/call.go +++ b/sdks/go/pkg/beam/core/util/reflectx/call.go @@ -25,9 +25,12 @@ import ( //go:generate specialize --input=calls.tmpl -// Caller is an untyped function call interface. This indirection allows -// us to avoid reflection call overhead for certain types. -type Caller interface { +// Func represents a callable untyped function. This indirection allows +// us to avoid reflection call overhead for certain types as well as +// faster dynamic function implementations. +type Func interface { + // Name returns the name of the function. + Name() string // Type returns the type. Type() reflect.Type // Call invokes the implicit fn with arguments. @@ -35,29 +38,29 @@ type Caller interface { } var ( - callers = make(map[string]func(interface{}) Caller) - callersMu sync.Mutex + funcs = make(map[string]func(interface{}) Func) + funcsMu sync.Mutex ) -// RegisterCaller registers an custom caller factory for the given type, such as -// "func(int)bool". If multiple caller factories are registered for the same type, +// RegisterFunc registers an custom reflectFunc factory for the given type, such as +// "func(int)bool". If multiple func factories are registered for the same type, // the last registration wins. -func RegisterCaller(t reflect.Type, maker func(interface{}) Caller) { - callersMu.Lock() - defer callersMu.Unlock() +func RegisterFunc(t reflect.Type, maker func(interface{}) Func) { + funcsMu.Lock() + defer funcsMu.Unlock() key := t.String() - if _, exists := callers[key]; exists { - log.Warnf(context.Background(), "Caller for %v already registered. Overwriting.", key) + if _, exists := funcs[key]; exists { + log.Warnf(context.Background(), "Func for %v already registered. Overwriting.", key) } - callers[key] = maker + funcs[key] = maker } -// MakeCaller returns a caller for given function. -func MakeCaller(fn interface{}) Caller { - callersMu.Lock() - maker, exists := callers[reflect.TypeOf(fn).String()] - callersMu.Unlock() +// MakeFunc returns a reflectFunc for given function. +func MakeFunc(fn interface{}) Func { + funcsMu.Lock() + maker, exists := funcs[reflect.TypeOf(fn).String()] + funcsMu.Unlock() if exists { return maker(fn) @@ -66,18 +69,22 @@ func MakeCaller(fn interface{}) Caller { // If no specialized implementation is available, we use the standard // reflection-based call. - return &caller{fn: reflect.ValueOf(fn)} + return &reflectFunc{fn: reflect.ValueOf(fn)} } -type caller struct { +type reflectFunc struct { fn reflect.Value } -func (c *caller) Type() reflect.Type { +func (c *reflectFunc) Name() string { + return FunctionName(c.fn.Interface()) +} + +func (c *reflectFunc) Type() reflect.Type { return c.fn.Type() } -func (c *caller) Call(args []interface{}) []interface{} { +func (c *reflectFunc) Call(args []interface{}) []interface{} { return Interface(c.fn.Call(ValueOf(args))) } diff --git a/sdks/go/pkg/beam/core/util/reflectx/calls.go b/sdks/go/pkg/beam/core/util/reflectx/calls.go index 2799b8a..a1bfe6b 100644 --- a/sdks/go/pkg/beam/core/util/reflectx/calls.go +++ b/sdks/go/pkg/beam/core/util/reflectx/calls.go @@ -19,1195 +19,1323 @@ package reflectx import "reflect" -// Generated arity-specialized Caller implementations to avoid runtime temporary +// Generated arity-specialized Func implementations to avoid runtime temporary // slices. Code that knows the arity can potentially avoid that overhead in // addition to avoiding the reflection call overhead. // -// We force CallerZxY to implement Caller as well to have a single registry. Concrete -// caller implementations should implement the most specific supported variant. This -// also allows more specific intermediate interfaces, such as Caller2bool, to be added +// We force FuncXxY to implement Func as well to have a single registry. Concrete +// Func implementations should implement the most specific supported variant. This +// also allows more specific intermediate interfaces, such as Func2xbool, to be added // later. -type Caller0x0 interface { - Caller +type Func0x0 interface { + Func Call0x0() } -type shimCaller0x0 struct { - inner Caller +type shimFunc0x0 struct { + inner Func } -func (c *shimCaller0x0) Type() reflect.Type { +func (c *shimFunc0x0) Name() string { + return c.inner.Name() +} + +func (c *shimFunc0x0) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller0x0) Call(args []interface{}) []interface{} { +func (c *shimFunc0x0) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller0x0) Call0x0() { +func (c *shimFunc0x0) Call0x0() { ret := c.inner.Call([]interface{}{}) _ = ret return } -func ToCaller0x0(c Caller) Caller0x0 { +func ToFunc0x0(c Func) Func0x0 { if c.Type().NumIn() != 0 || c.Type().NumOut() != 0 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller0x0); ok { + if sc, ok := c.(Func0x0); ok { return sc } - return &shimCaller0x0{inner: c} + return &shimFunc0x0{inner: c} } -func MakeCaller0x0(fn interface{}) Caller0x0 { - return ToCaller0x0(MakeCaller(fn)) +func MakeFunc0x0(fn interface{}) Func0x0 { + return ToFunc0x0(MakeFunc(fn)) } -type Caller0x1 interface { - Caller +type Func0x1 interface { + Func Call0x1() interface{} } -type shimCaller0x1 struct { - inner Caller +type shimFunc0x1 struct { + inner Func +} + +func (c *shimFunc0x1) Name() string { + return c.inner.Name() } -func (c *shimCaller0x1) Type() reflect.Type { +func (c *shimFunc0x1) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller0x1) Call(args []interface{}) []interface{} { +func (c *shimFunc0x1) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller0x1) Call0x1() interface{} { +func (c *shimFunc0x1) Call0x1() interface{} { ret := c.inner.Call([]interface{}{}) _ = ret return ret[0] } -func ToCaller0x1(c Caller) Caller0x1 { +func ToFunc0x1(c Func) Func0x1 { if c.Type().NumIn() != 0 || c.Type().NumOut() != 1 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller0x1); ok { + if sc, ok := c.(Func0x1); ok { return sc } - return &shimCaller0x1{inner: c} + return &shimFunc0x1{inner: c} } -func MakeCaller0x1(fn interface{}) Caller0x1 { - return ToCaller0x1(MakeCaller(fn)) +func MakeFunc0x1(fn interface{}) Func0x1 { + return ToFunc0x1(MakeFunc(fn)) } -type Caller0x2 interface { - Caller +type Func0x2 interface { + Func Call0x2() (interface{}, interface{}) } -type shimCaller0x2 struct { - inner Caller +type shimFunc0x2 struct { + inner Func } -func (c *shimCaller0x2) Type() reflect.Type { +func (c *shimFunc0x2) Name() string { + return c.inner.Name() +} + +func (c *shimFunc0x2) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller0x2) Call(args []interface{}) []interface{} { +func (c *shimFunc0x2) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller0x2) Call0x2() (interface{}, interface{}) { +func (c *shimFunc0x2) Call0x2() (interface{}, interface{}) { ret := c.inner.Call([]interface{}{}) _ = ret return ret[0], ret[1] } -func ToCaller0x2(c Caller) Caller0x2 { +func ToFunc0x2(c Func) Func0x2 { if c.Type().NumIn() != 0 || c.Type().NumOut() != 2 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller0x2); ok { + if sc, ok := c.(Func0x2); ok { return sc } - return &shimCaller0x2{inner: c} + return &shimFunc0x2{inner: c} } -func MakeCaller0x2(fn interface{}) Caller0x2 { - return ToCaller0x2(MakeCaller(fn)) +func MakeFunc0x2(fn interface{}) Func0x2 { + return ToFunc0x2(MakeFunc(fn)) } -type Caller0x3 interface { - Caller +type Func0x3 interface { + Func Call0x3() (interface{}, interface{}, interface{}) } -type shimCaller0x3 struct { - inner Caller +type shimFunc0x3 struct { + inner Func +} + +func (c *shimFunc0x3) Name() string { + return c.inner.Name() } -func (c *shimCaller0x3) Type() reflect.Type { +func (c *shimFunc0x3) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller0x3) Call(args []interface{}) []interface{} { +func (c *shimFunc0x3) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller0x3) Call0x3() (interface{}, interface{}, interface{}) { +func (c *shimFunc0x3) Call0x3() (interface{}, interface{}, interface{}) { ret := c.inner.Call([]interface{}{}) _ = ret return ret[0], ret[1], ret[2] } -func ToCaller0x3(c Caller) Caller0x3 { +func ToFunc0x3(c Func) Func0x3 { if c.Type().NumIn() != 0 || c.Type().NumOut() != 3 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller0x3); ok { + if sc, ok := c.(Func0x3); ok { return sc } - return &shimCaller0x3{inner: c} + return &shimFunc0x3{inner: c} } -func MakeCaller0x3(fn interface{}) Caller0x3 { - return ToCaller0x3(MakeCaller(fn)) +func MakeFunc0x3(fn interface{}) Func0x3 { + return ToFunc0x3(MakeFunc(fn)) } -type Caller1x0 interface { - Caller +type Func1x0 interface { + Func Call1x0(interface{}) } -type shimCaller1x0 struct { - inner Caller +type shimFunc1x0 struct { + inner Func } -func (c *shimCaller1x0) Type() reflect.Type { +func (c *shimFunc1x0) Name() string { + return c.inner.Name() +} + +func (c *shimFunc1x0) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller1x0) Call(args []interface{}) []interface{} { +func (c *shimFunc1x0) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller1x0) Call1x0(arg0 interface{}) { +func (c *shimFunc1x0) Call1x0(arg0 interface{}) { ret := c.inner.Call([]interface{}{arg0}) _ = ret return } -func ToCaller1x0(c Caller) Caller1x0 { +func ToFunc1x0(c Func) Func1x0 { if c.Type().NumIn() != 1 || c.Type().NumOut() != 0 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller1x0); ok { + if sc, ok := c.(Func1x0); ok { return sc } - return &shimCaller1x0{inner: c} + return &shimFunc1x0{inner: c} } -func MakeCaller1x0(fn interface{}) Caller1x0 { - return ToCaller1x0(MakeCaller(fn)) +func MakeFunc1x0(fn interface{}) Func1x0 { + return ToFunc1x0(MakeFunc(fn)) } -type Caller1x1 interface { - Caller +type Func1x1 interface { + Func Call1x1(interface{}) interface{} } -type shimCaller1x1 struct { - inner Caller +type shimFunc1x1 struct { + inner Func +} + +func (c *shimFunc1x1) Name() string { + return c.inner.Name() } -func (c *shimCaller1x1) Type() reflect.Type { +func (c *shimFunc1x1) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller1x1) Call(args []interface{}) []interface{} { +func (c *shimFunc1x1) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller1x1) Call1x1(arg0 interface{}) interface{} { +func (c *shimFunc1x1) Call1x1(arg0 interface{}) interface{} { ret := c.inner.Call([]interface{}{arg0}) _ = ret return ret[0] } -func ToCaller1x1(c Caller) Caller1x1 { +func ToFunc1x1(c Func) Func1x1 { if c.Type().NumIn() != 1 || c.Type().NumOut() != 1 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller1x1); ok { + if sc, ok := c.(Func1x1); ok { return sc } - return &shimCaller1x1{inner: c} + return &shimFunc1x1{inner: c} } -func MakeCaller1x1(fn interface{}) Caller1x1 { - return ToCaller1x1(MakeCaller(fn)) +func MakeFunc1x1(fn interface{}) Func1x1 { + return ToFunc1x1(MakeFunc(fn)) } -type Caller1x2 interface { - Caller +type Func1x2 interface { + Func Call1x2(interface{}) (interface{}, interface{}) } -type shimCaller1x2 struct { - inner Caller +type shimFunc1x2 struct { + inner Func } -func (c *shimCaller1x2) Type() reflect.Type { +func (c *shimFunc1x2) Name() string { + return c.inner.Name() +} + +func (c *shimFunc1x2) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller1x2) Call(args []interface{}) []interface{} { +func (c *shimFunc1x2) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller1x2) Call1x2(arg0 interface{}) (interface{}, interface{}) { +func (c *shimFunc1x2) Call1x2(arg0 interface{}) (interface{}, interface{}) { ret := c.inner.Call([]interface{}{arg0}) _ = ret return ret[0], ret[1] } -func ToCaller1x2(c Caller) Caller1x2 { +func ToFunc1x2(c Func) Func1x2 { if c.Type().NumIn() != 1 || c.Type().NumOut() != 2 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller1x2); ok { + if sc, ok := c.(Func1x2); ok { return sc } - return &shimCaller1x2{inner: c} + return &shimFunc1x2{inner: c} } -func MakeCaller1x2(fn interface{}) Caller1x2 { - return ToCaller1x2(MakeCaller(fn)) +func MakeFunc1x2(fn interface{}) Func1x2 { + return ToFunc1x2(MakeFunc(fn)) } -type Caller1x3 interface { - Caller +type Func1x3 interface { + Func Call1x3(interface{}) (interface{}, interface{}, interface{}) } -type shimCaller1x3 struct { - inner Caller +type shimFunc1x3 struct { + inner Func +} + +func (c *shimFunc1x3) Name() string { + return c.inner.Name() } -func (c *shimCaller1x3) Type() reflect.Type { +func (c *shimFunc1x3) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller1x3) Call(args []interface{}) []interface{} { +func (c *shimFunc1x3) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller1x3) Call1x3(arg0 interface{}) (interface{}, interface{}, interface{}) { +func (c *shimFunc1x3) Call1x3(arg0 interface{}) (interface{}, interface{}, interface{}) { ret := c.inner.Call([]interface{}{arg0}) _ = ret return ret[0], ret[1], ret[2] } -func ToCaller1x3(c Caller) Caller1x3 { +func ToFunc1x3(c Func) Func1x3 { if c.Type().NumIn() != 1 || c.Type().NumOut() != 3 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller1x3); ok { + if sc, ok := c.(Func1x3); ok { return sc } - return &shimCaller1x3{inner: c} + return &shimFunc1x3{inner: c} } -func MakeCaller1x3(fn interface{}) Caller1x3 { - return ToCaller1x3(MakeCaller(fn)) +func MakeFunc1x3(fn interface{}) Func1x3 { + return ToFunc1x3(MakeFunc(fn)) } -type Caller2x0 interface { - Caller +type Func2x0 interface { + Func Call2x0(interface{}, interface{}) } -type shimCaller2x0 struct { - inner Caller +type shimFunc2x0 struct { + inner Func } -func (c *shimCaller2x0) Type() reflect.Type { +func (c *shimFunc2x0) Name() string { + return c.inner.Name() +} + +func (c *shimFunc2x0) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller2x0) Call(args []interface{}) []interface{} { +func (c *shimFunc2x0) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller2x0) Call2x0(arg0, arg1 interface{}) { +func (c *shimFunc2x0) Call2x0(arg0, arg1 interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1}) _ = ret return } -func ToCaller2x0(c Caller) Caller2x0 { +func ToFunc2x0(c Func) Func2x0 { if c.Type().NumIn() != 2 || c.Type().NumOut() != 0 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller2x0); ok { + if sc, ok := c.(Func2x0); ok { return sc } - return &shimCaller2x0{inner: c} + return &shimFunc2x0{inner: c} } -func MakeCaller2x0(fn interface{}) Caller2x0 { - return ToCaller2x0(MakeCaller(fn)) +func MakeFunc2x0(fn interface{}) Func2x0 { + return ToFunc2x0(MakeFunc(fn)) } -type Caller2x1 interface { - Caller +type Func2x1 interface { + Func Call2x1(interface{}, interface{}) interface{} } -type shimCaller2x1 struct { - inner Caller +type shimFunc2x1 struct { + inner Func +} + +func (c *shimFunc2x1) Name() string { + return c.inner.Name() } -func (c *shimCaller2x1) Type() reflect.Type { +func (c *shimFunc2x1) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller2x1) Call(args []interface{}) []interface{} { +func (c *shimFunc2x1) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller2x1) Call2x1(arg0, arg1 interface{}) interface{} { +func (c *shimFunc2x1) Call2x1(arg0, arg1 interface{}) interface{} { ret := c.inner.Call([]interface{}{arg0, arg1}) _ = ret return ret[0] } -func ToCaller2x1(c Caller) Caller2x1 { +func ToFunc2x1(c Func) Func2x1 { if c.Type().NumIn() != 2 || c.Type().NumOut() != 1 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller2x1); ok { + if sc, ok := c.(Func2x1); ok { return sc } - return &shimCaller2x1{inner: c} + return &shimFunc2x1{inner: c} } -func MakeCaller2x1(fn interface{}) Caller2x1 { - return ToCaller2x1(MakeCaller(fn)) +func MakeFunc2x1(fn interface{}) Func2x1 { + return ToFunc2x1(MakeFunc(fn)) } -type Caller2x2 interface { - Caller +type Func2x2 interface { + Func Call2x2(interface{}, interface{}) (interface{}, interface{}) } -type shimCaller2x2 struct { - inner Caller +type shimFunc2x2 struct { + inner Func } -func (c *shimCaller2x2) Type() reflect.Type { +func (c *shimFunc2x2) Name() string { + return c.inner.Name() +} + +func (c *shimFunc2x2) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller2x2) Call(args []interface{}) []interface{} { +func (c *shimFunc2x2) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller2x2) Call2x2(arg0, arg1 interface{}) (interface{}, interface{}) { +func (c *shimFunc2x2) Call2x2(arg0, arg1 interface{}) (interface{}, interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1}) _ = ret return ret[0], ret[1] } -func ToCaller2x2(c Caller) Caller2x2 { +func ToFunc2x2(c Func) Func2x2 { if c.Type().NumIn() != 2 || c.Type().NumOut() != 2 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller2x2); ok { + if sc, ok := c.(Func2x2); ok { return sc } - return &shimCaller2x2{inner: c} + return &shimFunc2x2{inner: c} } -func MakeCaller2x2(fn interface{}) Caller2x2 { - return ToCaller2x2(MakeCaller(fn)) +func MakeFunc2x2(fn interface{}) Func2x2 { + return ToFunc2x2(MakeFunc(fn)) } -type Caller2x3 interface { - Caller +type Func2x3 interface { + Func Call2x3(interface{}, interface{}) (interface{}, interface{}, interface{}) } -type shimCaller2x3 struct { - inner Caller +type shimFunc2x3 struct { + inner Func +} + +func (c *shimFunc2x3) Name() string { + return c.inner.Name() } -func (c *shimCaller2x3) Type() reflect.Type { +func (c *shimFunc2x3) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller2x3) Call(args []interface{}) []interface{} { +func (c *shimFunc2x3) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller2x3) Call2x3(arg0, arg1 interface{}) (interface{}, interface{}, interface{}) { +func (c *shimFunc2x3) Call2x3(arg0, arg1 interface{}) (interface{}, interface{}, interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1}) _ = ret return ret[0], ret[1], ret[2] } -func ToCaller2x3(c Caller) Caller2x3 { +func ToFunc2x3(c Func) Func2x3 { if c.Type().NumIn() != 2 || c.Type().NumOut() != 3 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller2x3); ok { + if sc, ok := c.(Func2x3); ok { return sc } - return &shimCaller2x3{inner: c} + return &shimFunc2x3{inner: c} } -func MakeCaller2x3(fn interface{}) Caller2x3 { - return ToCaller2x3(MakeCaller(fn)) +func MakeFunc2x3(fn interface{}) Func2x3 { + return ToFunc2x3(MakeFunc(fn)) } -type Caller3x0 interface { - Caller +type Func3x0 interface { + Func Call3x0(interface{}, interface{}, interface{}) } -type shimCaller3x0 struct { - inner Caller +type shimFunc3x0 struct { + inner Func } -func (c *shimCaller3x0) Type() reflect.Type { +func (c *shimFunc3x0) Name() string { + return c.inner.Name() +} + +func (c *shimFunc3x0) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller3x0) Call(args []interface{}) []interface{} { +func (c *shimFunc3x0) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller3x0) Call3x0(arg0, arg1, arg2 interface{}) { +func (c *shimFunc3x0) Call3x0(arg0, arg1, arg2 interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2}) _ = ret return } -func ToCaller3x0(c Caller) Caller3x0 { +func ToFunc3x0(c Func) Func3x0 { if c.Type().NumIn() != 3 || c.Type().NumOut() != 0 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller3x0); ok { + if sc, ok := c.(Func3x0); ok { return sc } - return &shimCaller3x0{inner: c} + return &shimFunc3x0{inner: c} } -func MakeCaller3x0(fn interface{}) Caller3x0 { - return ToCaller3x0(MakeCaller(fn)) +func MakeFunc3x0(fn interface{}) Func3x0 { + return ToFunc3x0(MakeFunc(fn)) } -type Caller3x1 interface { - Caller +type Func3x1 interface { + Func Call3x1(interface{}, interface{}, interface{}) interface{} } -type shimCaller3x1 struct { - inner Caller +type shimFunc3x1 struct { + inner Func +} + +func (c *shimFunc3x1) Name() string { + return c.inner.Name() } -func (c *shimCaller3x1) Type() reflect.Type { +func (c *shimFunc3x1) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller3x1) Call(args []interface{}) []interface{} { +func (c *shimFunc3x1) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller3x1) Call3x1(arg0, arg1, arg2 interface{}) interface{} { +func (c *shimFunc3x1) Call3x1(arg0, arg1, arg2 interface{}) interface{} { ret := c.inner.Call([]interface{}{arg0, arg1, arg2}) _ = ret return ret[0] } -func ToCaller3x1(c Caller) Caller3x1 { +func ToFunc3x1(c Func) Func3x1 { if c.Type().NumIn() != 3 || c.Type().NumOut() != 1 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller3x1); ok { + if sc, ok := c.(Func3x1); ok { return sc } - return &shimCaller3x1{inner: c} + return &shimFunc3x1{inner: c} } -func MakeCaller3x1(fn interface{}) Caller3x1 { - return ToCaller3x1(MakeCaller(fn)) +func MakeFunc3x1(fn interface{}) Func3x1 { + return ToFunc3x1(MakeFunc(fn)) } -type Caller3x2 interface { - Caller +type Func3x2 interface { + Func Call3x2(interface{}, interface{}, interface{}) (interface{}, interface{}) } -type shimCaller3x2 struct { - inner Caller +type shimFunc3x2 struct { + inner Func } -func (c *shimCaller3x2) Type() reflect.Type { +func (c *shimFunc3x2) Name() string { + return c.inner.Name() +} + +func (c *shimFunc3x2) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller3x2) Call(args []interface{}) []interface{} { +func (c *shimFunc3x2) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller3x2) Call3x2(arg0, arg1, arg2 interface{}) (interface{}, interface{}) { +func (c *shimFunc3x2) Call3x2(arg0, arg1, arg2 interface{}) (interface{}, interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2}) _ = ret return ret[0], ret[1] } -func ToCaller3x2(c Caller) Caller3x2 { +func ToFunc3x2(c Func) Func3x2 { if c.Type().NumIn() != 3 || c.Type().NumOut() != 2 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller3x2); ok { + if sc, ok := c.(Func3x2); ok { return sc } - return &shimCaller3x2{inner: c} + return &shimFunc3x2{inner: c} } -func MakeCaller3x2(fn interface{}) Caller3x2 { - return ToCaller3x2(MakeCaller(fn)) +func MakeFunc3x2(fn interface{}) Func3x2 { + return ToFunc3x2(MakeFunc(fn)) } -type Caller3x3 interface { - Caller +type Func3x3 interface { + Func Call3x3(interface{}, interface{}, interface{}) (interface{}, interface{}, interface{}) } -type shimCaller3x3 struct { - inner Caller +type shimFunc3x3 struct { + inner Func +} + +func (c *shimFunc3x3) Name() string { + return c.inner.Name() } -func (c *shimCaller3x3) Type() reflect.Type { +func (c *shimFunc3x3) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller3x3) Call(args []interface{}) []interface{} { +func (c *shimFunc3x3) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller3x3) Call3x3(arg0, arg1, arg2 interface{}) (interface{}, interface{}, interface{}) { +func (c *shimFunc3x3) Call3x3(arg0, arg1, arg2 interface{}) (interface{}, interface{}, interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2}) _ = ret return ret[0], ret[1], ret[2] } -func ToCaller3x3(c Caller) Caller3x3 { +func ToFunc3x3(c Func) Func3x3 { if c.Type().NumIn() != 3 || c.Type().NumOut() != 3 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller3x3); ok { + if sc, ok := c.(Func3x3); ok { return sc } - return &shimCaller3x3{inner: c} + return &shimFunc3x3{inner: c} } -func MakeCaller3x3(fn interface{}) Caller3x3 { - return ToCaller3x3(MakeCaller(fn)) +func MakeFunc3x3(fn interface{}) Func3x3 { + return ToFunc3x3(MakeFunc(fn)) } -type Caller4x0 interface { - Caller +type Func4x0 interface { + Func Call4x0(interface{}, interface{}, interface{}, interface{}) } -type shimCaller4x0 struct { - inner Caller +type shimFunc4x0 struct { + inner Func } -func (c *shimCaller4x0) Type() reflect.Type { +func (c *shimFunc4x0) Name() string { + return c.inner.Name() +} + +func (c *shimFunc4x0) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller4x0) Call(args []interface{}) []interface{} { +func (c *shimFunc4x0) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller4x0) Call4x0(arg0, arg1, arg2, arg3 interface{}) { +func (c *shimFunc4x0) Call4x0(arg0, arg1, arg2, arg3 interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3}) _ = ret return } -func ToCaller4x0(c Caller) Caller4x0 { +func ToFunc4x0(c Func) Func4x0 { if c.Type().NumIn() != 4 || c.Type().NumOut() != 0 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller4x0); ok { + if sc, ok := c.(Func4x0); ok { return sc } - return &shimCaller4x0{inner: c} + return &shimFunc4x0{inner: c} } -func MakeCaller4x0(fn interface{}) Caller4x0 { - return ToCaller4x0(MakeCaller(fn)) +func MakeFunc4x0(fn interface{}) Func4x0 { + return ToFunc4x0(MakeFunc(fn)) } -type Caller4x1 interface { - Caller +type Func4x1 interface { + Func Call4x1(interface{}, interface{}, interface{}, interface{}) interface{} } -type shimCaller4x1 struct { - inner Caller +type shimFunc4x1 struct { + inner Func +} + +func (c *shimFunc4x1) Name() string { + return c.inner.Name() } -func (c *shimCaller4x1) Type() reflect.Type { +func (c *shimFunc4x1) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller4x1) Call(args []interface{}) []interface{} { +func (c *shimFunc4x1) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller4x1) Call4x1(arg0, arg1, arg2, arg3 interface{}) interface{} { +func (c *shimFunc4x1) Call4x1(arg0, arg1, arg2, arg3 interface{}) interface{} { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3}) _ = ret return ret[0] } -func ToCaller4x1(c Caller) Caller4x1 { +func ToFunc4x1(c Func) Func4x1 { if c.Type().NumIn() != 4 || c.Type().NumOut() != 1 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller4x1); ok { + if sc, ok := c.(Func4x1); ok { return sc } - return &shimCaller4x1{inner: c} + return &shimFunc4x1{inner: c} } -func MakeCaller4x1(fn interface{}) Caller4x1 { - return ToCaller4x1(MakeCaller(fn)) +func MakeFunc4x1(fn interface{}) Func4x1 { + return ToFunc4x1(MakeFunc(fn)) } -type Caller4x2 interface { - Caller +type Func4x2 interface { + Func Call4x2(interface{}, interface{}, interface{}, interface{}) (interface{}, interface{}) } -type shimCaller4x2 struct { - inner Caller +type shimFunc4x2 struct { + inner Func } -func (c *shimCaller4x2) Type() reflect.Type { +func (c *shimFunc4x2) Name() string { + return c.inner.Name() +} + +func (c *shimFunc4x2) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller4x2) Call(args []interface{}) []interface{} { +func (c *shimFunc4x2) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller4x2) Call4x2(arg0, arg1, arg2, arg3 interface{}) (interface{}, interface{}) { +func (c *shimFunc4x2) Call4x2(arg0, arg1, arg2, arg3 interface{}) (interface{}, interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3}) _ = ret return ret[0], ret[1] } -func ToCaller4x2(c Caller) Caller4x2 { +func ToFunc4x2(c Func) Func4x2 { if c.Type().NumIn() != 4 || c.Type().NumOut() != 2 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller4x2); ok { + if sc, ok := c.(Func4x2); ok { return sc } - return &shimCaller4x2{inner: c} + return &shimFunc4x2{inner: c} } -func MakeCaller4x2(fn interface{}) Caller4x2 { - return ToCaller4x2(MakeCaller(fn)) +func MakeFunc4x2(fn interface{}) Func4x2 { + return ToFunc4x2(MakeFunc(fn)) } -type Caller4x3 interface { - Caller +type Func4x3 interface { + Func Call4x3(interface{}, interface{}, interface{}, interface{}) (interface{}, interface{}, interface{}) } -type shimCaller4x3 struct { - inner Caller +type shimFunc4x3 struct { + inner Func +} + +func (c *shimFunc4x3) Name() string { + return c.inner.Name() } -func (c *shimCaller4x3) Type() reflect.Type { +func (c *shimFunc4x3) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller4x3) Call(args []interface{}) []interface{} { +func (c *shimFunc4x3) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller4x3) Call4x3(arg0, arg1, arg2, arg3 interface{}) (interface{}, interface{}, interface{}) { +func (c *shimFunc4x3) Call4x3(arg0, arg1, arg2, arg3 interface{}) (interface{}, interface{}, interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3}) _ = ret return ret[0], ret[1], ret[2] } -func ToCaller4x3(c Caller) Caller4x3 { +func ToFunc4x3(c Func) Func4x3 { if c.Type().NumIn() != 4 || c.Type().NumOut() != 3 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller4x3); ok { + if sc, ok := c.(Func4x3); ok { return sc } - return &shimCaller4x3{inner: c} + return &shimFunc4x3{inner: c} } -func MakeCaller4x3(fn interface{}) Caller4x3 { - return ToCaller4x3(MakeCaller(fn)) +func MakeFunc4x3(fn interface{}) Func4x3 { + return ToFunc4x3(MakeFunc(fn)) } -type Caller5x0 interface { - Caller +type Func5x0 interface { + Func Call5x0(interface{}, interface{}, interface{}, interface{}, interface{}) } -type shimCaller5x0 struct { - inner Caller +type shimFunc5x0 struct { + inner Func } -func (c *shimCaller5x0) Type() reflect.Type { +func (c *shimFunc5x0) Name() string { + return c.inner.Name() +} + +func (c *shimFunc5x0) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller5x0) Call(args []interface{}) []interface{} { +func (c *shimFunc5x0) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller5x0) Call5x0(arg0, arg1, arg2, arg3, arg4 interface{}) { +func (c *shimFunc5x0) Call5x0(arg0, arg1, arg2, arg3, arg4 interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3, arg4}) _ = ret return } -func ToCaller5x0(c Caller) Caller5x0 { +func ToFunc5x0(c Func) Func5x0 { if c.Type().NumIn() != 5 || c.Type().NumOut() != 0 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller5x0); ok { + if sc, ok := c.(Func5x0); ok { return sc } - return &shimCaller5x0{inner: c} + return &shimFunc5x0{inner: c} } -func MakeCaller5x0(fn interface{}) Caller5x0 { - return ToCaller5x0(MakeCaller(fn)) +func MakeFunc5x0(fn interface{}) Func5x0 { + return ToFunc5x0(MakeFunc(fn)) } -type Caller5x1 interface { - Caller +type Func5x1 interface { + Func Call5x1(interface{}, interface{}, interface{}, interface{}, interface{}) interface{} } -type shimCaller5x1 struct { - inner Caller +type shimFunc5x1 struct { + inner Func +} + +func (c *shimFunc5x1) Name() string { + return c.inner.Name() } -func (c *shimCaller5x1) Type() reflect.Type { +func (c *shimFunc5x1) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller5x1) Call(args []interface{}) []interface{} { +func (c *shimFunc5x1) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller5x1) Call5x1(arg0, arg1, arg2, arg3, arg4 interface{}) interface{} { +func (c *shimFunc5x1) Call5x1(arg0, arg1, arg2, arg3, arg4 interface{}) interface{} { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3, arg4}) _ = ret return ret[0] } -func ToCaller5x1(c Caller) Caller5x1 { +func ToFunc5x1(c Func) Func5x1 { if c.Type().NumIn() != 5 || c.Type().NumOut() != 1 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller5x1); ok { + if sc, ok := c.(Func5x1); ok { return sc } - return &shimCaller5x1{inner: c} + return &shimFunc5x1{inner: c} } -func MakeCaller5x1(fn interface{}) Caller5x1 { - return ToCaller5x1(MakeCaller(fn)) +func MakeFunc5x1(fn interface{}) Func5x1 { + return ToFunc5x1(MakeFunc(fn)) } -type Caller5x2 interface { - Caller +type Func5x2 interface { + Func Call5x2(interface{}, interface{}, interface{}, interface{}, interface{}) (interface{}, interface{}) } -type shimCaller5x2 struct { - inner Caller +type shimFunc5x2 struct { + inner Func } -func (c *shimCaller5x2) Type() reflect.Type { +func (c *shimFunc5x2) Name() string { + return c.inner.Name() +} + +func (c *shimFunc5x2) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller5x2) Call(args []interface{}) []interface{} { +func (c *shimFunc5x2) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller5x2) Call5x2(arg0, arg1, arg2, arg3, arg4 interface{}) (interface{}, interface{}) { +func (c *shimFunc5x2) Call5x2(arg0, arg1, arg2, arg3, arg4 interface{}) (interface{}, interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3, arg4}) _ = ret return ret[0], ret[1] } -func ToCaller5x2(c Caller) Caller5x2 { +func ToFunc5x2(c Func) Func5x2 { if c.Type().NumIn() != 5 || c.Type().NumOut() != 2 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller5x2); ok { + if sc, ok := c.(Func5x2); ok { return sc } - return &shimCaller5x2{inner: c} + return &shimFunc5x2{inner: c} } -func MakeCaller5x2(fn interface{}) Caller5x2 { - return ToCaller5x2(MakeCaller(fn)) +func MakeFunc5x2(fn interface{}) Func5x2 { + return ToFunc5x2(MakeFunc(fn)) } -type Caller5x3 interface { - Caller +type Func5x3 interface { + Func Call5x3(interface{}, interface{}, interface{}, interface{}, interface{}) (interface{}, interface{}, interface{}) } -type shimCaller5x3 struct { - inner Caller +type shimFunc5x3 struct { + inner Func +} + +func (c *shimFunc5x3) Name() string { + return c.inner.Name() } -func (c *shimCaller5x3) Type() reflect.Type { +func (c *shimFunc5x3) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller5x3) Call(args []interface{}) []interface{} { +func (c *shimFunc5x3) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller5x3) Call5x3(arg0, arg1, arg2, arg3, arg4 interface{}) (interface{}, interface{}, interface{}) { +func (c *shimFunc5x3) Call5x3(arg0, arg1, arg2, arg3, arg4 interface{}) (interface{}, interface{}, interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3, arg4}) _ = ret return ret[0], ret[1], ret[2] } -func ToCaller5x3(c Caller) Caller5x3 { +func ToFunc5x3(c Func) Func5x3 { if c.Type().NumIn() != 5 || c.Type().NumOut() != 3 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller5x3); ok { + if sc, ok := c.(Func5x3); ok { return sc } - return &shimCaller5x3{inner: c} + return &shimFunc5x3{inner: c} } -func MakeCaller5x3(fn interface{}) Caller5x3 { - return ToCaller5x3(MakeCaller(fn)) +func MakeFunc5x3(fn interface{}) Func5x3 { + return ToFunc5x3(MakeFunc(fn)) } -type Caller6x0 interface { - Caller +type Func6x0 interface { + Func Call6x0(interface{}, interface{}, interface{}, interface{}, interface{}, interface{}) } -type shimCaller6x0 struct { - inner Caller +type shimFunc6x0 struct { + inner Func } -func (c *shimCaller6x0) Type() reflect.Type { +func (c *shimFunc6x0) Name() string { + return c.inner.Name() +} + +func (c *shimFunc6x0) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller6x0) Call(args []interface{}) []interface{} { +func (c *shimFunc6x0) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller6x0) Call6x0(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) { +func (c *shimFunc6x0) Call6x0(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3, arg4, arg5}) _ = ret return } -func ToCaller6x0(c Caller) Caller6x0 { +func ToFunc6x0(c Func) Func6x0 { if c.Type().NumIn() != 6 || c.Type().NumOut() != 0 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller6x0); ok { + if sc, ok := c.(Func6x0); ok { return sc } - return &shimCaller6x0{inner: c} + return &shimFunc6x0{inner: c} } -func MakeCaller6x0(fn interface{}) Caller6x0 { - return ToCaller6x0(MakeCaller(fn)) +func MakeFunc6x0(fn interface{}) Func6x0 { + return ToFunc6x0(MakeFunc(fn)) } -type Caller6x1 interface { - Caller +type Func6x1 interface { + Func Call6x1(interface{}, interface{}, interface{}, interface{}, interface{}, interface{}) interface{} } -type shimCaller6x1 struct { - inner Caller +type shimFunc6x1 struct { + inner Func +} + +func (c *shimFunc6x1) Name() string { + return c.inner.Name() } -func (c *shimCaller6x1) Type() reflect.Type { +func (c *shimFunc6x1) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller6x1) Call(args []interface{}) []interface{} { +func (c *shimFunc6x1) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller6x1) Call6x1(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) interface{} { +func (c *shimFunc6x1) Call6x1(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) interface{} { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3, arg4, arg5}) _ = ret return ret[0] } -func ToCaller6x1(c Caller) Caller6x1 { +func ToFunc6x1(c Func) Func6x1 { if c.Type().NumIn() != 6 || c.Type().NumOut() != 1 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller6x1); ok { + if sc, ok := c.(Func6x1); ok { return sc } - return &shimCaller6x1{inner: c} + return &shimFunc6x1{inner: c} } -func MakeCaller6x1(fn interface{}) Caller6x1 { - return ToCaller6x1(MakeCaller(fn)) +func MakeFunc6x1(fn interface{}) Func6x1 { + return ToFunc6x1(MakeFunc(fn)) } -type Caller6x2 interface { - Caller +type Func6x2 interface { + Func Call6x2(interface{}, interface{}, interface{}, interface{}, interface{}, interface{}) (interface{}, interface{}) } -type shimCaller6x2 struct { - inner Caller +type shimFunc6x2 struct { + inner Func } -func (c *shimCaller6x2) Type() reflect.Type { +func (c *shimFunc6x2) Name() string { + return c.inner.Name() +} + +func (c *shimFunc6x2) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller6x2) Call(args []interface{}) []interface{} { +func (c *shimFunc6x2) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller6x2) Call6x2(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) (interface{}, interface{}) { +func (c *shimFunc6x2) Call6x2(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) (interface{}, interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3, arg4, arg5}) _ = ret return ret[0], ret[1] } -func ToCaller6x2(c Caller) Caller6x2 { +func ToFunc6x2(c Func) Func6x2 { if c.Type().NumIn() != 6 || c.Type().NumOut() != 2 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller6x2); ok { + if sc, ok := c.(Func6x2); ok { return sc } - return &shimCaller6x2{inner: c} + return &shimFunc6x2{inner: c} } -func MakeCaller6x2(fn interface{}) Caller6x2 { - return ToCaller6x2(MakeCaller(fn)) +func MakeFunc6x2(fn interface{}) Func6x2 { + return ToFunc6x2(MakeFunc(fn)) } -type Caller6x3 interface { - Caller +type Func6x3 interface { + Func Call6x3(interface{}, interface{}, interface{}, interface{}, interface{}, interface{}) (interface{}, interface{}, interface{}) } -type shimCaller6x3 struct { - inner Caller +type shimFunc6x3 struct { + inner Func +} + +func (c *shimFunc6x3) Name() string { + return c.inner.Name() } -func (c *shimCaller6x3) Type() reflect.Type { +func (c *shimFunc6x3) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller6x3) Call(args []interface{}) []interface{} { +func (c *shimFunc6x3) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller6x3) Call6x3(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) (interface{}, interface{}, interface{}) { +func (c *shimFunc6x3) Call6x3(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) (interface{}, interface{}, interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3, arg4, arg5}) _ = ret return ret[0], ret[1], ret[2] } -func ToCaller6x3(c Caller) Caller6x3 { +func ToFunc6x3(c Func) Func6x3 { if c.Type().NumIn() != 6 || c.Type().NumOut() != 3 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller6x3); ok { + if sc, ok := c.(Func6x3); ok { return sc } - return &shimCaller6x3{inner: c} + return &shimFunc6x3{inner: c} } -func MakeCaller6x3(fn interface{}) Caller6x3 { - return ToCaller6x3(MakeCaller(fn)) +func MakeFunc6x3(fn interface{}) Func6x3 { + return ToFunc6x3(MakeFunc(fn)) } -type Caller7x0 interface { - Caller +type Func7x0 interface { + Func Call7x0(interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}) } -type shimCaller7x0 struct { - inner Caller +type shimFunc7x0 struct { + inner Func } -func (c *shimCaller7x0) Type() reflect.Type { +func (c *shimFunc7x0) Name() string { + return c.inner.Name() +} + +func (c *shimFunc7x0) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller7x0) Call(args []interface{}) []interface{} { +func (c *shimFunc7x0) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller7x0) Call7x0(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) { +func (c *shimFunc7x0) Call7x0(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3, arg4, arg5, arg6}) _ = ret return } -func ToCaller7x0(c Caller) Caller7x0 { +func ToFunc7x0(c Func) Func7x0 { if c.Type().NumIn() != 7 || c.Type().NumOut() != 0 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller7x0); ok { + if sc, ok := c.(Func7x0); ok { return sc } - return &shimCaller7x0{inner: c} + return &shimFunc7x0{inner: c} } -func MakeCaller7x0(fn interface{}) Caller7x0 { - return ToCaller7x0(MakeCaller(fn)) +func MakeFunc7x0(fn interface{}) Func7x0 { + return ToFunc7x0(MakeFunc(fn)) } -type Caller7x1 interface { - Caller +type Func7x1 interface { + Func Call7x1(interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}) interface{} } -type shimCaller7x1 struct { - inner Caller +type shimFunc7x1 struct { + inner Func +} + +func (c *shimFunc7x1) Name() string { + return c.inner.Name() } -func (c *shimCaller7x1) Type() reflect.Type { +func (c *shimFunc7x1) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller7x1) Call(args []interface{}) []interface{} { +func (c *shimFunc7x1) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller7x1) Call7x1(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) interface{} { +func (c *shimFunc7x1) Call7x1(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) interface{} { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3, arg4, arg5, arg6}) _ = ret return ret[0] } -func ToCaller7x1(c Caller) Caller7x1 { +func ToFunc7x1(c Func) Func7x1 { if c.Type().NumIn() != 7 || c.Type().NumOut() != 1 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller7x1); ok { + if sc, ok := c.(Func7x1); ok { return sc } - return &shimCaller7x1{inner: c} + return &shimFunc7x1{inner: c} } -func MakeCaller7x1(fn interface{}) Caller7x1 { - return ToCaller7x1(MakeCaller(fn)) +func MakeFunc7x1(fn interface{}) Func7x1 { + return ToFunc7x1(MakeFunc(fn)) } -type Caller7x2 interface { - Caller +type Func7x2 interface { + Func Call7x2(interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}) (interface{}, interface{}) } -type shimCaller7x2 struct { - inner Caller +type shimFunc7x2 struct { + inner Func } -func (c *shimCaller7x2) Type() reflect.Type { +func (c *shimFunc7x2) Name() string { + return c.inner.Name() +} + +func (c *shimFunc7x2) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller7x2) Call(args []interface{}) []interface{} { +func (c *shimFunc7x2) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller7x2) Call7x2(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) (interface{}, interface{}) { +func (c *shimFunc7x2) Call7x2(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) (interface{}, interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3, arg4, arg5, arg6}) _ = ret return ret[0], ret[1] } -func ToCaller7x2(c Caller) Caller7x2 { +func ToFunc7x2(c Func) Func7x2 { if c.Type().NumIn() != 7 || c.Type().NumOut() != 2 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller7x2); ok { + if sc, ok := c.(Func7x2); ok { return sc } - return &shimCaller7x2{inner: c} + return &shimFunc7x2{inner: c} } -func MakeCaller7x2(fn interface{}) Caller7x2 { - return ToCaller7x2(MakeCaller(fn)) +func MakeFunc7x2(fn interface{}) Func7x2 { + return ToFunc7x2(MakeFunc(fn)) } -type Caller7x3 interface { - Caller +type Func7x3 interface { + Func Call7x3(interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}) (interface{}, interface{}, interface{}) } -type shimCaller7x3 struct { - inner Caller +type shimFunc7x3 struct { + inner Func +} + +func (c *shimFunc7x3) Name() string { + return c.inner.Name() } -func (c *shimCaller7x3) Type() reflect.Type { +func (c *shimFunc7x3) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller7x3) Call(args []interface{}) []interface{} { +func (c *shimFunc7x3) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller7x3) Call7x3(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) (interface{}, interface{}, interface{}) { +func (c *shimFunc7x3) Call7x3(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) (interface{}, interface{}, interface{}) { ret := c.inner.Call([]interface{}{arg0, arg1, arg2, arg3, arg4, arg5, arg6}) _ = ret return ret[0], ret[1], ret[2] } -func ToCaller7x3(c Caller) Caller7x3 { +func ToFunc7x3(c Func) Func7x3 { if c.Type().NumIn() != 7 || c.Type().NumOut() != 3 { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller7x3); ok { + if sc, ok := c.(Func7x3); ok { return sc } - return &shimCaller7x3{inner: c} + return &shimFunc7x3{inner: c} } -func MakeCaller7x3(fn interface{}) Caller7x3 { - return ToCaller7x3(MakeCaller(fn)) +func MakeFunc7x3(fn interface{}) Func7x3 { + return ToFunc7x3(MakeFunc(fn)) } diff --git a/sdks/go/pkg/beam/core/util/reflectx/calls.tmpl b/sdks/go/pkg/beam/core/util/reflectx/calls.tmpl index 0d68b5c..60b6107 100644 --- a/sdks/go/pkg/beam/core/util/reflectx/calls.tmpl +++ b/sdks/go/pkg/beam/core/util/reflectx/calls.tmpl @@ -17,52 +17,56 @@ package reflectx import "reflect" -// Generated arity-specialized Caller implementations to avoid runtime temporary +// Generated arity-specialized Func implementations to avoid runtime temporary // slices. Code that knows the arity can potentially avoid that overhead in // addition to avoiding the reflection call overhead. // -// We force CallerZxY to implement Caller as well to have a single registry. Concrete -// caller implementations should implement the most specific supported variant. This -// also allows more specific intermediate interfaces, such as Caller2bool, to be added +// We force FuncXxY to implement Func as well to have a single registry. Concrete +// Func implementations should implement the most specific supported variant. This +// also allows more specific intermediate interfaces, such as Func2xbool, to be added // later. {{range $in := upto 8}} {{range $out := upto 4}} -type Caller{{$in}}x{{$out}} interface { - Caller +type Func{{$in}}x{{$out}} interface { + Func Call{{$in}}x{{$out}}({{mktuple $in "interface{}"}}) ({{mktuple $out "interface{}"}}) } -type shimCaller{{$in}}x{{$out}} struct { - inner Caller +type shimFunc{{$in}}x{{$out}} struct { + inner Func } -func (c *shimCaller{{$in}}x{{$out}}) Type() reflect.Type { +func (c *shimFunc{{$in}}x{{$out}}) Name() string { + return c.inner.Name() +} + +func (c *shimFunc{{$in}}x{{$out}}) Type() reflect.Type { return c.inner.Type() } -func (c *shimCaller{{$in}}x{{$out}}) Call(args []interface{}) []interface{} { +func (c *shimFunc{{$in}}x{{$out}}) Call(args []interface{}) []interface{} { return c.inner.Call(args) } -func (c *shimCaller{{$in}}x{{$out}}) Call{{$in}}x{{$out}}({{mkargs $in "arg%v" "interface{}"}}) ({{mktuple $out "interface{}"}}) { +func (c *shimFunc{{$in}}x{{$out}}) Call{{$in}}x{{$out}}({{mkargs $in "arg%v" "interface{}"}}) ({{mktuple $out "interface{}"}}) { ret := c.inner.Call([]interface{}{ {{mktuplef $in "arg%v"}} }) _ = ret return {{mktuplef $out "ret[%v]"}} } -func ToCaller{{$in}}x{{$out}}(c Caller) Caller{{$in}}x{{$out}} { +func ToFunc{{$in}}x{{$out}}(c Func) Func{{$in}}x{{$out}} { if c.Type().NumIn() != {{$in}} || c.Type().NumOut() != {{$out}} { - panic("incompatible caller type") + panic("incompatible func type") } - if sc, ok := c.(Caller{{$in}}x{{$out}}); ok { + if sc, ok := c.(Func{{$in}}x{{$out}}); ok { return sc } - return &shimCaller{{$in}}x{{$out}}{inner: c} + return &shimFunc{{$in}}x{{$out}}{inner: c} } -func MakeCaller{{$in}}x{{$out}}(fn interface{}) Caller{{$in}}x{{$out}} { - return ToCaller{{$in}}x{{$out}}(MakeCaller(fn)) +func MakeFunc{{$in}}x{{$out}}(fn interface{}) Func{{$in}}x{{$out}} { + return ToFunc{{$in}}x{{$out}}(MakeFunc(fn)) } {{end}} {{end}} diff --git a/sdks/go/pkg/beam/core/util/reflectx/json.go b/sdks/go/pkg/beam/core/util/reflectx/json.go index f9142ef..530b9f8 100644 --- a/sdks/go/pkg/beam/core/util/reflectx/json.go +++ b/sdks/go/pkg/beam/core/util/reflectx/json.go @@ -26,7 +26,7 @@ import ( func UnmarshalJSON(t reflect.Type, str string) (interface{}, error) { data := reflect.New(t).Interface() if err := json.Unmarshal([]byte(str), data); err != nil { - return nil, fmt.Errorf("Failed to decode data: %v", err) + return nil, fmt.Errorf("failed to decode data: %v", err) } return reflect.ValueOf(data).Elem().Interface(), nil } diff --git a/sdks/go/pkg/beam/transforms/filter/filter.go b/sdks/go/pkg/beam/transforms/filter/filter.go index eb3de1e..dbb8a39 100644 --- a/sdks/go/pkg/beam/transforms/filter/filter.go +++ b/sdks/go/pkg/beam/transforms/filter/filter.go @@ -80,11 +80,11 @@ type filterFn struct { // Include indicates whether to include or exclude elements that satisfy the predicate. Include bool `json:"include"` - fn reflectx.Caller1x1 + fn reflectx.Func1x1 } func (f *filterFn) Setup() { - f.fn = reflectx.MakeCaller1x1(f.Predicate.Fn.Interface()) + f.fn = reflectx.MakeFunc1x1(f.Predicate.Fn.Interface()) } func (f *filterFn) ProcessElement(elm beam.T, emit func(beam.T)) { -- To stop receiving notification emails like this one, please contact "commits@beam.apache.org" <commits@beam.apache.org>.