@@ -1325,6 +1325,10 @@ func getJsTag(tag string) string {
1325
1325
return ""
1326
1326
}
1327
1327
1328
+ func (v Value ) UnsafePointer () unsafe.Pointer {
1329
+ return unsafe .Pointer (v .Pointer ())
1330
+ }
1331
+
1328
1332
func (v Value ) grow (n int ) {
1329
1333
if n < 0 {
1330
1334
panic (`reflect.Value.Grow: negative len` )
@@ -1343,6 +1347,32 @@ func (v Value) grow(n int) {
1343
1347
}
1344
1348
}
1345
1349
1350
+ // extendSlice is used by native reflect.Append and reflect.AppendSlice
1351
+ // Overridden to avoid the use of `unsafeheader.Slice` since GopherJS
1352
+ // uses different slice implementation.
1353
+ func (v Value ) extendSlice (n int ) Value {
1354
+ v .mustBeExported ()
1355
+ v .mustBe (Slice )
1356
+
1357
+ s := v .object ()
1358
+ sNil := jsType (v .typ ).Get (`nil` )
1359
+ fl := flagIndir | flag (Slice )
1360
+ if s == sNil && n <= 0 {
1361
+ return makeValue (v .typ , wrapJsObject (v .typ , sNil ), fl )
1362
+ }
1363
+
1364
+ newSlice := jsType (v .typ ).New (s .Get ("$array" ))
1365
+ newSlice .Set ("$offset" , s .Get ("$offset" ))
1366
+ newSlice .Set ("$length" , s .Get ("$length" ))
1367
+ newSlice .Set ("$capacity" , s .Get ("$capacity" ))
1368
+
1369
+ v2 := makeValue (v .typ , wrapJsObject (v .typ , newSlice ), fl )
1370
+ v2 .grow (n )
1371
+ s2 := v2 .object ()
1372
+ s2 .Set (`$length` , s2 .Get (`$length` ).Int ()+ n )
1373
+ return v2
1374
+ }
1375
+
1346
1376
func (v Value ) Index (i int ) Value {
1347
1377
switch k := v .kind (); k {
1348
1378
case Array :
@@ -1399,6 +1429,11 @@ func (v Value) InterfaceData() [2]uintptr {
1399
1429
panic (errors .New ("InterfaceData is not supported by GopherJS" ))
1400
1430
}
1401
1431
1432
+ func (v Value ) SetZero () {
1433
+ v .mustBeAssignable ()
1434
+ v .Set (Zero (v .typ ))
1435
+ }
1436
+
1402
1437
func (v Value ) IsNil () bool {
1403
1438
switch k := v .kind (); k {
1404
1439
case Ptr , Slice :
@@ -1438,6 +1473,9 @@ func (v Value) Len() int {
1438
1473
}
1439
1474
}
1440
1475
1476
+ //gopherjs:purge Not used since Len() is overridden.
1477
+ func (v Value ) lenNonSlice () int
1478
+
1441
1479
func (v Value ) Pointer () uintptr {
1442
1480
switch k := v .kind (); k {
1443
1481
case Chan , Map , Ptr , UnsafePointer :
0 commit comments