From f5b4fbd3fe77a01e35c3cd2e9c6ad909b061d607 Mon Sep 17 00:00:00 2001 From: pkujhd Date: Sat, 27 Jul 2024 17:35:13 +0800 Subject: [PATCH] add _type.uncommon --- type.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/type.go b/type.go index eebd64d..45f20fa 100644 --- a/type.go +++ b/type.go @@ -74,6 +74,16 @@ type uncommonType struct { _ uint32 // unused } +func (t *uncommonType) methods() []method { + if t.mcount == 0 { + return nil + } + return (*[1 << 16]method)(add(unsafe.Pointer(t), uintptr(t.moff)))[:t.mcount:t.mcount] +} + +//go:linkname _uncommon reflect.(*rtype).uncommon +func _uncommon(t *_type) *uncommonType + //go:linkname _Kind reflect.(*rtype).Kind func _Kind(t *_type) reflect.Kind @@ -128,6 +138,7 @@ func _PkgPath(t *_type) string //go:linkname typelinksinit runtime.typelinksinit func typelinksinit() +func (t *_type) uncommon() *uncommonType { return _uncommon(t) } func (t *_type) Kind() reflect.Kind { return _Kind(t) } func (t *_type) NumField() int { return _NumField(t) } func (t *_type) Field(i int) reflect.StructField { return _Field(t, i) }