aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2010-10-19 21:25:28 -0700
committerRob Pike <r@golang.org>2010-10-19 21:25:28 -0700
commit97f3a80d9319a644da91c8d49b3fd788bee185c0 (patch)
tree3cd8df56a3e264efbfaf8f5a4799527587eca8c4
parent321f0c7fe2078b244a7c11e1bde79b2d348b120f (diff)
downloadgo-97f3a80d9319a644da91c8d49b3fd788bee185c0.tar.gz
go-97f3a80d9319a644da91c8d49b3fd788bee185c0.zip
reflect: add InterfaceValue.Get to enable setting of an interface
value (through unsafe means) without having a reflect.Type of type *interface{} (pointer to interface). This is needed to make gob able to handle interface values by a method analogous to the way it handles maps. R=rsc CC=golang-dev https://golang.org/cl/2597041
-rw-r--r--src/pkg/reflect/value.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/pkg/reflect/value.go b/src/pkg/reflect/value.go
index dd677b4ea8..60e0d90deb 100644
--- a/src/pkg/reflect/value.go
+++ b/src/pkg/reflect/value.go
@@ -843,11 +843,17 @@ type InterfaceValue struct {
value "interface"
}
-// No Get because v.Interface() is available.
-
// IsNil returns whether v is a nil interface value.
func (v *InterfaceValue) IsNil() bool { return v.Interface() == nil }
+// No single uinptr Get because v.Interface() is available.
+
+// Get returns the two words that represent an interface in the runtime.
+// Those words are useful only when playing unsafe games.
+func (v *InterfaceValue) Get() [2]uintptr {
+ return *(*[2]uintptr)(v.addr)
+}
+
// Elem returns the concrete value stored in the interface value v.
func (v *InterfaceValue) Elem() Value { return NewValue(v.Interface()) }