summaryrefslogtreecommitdiff
path: root/src/lib/reflect/value.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2008-11-24 14:51:33 -0800
committerRuss Cox <rsc@golang.org>2008-11-24 14:51:33 -0800
commit2572141a63f90c4af6761d1c1dd17b5a624512f3 (patch)
tree34e2a5396894dca1141c0db81df5d7791807a8d8 /src/lib/reflect/value.go
parent4add140fbba0262ddd13b79f7ad012c9f78b4128 (diff)
downloadgolang-2572141a63f90c4af6761d1c1dd17b5a624512f3.tar.gz
replay CL 19916 and CL 19913 now that the build can handle them
TBR=r OCL=19924 CL=19934
Diffstat (limited to 'src/lib/reflect/value.go')
-rw-r--r--src/lib/reflect/value.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lib/reflect/value.go b/src/lib/reflect/value.go
index ef6ddce7a..65d4b5ca9 100644
--- a/src/lib/reflect/value.go
+++ b/src/lib/reflect/value.go
@@ -36,14 +36,13 @@ func AddrToPtrString(Addr) *string
func AddrToPtrBool(Addr) *bool
func AddrToPtrRuntimeArray(Addr) *RuntimeArray
func PtrRuntimeArrayToAddr(*RuntimeArray) Addr
-
-export type Empty interface {} // TODO(r): Delete when no longer needed?
+func AddrToPtrInterface(Addr) *interface{}
export type Value interface {
Kind() int;
Type() Type;
Addr() Addr;
- Interface() Empty;
+ Interface() interface {};
}
// Common fields and functionality for all values
@@ -66,7 +65,7 @@ func (c *Common) Addr() Addr {
return c.addr
}
-func (c *Common) Interface() Empty {
+func (c *Common) Interface() interface {} {
return sys.unreflect(*AddrToPtrAddr(c.addr), c.typ.String());
}
@@ -714,12 +713,17 @@ func StructCreator(typ Type, addr Addr) Value {
export type InterfaceValue interface {
Kind() int;
Type() Type;
+ Get() interface {};
}
type InterfaceValueStruct struct {
Common
}
+func (v *InterfaceValueStruct) Get() interface{} {
+ return *AddrToPtrInterface(v.addr);
+}
+
func InterfaceCreator(typ Type, addr Addr) Value {
return &InterfaceValueStruct{ Common{InterfaceKind, typ, addr} }
}
@@ -824,7 +828,7 @@ export func NewOpenArrayValue(typ ArrayType, len, cap int) ArrayValue {
return NewValueAddr(typ, PtrRuntimeArrayToAddr(array));
}
-export func NewValue(e Empty) Value {
+export func NewValue(e interface {}) Value {
value, typestring := sys.reflect(e);
p, ok := typecache[typestring];
if !ok {