@@ -217,9 +217,9 @@ private EdgeEmbeddedObject CreateEmbeddedFunction(Delegate del)
217217 {
218218 EdgeJsNativeFunction nativeFunction = ( callee , isConstructCall , args , argCount , callbackData ) =>
219219 {
220- object [ ] processedArgs = GetHostItemMemberArguments ( args ) ;
221220 MethodInfo method = del . GetMethodInfo ( ) ;
222221 ParameterInfo [ ] parameters = method . GetParameters ( ) ;
222+ object [ ] processedArgs = GetHostItemMemberArguments ( args , parameters . Length ) ;
223223
224224 ReflectionHelpers . FixArgumentTypes ( ref processedArgs , parameters ) ;
225225
@@ -231,6 +231,7 @@ private EdgeEmbeddedObject CreateEmbeddedFunction(Delegate del)
231231 }
232232 catch ( Exception e )
233233 {
234+ EdgeJsValue undefinedValue = EdgeJsValue . Undefined ;
234235 Exception exception = UnwrapException ( e ) ;
235236 var wrapperException = exception as WrapperException ;
236237 EdgeJsValue errorValue = wrapperException != null ?
@@ -241,7 +242,7 @@ private EdgeEmbeddedObject CreateEmbeddedFunction(Delegate del)
241242 ;
242243 EdgeJsContext . SetException ( errorValue ) ;
243244
244- return EdgeJsValue . Undefined ;
245+ return undefinedValue ;
245246 }
246247
247248 EdgeJsValue resultValue = MapToScriptType ( result ) ;
@@ -283,10 +284,12 @@ protected override EdgeEmbeddedType CreateEmbeddedType(Type type)
283284 return resultValue ;
284285 }
285286
287+ EdgeJsValue undefinedValue = EdgeJsValue . Undefined ;
288+
286289 if ( constructors . Length == 0 )
287290 {
288291 CreateAndSetError ( string . Format ( NetCoreStrings . Runtime_HostTypeConstructorNotFound , typeName ) ) ;
289- return EdgeJsValue . Undefined ;
292+ return undefinedValue ;
290293 }
291294
292295 var bestFitConstructor = ( ConstructorInfo ) ReflectionHelpers . GetBestFitMethod (
@@ -295,7 +298,7 @@ protected override EdgeEmbeddedType CreateEmbeddedType(Type type)
295298 {
296299 CreateAndSetReferenceError ( string . Format (
297300 NetCoreStrings . Runtime_SuitableConstructorOfHostTypeNotFound , typeName ) ) ;
298- return EdgeJsValue . Undefined ;
301+ return undefinedValue ;
299302 }
300303
301304 ReflectionHelpers . FixArgumentTypes ( ref processedArgs , bestFitConstructor . GetParameters ( ) ) ;
@@ -316,7 +319,7 @@ protected override EdgeEmbeddedType CreateEmbeddedType(Type type)
316319 ;
317320 EdgeJsContext . SetException ( errorValue ) ;
318321
319- return EdgeJsValue . Undefined ;
322+ return undefinedValue ;
320323 }
321324
322325 resultValue = MapToScriptType ( result ) ;
@@ -364,11 +367,13 @@ private void ProjectFields(EdgeEmbeddedItem externalItem)
364367
365368 EdgeJsNativeFunction nativeGetFunction = ( callee , isConstructCall , args , argCount , callbackData ) =>
366369 {
370+ EdgeJsValue undefinedValue = EdgeJsValue . Undefined ;
371+
367372 if ( instance && obj == null )
368373 {
369374 CreateAndSetTypeError ( string . Format (
370375 NetCoreStrings . Runtime_InvalidThisContextForHostObjectField , fieldName ) ) ;
371- return EdgeJsValue . Undefined ;
376+ return undefinedValue ;
372377 }
373378
374379 object result ;
@@ -400,7 +405,7 @@ private void ProjectFields(EdgeEmbeddedItem externalItem)
400405 }
401406 EdgeJsContext . SetException ( errorValue ) ;
402407
403- return EdgeJsValue . Undefined ;
408+ return undefinedValue ;
404409 }
405410
406411 EdgeJsValue resultValue = MapToScriptType ( result ) ;
@@ -414,11 +419,13 @@ private void ProjectFields(EdgeEmbeddedItem externalItem)
414419
415420 EdgeJsNativeFunction nativeSetFunction = ( callee , isConstructCall , args , argCount , callbackData ) =>
416421 {
422+ EdgeJsValue undefinedValue = EdgeJsValue . Undefined ;
423+
417424 if ( instance && obj == null )
418425 {
419426 CreateAndSetTypeError ( string . Format (
420427 NetCoreStrings . Runtime_InvalidThisContextForHostObjectField , fieldName ) ) ;
421- return EdgeJsValue . Undefined ;
428+ return undefinedValue ;
422429 }
423430
424431 object value = MapToHostType ( args [ 1 ] ) ;
@@ -451,10 +458,10 @@ private void ProjectFields(EdgeEmbeddedItem externalItem)
451458 }
452459 EdgeJsContext . SetException ( errorValue ) ;
453460
454- return EdgeJsValue . Undefined ;
461+ return undefinedValue ;
455462 }
456463
457- return EdgeJsValue . Undefined ;
464+ return undefinedValue ;
458465 } ;
459466 nativeFunctions . Add ( nativeSetFunction ) ;
460467
@@ -488,11 +495,13 @@ private void ProjectProperties(EdgeEmbeddedItem externalItem)
488495 {
489496 EdgeJsNativeFunction nativeGetFunction = ( callee , isConstructCall , args , argCount , callbackData ) =>
490497 {
498+ EdgeJsValue undefinedValue = EdgeJsValue . Undefined ;
499+
491500 if ( instance && obj == null )
492501 {
493502 CreateAndSetTypeError ( string . Format (
494503 NetCoreStrings . Runtime_InvalidThisContextForHostObjectProperty , propertyName ) ) ;
495- return EdgeJsValue . Undefined ;
504+ return undefinedValue ;
496505 }
497506
498507 object result ;
@@ -524,7 +533,7 @@ private void ProjectProperties(EdgeEmbeddedItem externalItem)
524533 }
525534 EdgeJsContext . SetException ( errorValue ) ;
526535
527- return EdgeJsValue . Undefined ;
536+ return undefinedValue ;
528537 }
529538
530539 EdgeJsValue resultValue = MapToScriptType ( result ) ;
@@ -541,11 +550,13 @@ private void ProjectProperties(EdgeEmbeddedItem externalItem)
541550 {
542551 EdgeJsNativeFunction nativeSetFunction = ( callee , isConstructCall , args , argCount , callbackData ) =>
543552 {
553+ EdgeJsValue undefinedValue = EdgeJsValue . Undefined ;
554+
544555 if ( instance && obj == null )
545556 {
546557 CreateAndSetTypeError ( string . Format (
547558 NetCoreStrings . Runtime_InvalidThisContextForHostObjectProperty , propertyName ) ) ;
548- return EdgeJsValue . Undefined ;
559+ return undefinedValue ;
549560 }
550561
551562 object value = MapToHostType ( args [ 1 ] ) ;
@@ -578,10 +589,10 @@ private void ProjectProperties(EdgeEmbeddedItem externalItem)
578589 }
579590 EdgeJsContext . SetException ( errorValue ) ;
580591
581- return EdgeJsValue . Undefined ;
592+ return undefinedValue ;
582593 }
583594
584- return EdgeJsValue . Undefined ;
595+ return undefinedValue ;
585596 } ;
586597 nativeFunctions . Add ( nativeSetFunction ) ;
587598
@@ -614,11 +625,13 @@ private void ProjectMethods(EdgeEmbeddedItem externalItem)
614625
615626 EdgeJsNativeFunction nativeFunction = ( callee , isConstructCall , args , argCount , callbackData ) =>
616627 {
628+ EdgeJsValue undefinedValue = EdgeJsValue . Undefined ;
629+
617630 if ( instance && obj == null )
618631 {
619632 CreateAndSetTypeError ( string . Format (
620633 NetCoreStrings . Runtime_InvalidThisContextForHostObjectMethod , methodName ) ) ;
621- return EdgeJsValue . Undefined ;
634+ return undefinedValue ;
622635 }
623636
624637 object [ ] processedArgs = GetHostItemMemberArguments ( args ) ;
@@ -629,7 +642,7 @@ private void ProjectMethods(EdgeEmbeddedItem externalItem)
629642 {
630643 CreateAndSetReferenceError ( string . Format (
631644 NetCoreStrings . Runtime_SuitableMethodOfHostObjectNotFound , methodName ) ) ;
632- return EdgeJsValue . Undefined ;
645+ return undefinedValue ;
633646 }
634647
635648 ReflectionHelpers . FixArgumentTypes ( ref processedArgs , bestFitMethod . GetParameters ( ) ) ;
@@ -663,7 +676,7 @@ private void ProjectMethods(EdgeEmbeddedItem externalItem)
663676 }
664677 EdgeJsContext . SetException ( errorValue ) ;
665678
666- return EdgeJsValue . Undefined ;
679+ return undefinedValue ;
667680 }
668681
669682 EdgeJsValue resultValue = MapToScriptType ( result ) ;
0 commit comments