@@ -1152,9 +1152,9 @@ func (v Value) Close() {
1152
1152
var selectHelper = js .Global .Get ("$select" ).Interface ().(func (... interface {}) * js.Object )
1153
1153
1154
1154
func chanrecv (t * rtype , ch unsafe.Pointer , nb bool , val unsafe.Pointer ) (selected , received bool ) {
1155
- comms := [][]interface {} {{js .InternalObject (ch )}}
1155
+ comms := [][]* js. Object {{js .InternalObject (ch )}}
1156
1156
if nb {
1157
- comms = append (comms , []interface {} {})
1157
+ comms = append (comms , []* js. Object {})
1158
1158
}
1159
1159
selectRes := selectHelper (comms )
1160
1160
if nb && selectRes .Index (0 ).Int () == 1 {
@@ -1166,9 +1166,9 @@ func chanrecv(t *rtype, ch unsafe.Pointer, nb bool, val unsafe.Pointer) (selecte
1166
1166
}
1167
1167
1168
1168
func chansend (t * rtype , ch unsafe.Pointer , val unsafe.Pointer , nb bool ) bool {
1169
- comms := [][]interface {} {{js .InternalObject (ch ), js .InternalObject (val ).Call ("$get" )}}
1169
+ comms := [][]* js. Object {{js .InternalObject (ch ), js .InternalObject (val ).Call ("$get" )}}
1170
1170
if nb {
1171
- comms = append (comms , []interface {} {})
1171
+ comms = append (comms , []* js. Object {})
1172
1172
}
1173
1173
selectRes := selectHelper (comms )
1174
1174
if nb && selectRes .Index (0 ).Int () == 1 {
@@ -1178,20 +1178,30 @@ func chansend(t *rtype, ch unsafe.Pointer, val unsafe.Pointer, nb bool) bool {
1178
1178
}
1179
1179
1180
1180
func rselect (rselects []runtimeSelect ) (chosen int , recvOK bool ) {
1181
- comms := make ([][]interface {} , len (rselects ))
1181
+ comms := make ([][]* js. Object , len (rselects ))
1182
1182
for i , s := range rselects {
1183
- switch ChanDir (s .dir ) {
1184
- case 0 :
1185
- comms [i ] = []interface {}{}
1186
- case RecvDir :
1187
- comms [i ] = []interface {}{js .InternalObject (s .ch )}
1188
- case SendDir :
1189
- comms [i ] = []interface {}{js .InternalObject (s .ch ), js .InternalObject (s .val ).Call ("$get" )}
1183
+ switch SelectDir (s .dir ) {
1184
+ case SelectDefault :
1185
+ comms [i ] = []* js.Object {}
1186
+ case SelectRecv :
1187
+ ch := js .Global .Get ("$chanNil" )
1188
+ if js .InternalObject (s .ch ) != js .InternalObject (0 ) {
1189
+ ch = js .InternalObject (s .ch )
1190
+ }
1191
+ comms [i ] = []* js.Object {ch }
1192
+ case SelectSend :
1193
+ ch := js .Global .Get ("$chanNil" )
1194
+ var val * js.Object
1195
+ if js .InternalObject (s .ch ) != js .InternalObject (0 ) {
1196
+ ch = js .InternalObject (s .ch )
1197
+ val = js .InternalObject (s .val ).Call ("$get" )
1198
+ }
1199
+ comms [i ] = []* js.Object {ch , val }
1190
1200
}
1191
1201
}
1192
1202
selectRes := selectHelper (comms )
1193
1203
c := selectRes .Index (0 ).Int ()
1194
- if ChanDir (rselects [c ].dir ) == RecvDir {
1204
+ if SelectDir (rselects [c ].dir ) == SelectRecv {
1195
1205
recvRes := selectRes .Index (1 )
1196
1206
js .InternalObject (rselects [c ].val ).Call ("$set" , recvRes .Index (0 ))
1197
1207
return c , recvRes .Index (1 ).Bool ()
0 commit comments