@@ -110,11 +110,9 @@ export class SwiftRuntime {
110
110
payload2 : number
111
111
) => {
112
112
const obj = this . memory . getObject ( ref ) ;
113
- Reflect . set (
114
- obj ,
115
- this . memory . getObject ( name ) ,
116
- JSValue . decode ( kind , payload1 , payload2 , this . memory )
117
- ) ;
113
+ const key = this . memory . getObject ( name ) ;
114
+ const value = JSValue . decode ( kind , payload1 , payload2 , this . memory ) ;
115
+ obj [ key ] = value ;
118
116
} ,
119
117
120
118
swjs_get_prop : (
@@ -125,7 +123,8 @@ export class SwiftRuntime {
125
123
payload2_ptr : pointer
126
124
) => {
127
125
const obj = this . memory . getObject ( ref ) ;
128
- const result = Reflect . get ( obj , this . memory . getObject ( name ) ) ;
126
+ const key = this . memory . getObject ( name ) ;
127
+ const result = obj [ key ] ;
129
128
JSValue . write (
130
129
result ,
131
130
kind_ptr ,
@@ -144,11 +143,8 @@ export class SwiftRuntime {
144
143
payload2 : number
145
144
) => {
146
145
const obj = this . memory . getObject ( ref ) ;
147
- Reflect . set (
148
- obj ,
149
- index ,
150
- JSValue . decode ( kind , payload1 , payload2 , this . memory )
151
- ) ;
146
+ const value = JSValue . decode ( kind , payload1 , payload2 , this . memory ) ;
147
+ obj [ index ] = value ;
152
148
} ,
153
149
154
150
swjs_get_subscript : (
@@ -159,7 +155,7 @@ export class SwiftRuntime {
159
155
payload2_ptr : pointer
160
156
) => {
161
157
const obj = this . memory . getObject ( ref ) ;
162
- const result = Reflect . get ( obj , index ) ;
158
+ const result = obj [ index ] ;
163
159
JSValue . write (
164
160
result ,
165
161
kind_ptr ,
@@ -201,11 +197,8 @@ export class SwiftRuntime {
201
197
const func = this . memory . getObject ( ref ) ;
202
198
let result : any ;
203
199
try {
204
- result = Reflect . apply (
205
- func ,
206
- undefined ,
207
- JSValue . decodeArray ( argv , argc , this . memory )
208
- ) ;
200
+ const args = JSValue . decodeArray ( argv , argc , this . memory ) ;
201
+ result = func ( ...args ) ;
209
202
} catch ( error ) {
210
203
JSValue . write (
211
204
error ,
@@ -237,11 +230,8 @@ export class SwiftRuntime {
237
230
const func = this . memory . getObject ( ref ) ;
238
231
let isException = true ;
239
232
try {
240
- const result = Reflect . apply (
241
- func ,
242
- undefined ,
243
- JSValue . decodeArray ( argv , argc , this . memory )
244
- ) ;
233
+ const args = JSValue . decodeArray ( argv , argc , this . memory ) ;
234
+ const result = func ( ...args ) ;
245
235
JSValue . write (
246
236
result ,
247
237
kind_ptr ,
@@ -278,11 +268,8 @@ export class SwiftRuntime {
278
268
const func = this . memory . getObject ( func_ref ) ;
279
269
let result : any ;
280
270
try {
281
- result = Reflect . apply (
282
- func ,
283
- obj ,
284
- JSValue . decodeArray ( argv , argc , this . memory )
285
- ) ;
271
+ const args = JSValue . decodeArray ( argv , argc , this . memory ) ;
272
+ result = func . apply ( obj , args ) ;
286
273
} catch ( error ) {
287
274
JSValue . write (
288
275
error ,
@@ -317,11 +304,8 @@ export class SwiftRuntime {
317
304
const func = this . memory . getObject ( func_ref ) ;
318
305
let isException = true ;
319
306
try {
320
- const result = Reflect . apply (
321
- func ,
322
- obj ,
323
- JSValue . decodeArray ( argv , argc , this . memory )
324
- ) ;
307
+ const args = JSValue . decodeArray ( argv , argc , this . memory ) ;
308
+ const result = func . apply ( obj , args ) ;
325
309
JSValue . write (
326
310
result ,
327
311
kind_ptr ,
@@ -346,10 +330,8 @@ export class SwiftRuntime {
346
330
} ,
347
331
swjs_call_new : ( ref : ref , argv : pointer , argc : number ) => {
348
332
const constructor = this . memory . getObject ( ref ) ;
349
- const instance = Reflect . construct (
350
- constructor ,
351
- JSValue . decodeArray ( argv , argc , this . memory )
352
- ) ;
333
+ const args = JSValue . decodeArray ( argv , argc , this . memory ) ;
334
+ const instance = new constructor ( ...args ) ;
353
335
return this . memory . retain ( instance ) ;
354
336
} ,
355
337
@@ -364,10 +346,8 @@ export class SwiftRuntime {
364
346
const constructor = this . memory . getObject ( ref ) ;
365
347
let result : any ;
366
348
try {
367
- result = Reflect . construct (
368
- constructor ,
369
- JSValue . decodeArray ( argv , argc , this . memory )
370
- ) ;
349
+ const args = JSValue . decodeArray ( argv , argc , this . memory ) ;
350
+ result = new constructor ( ...args ) ;
371
351
} catch ( error ) {
372
352
JSValue . write (
373
353
error ,
0 commit comments