From 404e3f3f6f052562b050412a6259d8c1090b267a Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 6 Jul 2020 12:12:13 +0900 Subject: [PATCH] Replace type definition from *Type to Type --- all_test.go | 54 ++++++++++++------------- bridge.go | 8 ++-- reflect.go | 112 ++++++++++++++++++++++++++-------------------------- type.go | 76 +++++++++++++++++------------------ value.go | 20 +++++----- 5 files changed, 136 insertions(+), 134 deletions(-) diff --git a/all_test.go b/all_test.go index 2de3b26..12affa0 100644 --- a/all_test.go +++ b/all_test.go @@ -233,7 +233,7 @@ var valueTests = []pair{ }, } -func testType(t *testing.T, i int, typ *Type, want string) { +func testType(t *testing.T, i int, typ Type, want string) { s := typ.String() if s != want { t.Errorf("#%d: have %#q, want %#q", i, s, want) @@ -2488,7 +2488,7 @@ func TestFieldByName(t *testing.T) { func TestImportPath(t *testing.T) { tests := []struct { - t *Type + t Type path string }{ {TypeOf(&base64.Encoding{}).Elem(), "encoding/base64"}, @@ -3723,8 +3723,8 @@ var convertTests = []struct { } func TestConvert(t *testing.T) { - canConvert := map[[2]*Type]bool{} - all := map[*Type]bool{} + canConvert := map[[2]Type]bool{} + all := map[Type]bool{} for _, tt := range convertTests { t1 := tt.in.Type() @@ -3741,7 +3741,7 @@ func TestConvert(t *testing.T) { all[t1] = true all[t2] = true - canConvert[[2]*Type{t1, t2}] = true + canConvert[[2]Type{t1, t2}] = true // vout1 represents the in value converted to the in type. v1 := tt.in @@ -3774,7 +3774,7 @@ func TestConvert(t *testing.T) { // things like 'int64' converting to '*int'. for t1 := range all { for t2 := range all { - expectOK := t1 == t2 || canConvert[[2]*Type{t1, t2}] || t2.Kind() == Interface && t2.NumMethod() == 0 + expectOK := t1 == t2 || canConvert[[2]Type{t1, t2}] || t2.Kind() == Interface && t2.NumMethod() == 0 if ok := t1.ConvertibleTo(t2); ok != expectOK { t.Errorf("(%s).ConvertibleTo(%s) = %v, want %v", t1, t2, ok, expectOK) } @@ -3792,7 +3792,7 @@ type NonComparableStruct struct { } var comparableTests = []struct { - typ *Type + typ Type ok bool }{ {TypeOf(1), true}, @@ -3859,7 +3859,7 @@ func TestOverflow(t *testing.T) { } } -func checkSameType(t *testing.T, x *Type, y interface{}) { +func checkSameType(t *testing.T, x Type, y interface{}) { if x != TypeOf(y) || TypeOf(Zero(x).Interface()) != TypeOf(y) { t.Errorf("did not find preexisting type for %s (vs %s)", TypeOf(x), TypeOf(y)) } @@ -4422,7 +4422,7 @@ func TestStructOfGenericAlg(t *testing.T) { }) tests := []struct { - rt *Type + rt Type idx []int }{ { @@ -4624,7 +4624,7 @@ func TestStructOfWithInterface(t *testing.T) { } tests := []struct { name string - typ *Type + typ Type val Value impl bool }{ @@ -5014,7 +5014,7 @@ func TestFuncOf(t *testing.T) { } return []Value{ValueOf(V(3.14))} } - v := MakeFunc(FuncOf([]*Type{TypeOf(K(""))}, []*Type{TypeOf(V(0))}, false), fn) + v := MakeFunc(FuncOf([]Type{TypeOf(K(""))}, []Type{TypeOf(V(0))}, false), fn) outs := v.Call([]Value{ValueOf(K("gopher"))}) if len(outs) != 1 { @@ -5030,23 +5030,23 @@ func TestFuncOf(t *testing.T) { // check that types already in binary are found type T1 int testCases := []struct { - in, out []*Type + in, out []Type variadic bool want interface{} }{ - {in: []*Type{TypeOf(T1(0))}, want: (func(T1))(nil)}, - {in: []*Type{TypeOf(int(0))}, want: (func(int))(nil)}, - {in: []*Type{SliceOf(TypeOf(int(0)))}, variadic: true, want: (func(...int))(nil)}, - {in: []*Type{TypeOf(int(0))}, out: []*Type{TypeOf(false)}, want: (func(int) bool)(nil)}, - {in: []*Type{TypeOf(int(0))}, out: []*Type{TypeOf(false), TypeOf("")}, want: (func(int) (bool, string))(nil)}, + {in: []Type{TypeOf(T1(0))}, want: (func(T1))(nil)}, + {in: []Type{TypeOf(int(0))}, want: (func(int))(nil)}, + {in: []Type{SliceOf(TypeOf(int(0)))}, variadic: true, want: (func(...int))(nil)}, + {in: []Type{TypeOf(int(0))}, out: []Type{TypeOf(false)}, want: (func(int) bool)(nil)}, + {in: []Type{TypeOf(int(0))}, out: []Type{TypeOf(false), TypeOf("")}, want: (func(int) (bool, string))(nil)}, } for _, tt := range testCases { checkSameType(t, FuncOf(tt.in, tt.out, tt.variadic), tt.want) } // check that variadic requires last element be a slice. - FuncOf([]*Type{TypeOf(1), TypeOf(""), SliceOf(TypeOf(false))}, nil, true) - shouldPanic(func() { FuncOf([]*Type{TypeOf(0), TypeOf(""), TypeOf(false)}, nil, true) }) + FuncOf([]Type{TypeOf(1), TypeOf(""), SliceOf(TypeOf(false))}, nil, true) + shouldPanic(func() { FuncOf([]Type{TypeOf(0), TypeOf(""), TypeOf(false)}, nil, true) }) shouldPanic(func() { FuncOf(nil, nil, true) }) } @@ -5477,7 +5477,7 @@ func TestLargeGCProg(t *testing.T) { fv.Call([]Value{ValueOf([256]*byte{})}) } -func fieldIndexRecover(t *Type, i int) (recovered interface{}) { +func fieldIndexRecover(t Type, i int) (recovered interface{}) { defer func() { recovered = recover() }() @@ -5611,7 +5611,7 @@ func clobber() { } type funcLayoutTest struct { - rcvr, t *Type + rcvr, t Type size, argsize, retOffset uintptr stack []byte // pointer bitmap: 1 is pointer, 0 is scalar gc []byte @@ -5745,9 +5745,9 @@ func TestTypeOfTypeOf(t *testing.T) { // Check that all the type constructors return concrete *rtype implementations. // It's difficult to test directly because the reflect package is only at arm's length. // The easiest thing to do is just call a function that crashes if it doesn't get an *rtype. - check := func(name string, typ *Type) { - if underlying := TypeOf(typ).String(); underlying != "*reflect.Type" { - t.Errorf("%v returned %v, not *reflect.Type", name, underlying) + check := func(name string, typ Type) { + if underlying := TypeOf(typ).String(); underlying != "*reflect.rtype" { + t.Errorf("%v returned %v, not *reflect.rtype", name, underlying) } } @@ -5756,7 +5756,7 @@ func TestTypeOfTypeOf(t *testing.T) { check("ArrayOf", ArrayOf(10, TypeOf(T{}))) check("ChanOf", ChanOf(BothDir, TypeOf(T{}))) - check("FuncOf", FuncOf([]*Type{TypeOf(T{})}, nil, false)) + check("FuncOf", FuncOf([]Type{TypeOf(T{})}, nil, false)) check("MapOf", MapOf(TypeOf(T{}), TypeOf(T{}))) check("PtrTo", PtrTo(TypeOf(T{}))) check("SliceOf", SliceOf(TypeOf(T{}))) @@ -5855,12 +5855,12 @@ func TestNames(t *testing.T) { func TestTypeStrings(t *testing.T) { type stringTest struct { - typ *Type + typ Type want string } stringTests := []stringTest{ {TypeOf(func(int) {}), "func(int)"}, - {FuncOf([]*Type{TypeOf(int(0))}, nil, false), "func(int)"}, + {FuncOf([]Type{TypeOf(int(0))}, nil, false), "func(int)"}, {TypeOf(XM{}), "reflect_test.XM"}, {TypeOf(new(XM)), "*reflect_test.XM"}, {TypeOf(new(XM).String), "func() string"}, diff --git a/bridge.go b/bridge.go index ec7f8c2..4f05b15 100644 --- a/bridge.go +++ b/bridge.go @@ -5,11 +5,11 @@ import ( "unsafe" ) -func toRT(t *Type) reflect.Type { +func toRT(t Type) reflect.Type { return type_toType(t) } -func toRTs(t []*Type) []reflect.Type { +func toRTs(t []Type) []reflect.Type { out := make([]reflect.Type, len(t)) for idx, tt := range t { out[idx] = toRT(tt) @@ -17,8 +17,8 @@ func toRTs(t []*Type) []reflect.Type { return out } -func toT(t reflect.Type) *Type { - return (*Type)(((*Value)(unsafe.Pointer(&t))).ptr) +func toT(t reflect.Type) Type { + return (Type)(((*Value)(unsafe.Pointer(&t))).ptr) } func toTs(v []reflect.Value) []Value { diff --git a/reflect.go b/reflect.go index ff40d79..07cca2d 100644 --- a/reflect.go +++ b/reflect.go @@ -16,7 +16,9 @@ import ( // Type values are comparable, such as with the == operator, // so they can be used as map keys. // Two Type values are equal if they represent identical types. -type Type struct{} +type Type = *rtype + +type rtype struct{} type flag uintptr @@ -157,7 +159,7 @@ type SelectDir = reflect.SelectDir // To compare two Values, compare the results of the Interface method. // Using == on two Values does not compare the underlying values they represent. type Value struct { - typ *Type + typ Type ptr unsafe.Pointer flag } @@ -173,7 +175,7 @@ type Method struct { Name string PkgPath string - Type *Type // method type + Type Type // method type Func Value // func with receiver as first argument Index int // index for Type.Method } @@ -187,7 +189,7 @@ type StructField struct { // See https://golang.org/ref/spec#Uniqueness_of_identifiers PkgPath string - Type *Type // field type + Type Type // field type Tag StructTag // field tag string Offset uintptr // offset within struct, in bytes Index []int // index sequence for Type.FieldByIndex @@ -199,7 +201,7 @@ type StructField struct { // // If the resulting type would be larger than the available address space, // ArrayOf panics. -func ArrayOf(count int, elem *Type) *Type { +func ArrayOf(count int, elem Type) Type { return arrayOf(count, elem) } @@ -208,7 +210,7 @@ func ArrayOf(count int, elem *Type) *Type { // // The gc runtime imposes a limit of 64 kB on channel element types. // If t's size is equal to or exceeds this limit, ChanOf panics. -func ChanOf(dir ChanDir, t *Type) *Type { +func ChanOf(dir ChanDir, t Type) Type { return chanOf(dir, t) } @@ -219,7 +221,7 @@ func ChanOf(dir ChanDir, t *Type) *Type { // The variadic argument controls whether the function is variadic. FuncOf // panics if the in[len(in)-1] does not represent a slice and variadic is // true. -func FuncOf(in, out []*Type, variadic bool) *Type { +func FuncOf(in, out []Type, variadic bool) Type { return funcOf(in, out, variadic) } @@ -229,19 +231,19 @@ func FuncOf(in, out []*Type, variadic bool) *Type { // // If the key type is not a valid map key type (that is, if it does // not implement Go's == operator), MapOf panics. -func MapOf(key, elem *Type) *Type { +func MapOf(key, elem Type) Type { return mapOf(key, elem) } // PtrTo returns the pointer type with element t. // For example, if t represents type Foo, PtrTo(t) represents *Foo. -func PtrTo(t *Type) *Type { +func PtrTo(t Type) Type { return ptrTo(t) } // SliceOf returns the slice type with element type t. // For example, if t represents int, SliceOf(t) represents []int. -func SliceOf(t *Type) *Type { +func SliceOf(t Type) Type { return sliceOf(t) } @@ -252,13 +254,13 @@ func SliceOf(t *Type) *Type { // StructOf currently does not generate wrapper methods for embedded // fields and panics if passed unexported StructFields. // These limitations may be lifted in a future version. -func StructOf(fields []StructField) *Type { +func StructOf(fields []StructField) Type { return structOf(fields) } // TypeOf returns the reflection Type that represents the dynamic type of i. // If i is a nil interface value, TypeOf returns nil. -func TypeOf(v interface{}) *Type { +func TypeOf(v interface{}) Type { value := (*Value)(unsafe.Pointer(&v)) return value.typ } @@ -296,8 +298,8 @@ func ValueNoEscapeOf(v interface{}) Value { return valueOf(v) } -// ToReflectType convert *Type to reflect.Type -func ToReflectType(t *Type) reflect.Type { +// ToReflectType convert Type to reflect.Type +func ToReflectType(t Type) reflect.Type { return toRT(t) } @@ -306,8 +308,8 @@ func ToReflectValue(v Value) reflect.Value { return toRV(v) } -// ToType convert reflect.Type to *Type -func ToType(t reflect.Type) *Type { +// ToType convert reflect.Type to Type +func ToType(t reflect.Type) Type { return toT(t) } @@ -406,7 +408,7 @@ func Indirect(v Value) Value { } // MakeChan creates a new channel with the specified type and buffer size. -func MakeChan(typ *Type, buffer int) Value { +func MakeChan(typ Type, buffer int) Value { return value_MakeChan(typ, buffer) } @@ -432,36 +434,36 @@ func MakeChan(typ *Type, buffer int) Value { // The Examples section of the documentation includes an illustration // of how to use MakeFunc to build a swap function for different types. // -func MakeFunc(typ *Type, fn func(args []Value) (results []Value)) Value { +func MakeFunc(typ Type, fn func(args []Value) (results []Value)) Value { return value_MakeFunc(typ, fn) } // MakeMap creates a new map with the specified type. -func MakeMap(typ *Type) Value { +func MakeMap(typ Type) Value { return value_MakeMap(typ) } // MakeMapWithSize creates a new map with the specified type // and initial space for approximately n elements. -func MakeMapWithSize(typ *Type, n int) Value { +func MakeMapWithSize(typ Type, n int) Value { return value_MakeMapWithSize(typ, n) } // MakeSlice creates a new zero-initialized slice value // for the specified slice type, length, and capacity. -func MakeSlice(typ *Type, len, cap int) Value { +func MakeSlice(typ Type, len, cap int) Value { return value_MakeSlice(typ, len, cap) } // New returns a Value representing a pointer to a new zero value // for the specified type. That is, the returned Value's Type is PtrTo(typ). -func New(typ *Type) Value { +func New(typ Type) Value { return value_New(typ) } // NewAt returns a Value representing a pointer to a value of the // specified type, using p as that pointer. -func NewAt(typ *Type, p unsafe.Pointer) Value { +func NewAt(typ Type, p unsafe.Pointer) Value { return value_NewAt(typ, p) } @@ -481,19 +483,19 @@ func Select(cases []SelectCase) (int, Value, bool) { // which represents no value at all. // For example, Zero(TypeOf(42)) returns a Value with Kind Int and value 0. // The returned value is neither addressable nor settable. -func Zero(typ *Type) Value { +func Zero(typ Type) Value { return value_Zero(typ) } // Align returns the alignment in bytes of a value of // this type when allocated in memory. -func (t *Type) Align() int { +func (t Type) Align() int { return type_Align(t) } // FieldAlign returns the alignment in bytes of a value of // this type when used as a field in a struct. -func (t *Type) FieldAlign() int { +func (t Type) FieldAlign() int { return type_FieldAlign(t) } @@ -508,7 +510,7 @@ func (t *Type) FieldAlign() int { // // Only exported methods are accessible and they are sorted in // lexicographic order. -func (t *Type) Method(a0 int) Method { +func (t Type) Method(a0 int) Method { return toM(type_Method(t, a0)) } @@ -520,19 +522,19 @@ func (t *Type) Method(a0 int) Method { // // For an interface type, the returned Method's Type field gives the // method signature, without a receiver, and the Func field is nil. -func (t *Type) MethodByName(a0 string) (Method, bool) { +func (t Type) MethodByName(a0 string) (Method, bool) { mtd, ok := type_MethodByName(t, a0) return toM(mtd), ok } // NumMethod returns the number of exported methods in the type's method set. -func (t *Type) NumMethod() int { +func (t Type) NumMethod() int { return type_NumMethod(t) } // Name returns the type's name within its package for a defined type. // For other (non-defined) types it returns the empty string. -func (t *Type) Name() string { +func (t Type) Name() string { return type_Name(t) } @@ -541,13 +543,13 @@ func (t *Type) Name() string { // If the type was predeclared (string, error) or not defined (*T, struct{}, // []int, or A where A is an alias for a non-defined type), the package path // will be the empty string. -func (t *Type) PkgPath() string { +func (t Type) PkgPath() string { return type_PkgPath(t) } // Size returns the number of bytes needed to store // a value of the given type; it is analogous to unsafe.Sizeof. -func (t *Type) Size() uintptr { +func (t Type) Size() uintptr { return type_Size(t) } @@ -556,32 +558,32 @@ func (t *Type) Size() uintptr { // (e.g., base64 instead of "encoding/base64") and is not // guaranteed to be unique among types. To test for type identity, // compare the Types directly. -func (t *Type) String() string { +func (t Type) String() string { return type_String(t) } // Kind returns the specific kind of this type. -func (t *Type) Kind() Kind { +func (t Type) Kind() Kind { return type_Kind(t) } // Implements reports whether the type implements the interface type u. -func (t *Type) Implements(u *Type) bool { +func (t Type) Implements(u Type) bool { return type_Implements(t, toRT(u)) } // AssignableTo reports whether a value of the type is assignable to type u. -func (t *Type) AssignableTo(u *Type) bool { +func (t Type) AssignableTo(u Type) bool { return type_AssignableTo(t, toRT(u)) } // ConvertibleTo reports whether a value of the type is convertible to type u. -func (t *Type) ConvertibleTo(u *Type) bool { +func (t Type) ConvertibleTo(u Type) bool { return type_ConvertibleTo(t, toRT(u)) } // Comparable reports whether values of this type are comparable. -func (t *Type) Comparable() bool { +func (t Type) Comparable() bool { return type_Comparable(t) } @@ -600,13 +602,13 @@ func (t *Type) Comparable() bool { // Bits returns the size of the type in bits. // It panics if the type's Kind is not one of the // sized or unsized Int, Uint, Float, or Complex kinds. -func (t *Type) Bits() int { +func (t Type) Bits() int { return type_Bits(t) } // ChanDir returns a channel type's direction. // It panics if the type's Kind is not Chan. -func (t *Type) ChanDir() ChanDir { +func (t Type) ChanDir() ChanDir { return type_ChanDir(t) } @@ -622,20 +624,20 @@ func (t *Type) ChanDir() ChanDir { // t.IsVariadic() == true // // IsVariadic panics if the type's Kind is not Func. -func (t *Type) IsVariadic() bool { +func (t Type) IsVariadic() bool { return type_IsVariadic(t) } // Elem returns a type's element type. // It panics if the type's Kind is not Array, Chan, Map, Ptr, or Slice. -func (t *Type) Elem() *Type { +func (t Type) Elem() Type { return ToType(type_Elem(t)) } // Field returns a struct type's i'th field. // It panics if the type's Kind is not Struct. // It panics if i is not in the range [0, NumField()). -func (t *Type) Field(i int) StructField { +func (t Type) Field(i int) StructField { return toSF(type_Field(t, i)) } @@ -643,13 +645,13 @@ func (t *Type) Field(i int) StructField { // to the index sequence. It is equivalent to calling Field // successively for each index i. // It panics if the type's Kind is not Struct. -func (t *Type) FieldByIndex(index []int) StructField { +func (t Type) FieldByIndex(index []int) StructField { return toSF(type_FieldByIndex(t, index)) } // FieldByName returns the struct field with the given name // and a boolean indicating if the field was found. -func (t *Type) FieldByName(name string) (StructField, bool) { +func (t Type) FieldByName(name string) (StructField, bool) { field, ok := type_FieldByName(t, name) return toSF(field), ok } @@ -666,7 +668,7 @@ func (t *Type) FieldByName(name string) (StructField, bool) { // and FieldByNameFunc returns no match. // This behavior mirrors Go's handling of name lookup in // structs containing embedded fields. -func (t *Type) FieldByNameFunc(match func(string) bool) (StructField, bool) { +func (t Type) FieldByNameFunc(match func(string) bool) (StructField, bool) { field, ok := type_FieldByNameFunc(t, match) return toSF(field), ok } @@ -674,44 +676,44 @@ func (t *Type) FieldByNameFunc(match func(string) bool) (StructField, bool) { // In returns the type of a function type's i'th input parameter. // It panics if the type's Kind is not Func. // It panics if i is not in the range [0, NumIn()). -func (t *Type) In(i int) *Type { +func (t Type) In(i int) Type { return ToType(type_In(t, i)) } // Key returns a map type's key type. // It panics if the type's Kind is not Map. -func (t *Type) Key() *Type { +func (t Type) Key() Type { return ToType(type_Key(t)) } // Len returns an array type's length. // It panics if the type's Kind is not Array. -func (t *Type) Len() int { +func (t Type) Len() int { return type_Len(t) } // NumField returns a struct type's field count. // It panics if the type's Kind is not Struct. -func (t *Type) NumField() int { +func (t Type) NumField() int { return type_NumField(t) } // NumIn returns a function type's input parameter count. // It panics if the type's Kind is not Func. -func (t *Type) NumIn() int { +func (t Type) NumIn() int { return type_NumIn(t) } // NumOut returns a function type's output parameter count. // It panics if the type's Kind is not Func. -func (t *Type) NumOut() int { +func (t Type) NumOut() int { return type_NumOut(t) } // Out returns the type of a function type's i'th output parameter. // It panics if the type's Kind is not Func. // It panics if i is not in the range [0, NumOut()). -func (t *Type) Out(i int) *Type { +func (t Type) Out(i int) Type { return toT(type_Out(t, i)) } @@ -803,7 +805,7 @@ func (v Value) Complex() complex128 { // Convert returns the value v converted to type t. // If the usual Go conversion rules do not allow conversion // of the value v to type t, Convert panics. -func (v Value) Convert(t *Type) Value { +func (v Value) Convert(t Type) Value { return value_Convert(v, t) } @@ -1155,7 +1157,7 @@ func (v Value) TrySend(x Value) bool { } // Type returns v's type. -func (v Value) Type() *Type { +func (v Value) Type() Type { return value_Type(v) } diff --git a/type.go b/type.go index d0712e2..011d8fd 100644 --- a/type.go +++ b/type.go @@ -7,155 +7,155 @@ import ( //go:linkname ifaceIndir reflect.ifaceIndir //go:noescape -func ifaceIndir(*Type) bool +func ifaceIndir(Type) bool -func arrayOf(i int, typ *Type) *Type { +func arrayOf(i int, typ Type) Type { return toT(reflect.ArrayOf(i, toRT(typ))) } -func chanOf(dir ChanDir, typ *Type) *Type { +func chanOf(dir ChanDir, typ Type) Type { return toT(reflect.ChanOf(dir, toRT(typ))) } -func funcOf(in []*Type, out []*Type, variadic bool) *Type { +func funcOf(in []Type, out []Type, variadic bool) Type { return toT(reflect.FuncOf(toRTs(in), toRTs(out), variadic)) } -func mapOf(key *Type, elem *Type) *Type { +func mapOf(key Type, elem Type) Type { return toT(reflect.MapOf(toRT(key), toRT(elem))) } -func ptrTo(typ *Type) *Type { +func ptrTo(typ Type) Type { return toT(reflect.PtrTo(toRT(typ))) } -func sliceOf(t *Type) *Type { +func sliceOf(t Type) Type { return toT(reflect.SliceOf(toRT(t))) } -func structOf(fields []StructField) *Type { +func structOf(fields []StructField) Type { return ToType(reflect.StructOf(toSFs(fields))) } //go:linkname type_Align reflect.(*rtype).Align //go:noescape -func type_Align(*Type) int +func type_Align(Type) int //go:linkname type_FieldAlign reflect.(*rtype).FieldAlign //go:noescape -func type_FieldAlign(*Type) int +func type_FieldAlign(Type) int //go:linkname type_Method reflect.(*rtype).Method //go:noescape -func type_Method(*Type, int) reflect.Method +func type_Method(Type, int) reflect.Method //go:linkname type_MethodByName reflect.(*rtype).MethodByName //go:noescape -func type_MethodByName(*Type, string) (reflect.Method, bool) +func type_MethodByName(Type, string) (reflect.Method, bool) //go:linkname type_NumMethod reflect.(*rtype).NumMethod //go:noescape -func type_NumMethod(*Type) int +func type_NumMethod(Type) int //go:linkname type_Name reflect.(*rtype).Name //go:noescape -func type_Name(*Type) string +func type_Name(Type) string //go:linkname type_PkgPath reflect.(*rtype).PkgPath //go:noescape -func type_PkgPath(*Type) string +func type_PkgPath(Type) string //go:linkname type_Size reflect.(*rtype).Size //go:noescape -func type_Size(*Type) uintptr +func type_Size(Type) uintptr //go:linkname type_String reflect.(*rtype).String //go:noescape -func type_String(*Type) string +func type_String(Type) string //go:linkname type_Kind reflect.(*rtype).Kind //go:noescape -func type_Kind(*Type) reflect.Kind +func type_Kind(Type) reflect.Kind //go:linkname type_Implements reflect.(*rtype).Implements //go:noescape -func type_Implements(*Type, reflect.Type) bool +func type_Implements(Type, reflect.Type) bool //go:linkname type_AssignableTo reflect.(*rtype).AssignableTo //go:noescape -func type_AssignableTo(*Type, reflect.Type) bool +func type_AssignableTo(Type, reflect.Type) bool //go:linkname type_ConvertibleTo reflect.(*rtype).ConvertibleTo //go:noescape -func type_ConvertibleTo(*Type, reflect.Type) bool +func type_ConvertibleTo(Type, reflect.Type) bool //go:linkname type_Comparable reflect.(*rtype).Comparable //go:noescape -func type_Comparable(*Type) bool +func type_Comparable(Type) bool //go:linkname type_Bits reflect.(*rtype).Bits //go:noescape -func type_Bits(*Type) int +func type_Bits(Type) int //go:linkname type_ChanDir reflect.(*rtype).ChanDir //go:noescape -func type_ChanDir(*Type) ChanDir +func type_ChanDir(Type) ChanDir //go:linkname type_IsVariadic reflect.(*rtype).IsVariadic //go:noescape -func type_IsVariadic(*Type) bool +func type_IsVariadic(Type) bool //go:linkname type_Elem reflect.(*rtype).Elem //go:noescape -func type_Elem(t *Type) reflect.Type +func type_Elem(t Type) reflect.Type //go:linkname type_Field reflect.(*rtype).Field //go:noescape -func type_Field(typ *Type, i int) reflect.StructField +func type_Field(typ Type, i int) reflect.StructField //go:linkname type_FieldByIndex reflect.(*rtype).FieldByIndex //go:noescape -func type_FieldByIndex(*Type, []int) reflect.StructField +func type_FieldByIndex(Type, []int) reflect.StructField //go:linkname type_FieldByName reflect.(*rtype).FieldByName //go:noescape -func type_FieldByName(*Type, string) (reflect.StructField, bool) +func type_FieldByName(Type, string) (reflect.StructField, bool) //go:linkname type_FieldByNameFunc reflect.(*rtype).FieldByNameFunc //go:noescape -func type_FieldByNameFunc(*Type, func(string) bool) (reflect.StructField, bool) +func type_FieldByNameFunc(Type, func(string) bool) (reflect.StructField, bool) //go:linkname type_In reflect.(*rtype).In //go:noescape -func type_In(*Type, int) reflect.Type +func type_In(Type, int) reflect.Type //go:linkname type_Key reflect.(*rtype).Key //go:noescape -func type_Key(*Type) reflect.Type +func type_Key(Type) reflect.Type //go:linkname type_Len reflect.(*rtype).Len //go:noescape -func type_Len(*Type) int +func type_Len(Type) int //go:linkname type_NumField reflect.(*rtype).NumField //go:noescape -func type_NumField(*Type) int +func type_NumField(Type) int //go:linkname type_NumIn reflect.(*rtype).NumIn //go:noescape -func type_NumIn(*Type) int +func type_NumIn(Type) int //go:linkname type_NumOut reflect.(*rtype).NumOut //go:noescape -func type_NumOut(*Type) int +func type_NumOut(Type) int //go:linkname type_Out reflect.(*rtype).Out //go:noescape -func type_Out(*Type, int) reflect.Type +func type_Out(Type, int) reflect.Type //go:linkname type_toType reflect.toType //go:noescape -func type_toType(t *Type) reflect.Type +func type_toType(t Type) reflect.Type var dummy struct { b bool diff --git a/value.go b/value.go index 7d210c8..15adaec 100644 --- a/value.go +++ b/value.go @@ -21,33 +21,33 @@ func value_Indirect(v Value) Value { return toV(reflect.Indirect(toRV(v))) } -func value_MakeChan(typ *Type, buffer int) Value { +func value_MakeChan(typ Type, buffer int) Value { return toV(reflect.MakeChan(toRT(typ), buffer)) } -func value_MakeFunc(typ *Type, fn func([]Value) []Value) Value { +func value_MakeFunc(typ Type, fn func([]Value) []Value) Value { return toV(reflect.MakeFunc(toRT(typ), func(args []reflect.Value) []reflect.Value { return toRVs(fn(toVs(args))) })) } -func value_MakeMap(typ *Type) Value { +func value_MakeMap(typ Type) Value { return toV(reflect.MakeMap(toRT(typ))) } -func value_MakeMapWithSize(typ *Type, n int) Value { +func value_MakeMapWithSize(typ Type, n int) Value { return toV(reflect.MakeMapWithSize(toRT(typ), n)) } -func value_MakeSlice(typ *Type, len, cap int) Value { +func value_MakeSlice(typ Type, len, cap int) Value { return toV(reflect.MakeSlice(toRT(typ), len, cap)) } -func value_New(typ *Type) Value { +func value_New(typ Type) Value { return toV(reflect.New(toRT(typ))) } -func value_NewAt(typ *Type, p unsafe.Pointer) Value { +func value_NewAt(typ Type, p unsafe.Pointer) Value { return toV(reflect.NewAt(toRT(typ), p)) } @@ -56,7 +56,7 @@ func value_Select(cases []SelectCase) (int, Value, bool) { return chosen, toV(recv), recvOK } -func value_Zero(typ *Type) Value { +func value_Zero(typ Type) Value { return toV(reflect.Zero(toRT(typ))) } @@ -104,7 +104,7 @@ func value_Complex(v Value) complex128 { return toRV(v).Complex() } -func value_Convert(v Value, typ *Type) Value { +func value_Convert(v Value, typ Type) Value { return toV(toRV(v).Convert(toRT(typ))) } @@ -290,7 +290,7 @@ func value_TrySend(v Value, x Value) bool { return toRV(v).TrySend(toRV(x)) } -func value_Type(v Value) *Type { +func value_Type(v Value) Type { return ToType(toRV(v).Type()) }