reflect, internal/reflectlite: add Value.SetIter{Key,Value} and MapIter.Reset

Fixes #4790. Depends on #4787 (merge that first).
This commit is contained in:
Randy Reddig
2025-03-17 08:34:49 -07:00
committed by Ron Evans
parent d95c1b5982
commit 6a25fd494e
3 changed files with 44 additions and 18 deletions
+4 -4
View File
@@ -381,8 +381,6 @@ func TestSetValue(t *testing.T) {
}
}
/*
func TestMapIterSet(t *testing.T) {
m := make(map[string]any, len(valueTests))
for _, tt := range valueTests {
@@ -430,8 +428,6 @@ func TestMapIterSet(t *testing.T) {
}
}
*/
func TestCanIntUintFloatComplex(t *testing.T) {
type integer int
type uinteger uint
@@ -7955,6 +7951,8 @@ func TestConvertibleTo(t *testing.T) {
}
}
*/
func TestSetIter(t *testing.T) {
data := map[string]int{
"foo": 1,
@@ -8044,6 +8042,8 @@ func TestSetIter(t *testing.T) {
}
}
/*
func TestMethodCallValueCodePtr(t *testing.T) {
m := ValueOf(Point{}).Method(1)
want := MethodValueCallCodePtr()
+12
View File
@@ -65,14 +65,26 @@ func (it *MapIter) Key() Value {
return Value{((*reflectlite.MapIter)(it)).Key()}
}
func (v Value) SetIterKey(iter *MapIter) {
v.Value.SetIterKey((*reflectlite.MapIter)(iter))
}
func (it *MapIter) Value() Value {
return Value{((*reflectlite.MapIter)(it)).Value()}
}
func (v Value) SetIterValue(iter *MapIter) {
v.Value.SetIterValue((*reflectlite.MapIter)(iter))
}
func (it *MapIter) Next() bool {
return ((*reflectlite.MapIter)(it)).Next()
}
func (iter *MapIter) Reset(v Value) {
(*reflectlite.MapIter)(iter).Reset(v.Value)
}
func (v Value) Set(x Value) {
v.Value.Set(x.Value)
}