@@ -217,9 +217,9 @@ private EdgeEmbeddedObject CreateEmbeddedFunction(Delegate del)
217
217
{
218
218
EdgeJsNativeFunction nativeFunction = ( callee , isConstructCall , args , argCount , callbackData ) =>
219
219
{
220
- object [ ] processedArgs = GetHostItemMemberArguments ( args ) ;
221
220
MethodInfo method = del . GetMethodInfo ( ) ;
222
221
ParameterInfo [ ] parameters = method . GetParameters ( ) ;
222
+ object [ ] processedArgs = GetHostItemMemberArguments ( args , parameters . Length ) ;
223
223
224
224
ReflectionHelpers . FixArgumentTypes ( ref processedArgs , parameters ) ;
225
225
@@ -231,6 +231,7 @@ private EdgeEmbeddedObject CreateEmbeddedFunction(Delegate del)
231
231
}
232
232
catch ( Exception e )
233
233
{
234
+ EdgeJsValue undefinedValue = EdgeJsValue . Undefined ;
234
235
Exception exception = UnwrapException ( e ) ;
235
236
var wrapperException = exception as WrapperException ;
236
237
EdgeJsValue errorValue = wrapperException != null ?
@@ -241,7 +242,7 @@ private EdgeEmbeddedObject CreateEmbeddedFunction(Delegate del)
241
242
;
242
243
EdgeJsContext . SetException ( errorValue ) ;
243
244
244
- return EdgeJsValue . Undefined ;
245
+ return undefinedValue ;
245
246
}
246
247
247
248
EdgeJsValue resultValue = MapToScriptType ( result ) ;
@@ -283,10 +284,12 @@ protected override EdgeEmbeddedType CreateEmbeddedType(Type type)
283
284
return resultValue ;
284
285
}
285
286
287
+ EdgeJsValue undefinedValue = EdgeJsValue . Undefined ;
288
+
286
289
if ( constructors . Length == 0 )
287
290
{
288
291
CreateAndSetError ( string . Format ( NetCoreStrings . Runtime_HostTypeConstructorNotFound , typeName ) ) ;
289
- return EdgeJsValue . Undefined ;
292
+ return undefinedValue ;
290
293
}
291
294
292
295
var bestFitConstructor = ( ConstructorInfo ) ReflectionHelpers . GetBestFitMethod (
@@ -295,7 +298,7 @@ protected override EdgeEmbeddedType CreateEmbeddedType(Type type)
295
298
{
296
299
CreateAndSetReferenceError ( string . Format (
297
300
NetCoreStrings . Runtime_SuitableConstructorOfHostTypeNotFound , typeName ) ) ;
298
- return EdgeJsValue . Undefined ;
301
+ return undefinedValue ;
299
302
}
300
303
301
304
ReflectionHelpers . FixArgumentTypes ( ref processedArgs , bestFitConstructor . GetParameters ( ) ) ;
@@ -316,7 +319,7 @@ protected override EdgeEmbeddedType CreateEmbeddedType(Type type)
316
319
;
317
320
EdgeJsContext . SetException ( errorValue ) ;
318
321
319
- return EdgeJsValue . Undefined ;
322
+ return undefinedValue ;
320
323
}
321
324
322
325
resultValue = MapToScriptType ( result ) ;
@@ -364,11 +367,13 @@ private void ProjectFields(EdgeEmbeddedItem externalItem)
364
367
365
368
EdgeJsNativeFunction nativeGetFunction = ( callee , isConstructCall , args , argCount , callbackData ) =>
366
369
{
370
+ EdgeJsValue undefinedValue = EdgeJsValue . Undefined ;
371
+
367
372
if ( instance && obj == null )
368
373
{
369
374
CreateAndSetTypeError ( string . Format (
370
375
NetCoreStrings . Runtime_InvalidThisContextForHostObjectField , fieldName ) ) ;
371
- return EdgeJsValue . Undefined ;
376
+ return undefinedValue ;
372
377
}
373
378
374
379
object result ;
@@ -400,7 +405,7 @@ private void ProjectFields(EdgeEmbeddedItem externalItem)
400
405
}
401
406
EdgeJsContext . SetException ( errorValue ) ;
402
407
403
- return EdgeJsValue . Undefined ;
408
+ return undefinedValue ;
404
409
}
405
410
406
411
EdgeJsValue resultValue = MapToScriptType ( result ) ;
@@ -414,11 +419,13 @@ private void ProjectFields(EdgeEmbeddedItem externalItem)
414
419
415
420
EdgeJsNativeFunction nativeSetFunction = ( callee , isConstructCall , args , argCount , callbackData ) =>
416
421
{
422
+ EdgeJsValue undefinedValue = EdgeJsValue . Undefined ;
423
+
417
424
if ( instance && obj == null )
418
425
{
419
426
CreateAndSetTypeError ( string . Format (
420
427
NetCoreStrings . Runtime_InvalidThisContextForHostObjectField , fieldName ) ) ;
421
- return EdgeJsValue . Undefined ;
428
+ return undefinedValue ;
422
429
}
423
430
424
431
object value = MapToHostType ( args [ 1 ] ) ;
@@ -451,10 +458,10 @@ private void ProjectFields(EdgeEmbeddedItem externalItem)
451
458
}
452
459
EdgeJsContext . SetException ( errorValue ) ;
453
460
454
- return EdgeJsValue . Undefined ;
461
+ return undefinedValue ;
455
462
}
456
463
457
- return EdgeJsValue . Undefined ;
464
+ return undefinedValue ;
458
465
} ;
459
466
nativeFunctions . Add ( nativeSetFunction ) ;
460
467
@@ -488,11 +495,13 @@ private void ProjectProperties(EdgeEmbeddedItem externalItem)
488
495
{
489
496
EdgeJsNativeFunction nativeGetFunction = ( callee , isConstructCall , args , argCount , callbackData ) =>
490
497
{
498
+ EdgeJsValue undefinedValue = EdgeJsValue . Undefined ;
499
+
491
500
if ( instance && obj == null )
492
501
{
493
502
CreateAndSetTypeError ( string . Format (
494
503
NetCoreStrings . Runtime_InvalidThisContextForHostObjectProperty , propertyName ) ) ;
495
- return EdgeJsValue . Undefined ;
504
+ return undefinedValue ;
496
505
}
497
506
498
507
object result ;
@@ -524,7 +533,7 @@ private void ProjectProperties(EdgeEmbeddedItem externalItem)
524
533
}
525
534
EdgeJsContext . SetException ( errorValue ) ;
526
535
527
- return EdgeJsValue . Undefined ;
536
+ return undefinedValue ;
528
537
}
529
538
530
539
EdgeJsValue resultValue = MapToScriptType ( result ) ;
@@ -541,11 +550,13 @@ private void ProjectProperties(EdgeEmbeddedItem externalItem)
541
550
{
542
551
EdgeJsNativeFunction nativeSetFunction = ( callee , isConstructCall , args , argCount , callbackData ) =>
543
552
{
553
+ EdgeJsValue undefinedValue = EdgeJsValue . Undefined ;
554
+
544
555
if ( instance && obj == null )
545
556
{
546
557
CreateAndSetTypeError ( string . Format (
547
558
NetCoreStrings . Runtime_InvalidThisContextForHostObjectProperty , propertyName ) ) ;
548
- return EdgeJsValue . Undefined ;
559
+ return undefinedValue ;
549
560
}
550
561
551
562
object value = MapToHostType ( args [ 1 ] ) ;
@@ -578,10 +589,10 @@ private void ProjectProperties(EdgeEmbeddedItem externalItem)
578
589
}
579
590
EdgeJsContext . SetException ( errorValue ) ;
580
591
581
- return EdgeJsValue . Undefined ;
592
+ return undefinedValue ;
582
593
}
583
594
584
- return EdgeJsValue . Undefined ;
595
+ return undefinedValue ;
585
596
} ;
586
597
nativeFunctions . Add ( nativeSetFunction ) ;
587
598
@@ -614,11 +625,13 @@ private void ProjectMethods(EdgeEmbeddedItem externalItem)
614
625
615
626
EdgeJsNativeFunction nativeFunction = ( callee , isConstructCall , args , argCount , callbackData ) =>
616
627
{
628
+ EdgeJsValue undefinedValue = EdgeJsValue . Undefined ;
629
+
617
630
if ( instance && obj == null )
618
631
{
619
632
CreateAndSetTypeError ( string . Format (
620
633
NetCoreStrings . Runtime_InvalidThisContextForHostObjectMethod , methodName ) ) ;
621
- return EdgeJsValue . Undefined ;
634
+ return undefinedValue ;
622
635
}
623
636
624
637
object [ ] processedArgs = GetHostItemMemberArguments ( args ) ;
@@ -629,7 +642,7 @@ private void ProjectMethods(EdgeEmbeddedItem externalItem)
629
642
{
630
643
CreateAndSetReferenceError ( string . Format (
631
644
NetCoreStrings . Runtime_SuitableMethodOfHostObjectNotFound , methodName ) ) ;
632
- return EdgeJsValue . Undefined ;
645
+ return undefinedValue ;
633
646
}
634
647
635
648
ReflectionHelpers . FixArgumentTypes ( ref processedArgs , bestFitMethod . GetParameters ( ) ) ;
@@ -663,7 +676,7 @@ private void ProjectMethods(EdgeEmbeddedItem externalItem)
663
676
}
664
677
EdgeJsContext . SetException ( errorValue ) ;
665
678
666
- return EdgeJsValue . Undefined ;
679
+ return undefinedValue ;
667
680
}
668
681
669
682
EdgeJsValue resultValue = MapToScriptType ( result ) ;
0 commit comments