@@ -313,12 +313,12 @@ private EmbeddedObject CreateEmbeddedFunction(Delegate del)
313313 return resultValue ;
314314 } ;
315315
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 ) ;
317319
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 ;
322322
323323 var embeddedObject = new EmbeddedObject ( del , functionValue ,
324324 new List < JsNativeFunction > { nativeFunction } ) ;
@@ -419,23 +419,22 @@ private EmbeddedType CreateEmbeddedType(Type type)
419419 return resultValue ;
420420 } ;
421421
422- JsValue constructorValue = JsValue . CreateFunction ( nativeConstructorFunction ) ;
423-
424422 string embeddedTypeKey = type . AssemblyQualifiedName ;
425423 GCHandle embeddedTypeKeyHandle = GCHandle . Alloc ( embeddedTypeKey ) ;
426424 IntPtr embeddedTypeKeyPtr = GCHandle . ToIntPtr ( embeddedTypeKeyHandle ) ;
427425 JsValue prototypeValue = JsValue . CreateExternalObject ( embeddedTypeKeyPtr ,
428426 _embeddedTypeFinalizeCallback ) ;
429- constructorValue . Prototype = prototypeValue ;
430- prototypeValue . SetProperty ( "constructor" , constructorValue , true ) ;
431427
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 ,
433432 new List < JsNativeFunction > { nativeConstructorFunction } ) ;
434433
435434 ProjectFields ( embeddedType ) ;
436435 ProjectProperties ( embeddedType ) ;
437436 ProjectMethods ( embeddedType ) ;
438- FreezeObject ( constructorValue ) ;
437+ FreezeObject ( typeValue ) ;
439438
440439 return embeddedType ;
441440 }
@@ -697,9 +696,7 @@ private void ProjectMethods(EmbeddedItem externalItem)
697696 string typeName = type . FullName ;
698697 BindingFlags defaultBindingFlags = ReflectionHelpers . GetDefaultBindingFlags ( instance ) ;
699698 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 ) ;
703700 IEnumerable < IGrouping < string , MethodInfo > > methodGroups = methods . GroupBy ( m => m . Name ) ;
704701
705702 foreach ( IGrouping < string , MethodInfo > methodGroup in methodGroups )
0 commit comments