@@ -313,12 +313,12 @@ private EmbeddedObject CreateEmbeddedFunction(Delegate del)
313
313
return resultValue ;
314
314
} ;
315
315
316
- JsValue functionValue = JsValue . CreateFunction ( nativeFunction ) ;
316
+ GCHandle delHandle = GCHandle . Alloc ( del ) ;
317
+ IntPtr delPtr = GCHandle . ToIntPtr ( delHandle ) ;
318
+ JsValue prototypeValue = JsValue . CreateExternalObject ( delPtr , _embeddedObjectFinalizeCallback ) ;
317
319
318
- GCHandle objHandle = GCHandle . Alloc ( del ) ;
319
- IntPtr objPtr = GCHandle . ToIntPtr ( objHandle ) ;
320
- JsValue objValue = JsValue . CreateExternalObjectWithPrototype ( objPtr ,
321
- _embeddedObjectFinalizeCallback , functionValue ) ;
320
+ JsValue functionValue = JsValue . CreateFunction ( nativeFunction ) ;
321
+ functionValue . Prototype = prototypeValue ;
322
322
323
323
var embeddedObject = new EmbeddedObject ( del , functionValue ,
324
324
new List < JsNativeFunction > { nativeFunction } ) ;
@@ -419,23 +419,22 @@ private EmbeddedType CreateEmbeddedType(Type type)
419
419
return resultValue ;
420
420
} ;
421
421
422
- JsValue constructorValue = JsValue . CreateFunction ( nativeConstructorFunction ) ;
423
-
424
422
string embeddedTypeKey = type . AssemblyQualifiedName ;
425
423
GCHandle embeddedTypeKeyHandle = GCHandle . Alloc ( embeddedTypeKey ) ;
426
424
IntPtr embeddedTypeKeyPtr = GCHandle . ToIntPtr ( embeddedTypeKeyHandle ) ;
427
425
JsValue prototypeValue = JsValue . CreateExternalObject ( embeddedTypeKeyPtr ,
428
426
_embeddedTypeFinalizeCallback ) ;
429
- constructorValue . Prototype = prototypeValue ;
430
- prototypeValue . SetProperty ( "constructor" , constructorValue , true ) ;
431
427
432
- var embeddedType = new EmbeddedType ( type , constructorValue ,
428
+ JsValue typeValue = JsValue . CreateFunction ( nativeConstructorFunction ) ;
429
+ typeValue . Prototype = prototypeValue ;
430
+
431
+ var embeddedType = new EmbeddedType ( type , typeValue ,
433
432
new List < JsNativeFunction > { nativeConstructorFunction } ) ;
434
433
435
434
ProjectFields ( embeddedType ) ;
436
435
ProjectProperties ( embeddedType ) ;
437
436
ProjectMethods ( embeddedType ) ;
438
- FreezeObject ( constructorValue ) ;
437
+ FreezeObject ( typeValue ) ;
439
438
440
439
return embeddedType ;
441
440
}
@@ -697,9 +696,7 @@ private void ProjectMethods(EmbeddedItem externalItem)
697
696
string typeName = type . FullName ;
698
697
BindingFlags defaultBindingFlags = ReflectionHelpers . GetDefaultBindingFlags ( instance ) ;
699
698
IEnumerable < MethodInfo > methods = type . GetMethods ( defaultBindingFlags )
700
- . Where ( m => ! ( m . Attributes . HasFlag ( MethodAttributes . SpecialName )
701
- && ( m . Name . StartsWith ( "get_" ) || m . Name . StartsWith ( "set_" ) ) ) )
702
- ;
699
+ . Where ( ReflectionHelpers . IsFullyFledgedMethod ) ;
703
700
IEnumerable < IGrouping < string , MethodInfo > > methodGroups = methods . GroupBy ( m => m . Name ) ;
704
701
705
702
foreach ( IGrouping < string , MethodInfo > methodGroup in methodGroups )
0 commit comments