@@ -42,7 +42,7 @@ func reflectType(typ *js.Object) *rtype {
42
42
rt := & rtype {
43
43
size : uintptr (typ .Get ("size" ).Int ()),
44
44
kind : uint8 (typ .Get ("kind" ).Int ()),
45
- str : newNameOff (newName (typ .Get ("string" ). String ( ), "" , typ .Get ("exported" ).Bool ())),
45
+ str : newNameOff (newName (internalStr ( typ .Get ("string" )), "" , typ .Get ("exported" ).Bool ())),
46
46
}
47
47
js .InternalObject (rt ).Set ("jsType" , typ )
48
48
typ .Set ("reflectType" , js .InternalObject (rt ))
@@ -57,12 +57,12 @@ func reflectType(typ *js.Object) *rtype {
57
57
for i := range reflectMethods {
58
58
m := methodSet .Index (i )
59
59
reflectMethods [i ] = method {
60
- name : newNameOff (newName (m .Get ("name" ). String ( ), "" , m .Get ("pkg" ). String ( ) == "" )),
60
+ name : newNameOff (newName (internalStr ( m .Get ("name" )), "" , internalStr ( m .Get ("pkg" )) == "" )),
61
61
mtyp : newTypeOff (reflectType (m .Get ("typ" ))),
62
62
}
63
63
}
64
64
ut := & uncommonType {
65
- pkgPath : newNameOff (newName (typ .Get ("pkg" ). String ( ), "" , false )),
65
+ pkgPath : newNameOff (newName (internalStr ( typ .Get ("pkg" )), "" , false )),
66
66
mcount : uint16 (methodSet .Length ()),
67
67
_methods : reflectMethods ,
68
68
}
@@ -116,13 +116,13 @@ func reflectType(typ *js.Object) *rtype {
116
116
for i := range imethods {
117
117
m := methods .Index (i )
118
118
imethods [i ] = imethod {
119
- name : newNameOff (newName (m .Get ("name" ). String ( ), "" , m .Get ("pkg" ). String ( ) == "" )),
119
+ name : newNameOff (newName (internalStr ( m .Get ("name" )), "" , internalStr ( m .Get ("pkg" )) == "" )),
120
120
typ : newTypeOff (reflectType (m .Get ("typ" ))),
121
121
}
122
122
}
123
123
setKindType (rt , & interfaceType {
124
124
rtype : * rt ,
125
- pkgPath : newName (typ .Get ("pkg" ). String ( ), "" , false ),
125
+ pkgPath : newName (internalStr ( typ .Get ("pkg" )), "" , false ),
126
126
methods : imethods ,
127
127
})
128
128
case Map :
@@ -148,14 +148,14 @@ func reflectType(typ *js.Object) *rtype {
148
148
offsetAnon |= 1
149
149
}
150
150
reflectFields [i ] = structField {
151
- name : newName (f .Get ("name" ). String ( ), f .Get ("tag" ). String ( ), f .Get ("exported" ).Bool ()),
151
+ name : newName (internalStr ( f .Get ("name" )), internalStr ( f .Get ("tag" )), f .Get ("exported" ).Bool ()),
152
152
typ : reflectType (f .Get ("typ" )),
153
153
offsetAnon : offsetAnon ,
154
154
}
155
155
}
156
156
setKindType (rt , & structType {
157
157
rtype : * rt ,
158
- pkgPath : newName (typ .Get ("pkgPath" ). String ( ), "" , false ),
158
+ pkgPath : newName (internalStr ( typ .Get ("pkgPath" )), "" , false ),
159
159
fields : reflectFields ,
160
160
})
161
161
}
@@ -259,6 +259,12 @@ func newTypeOff(t *rtype) typeOff {
259
259
return typeOff (i )
260
260
}
261
261
262
+ func internalStr (strObj * js.Object ) string {
263
+ var c struct { str string }
264
+ js .InternalObject (c ).Set ("str" , strObj ) // get string without internalizing
265
+ return c .str
266
+ }
267
+
262
268
func isWrapped (typ Type ) bool {
263
269
return jsType (typ ).Get ("wrapped" ).Bool ()
264
270
}
0 commit comments