@@ -22,13 +22,17 @@ Dart_Handle DartWrappable::CreateDartWrapper(DartState* dart_state) {
2222 Dart_PersistentHandle type = dart_state->class_library ().GetClass (info);
2323 TONIC_DCHECK (!LogIfError (type));
2424
25- intptr_t native_fields[kNumberOfNativeFields ];
26- native_fields[kPeerIndex ] = reinterpret_cast <intptr_t >(this );
27- native_fields[kWrapperInfoIndex ] = reinterpret_cast <intptr_t >(&info);
28- Dart_Handle wrapper =
29- Dart_AllocateWithNativeFields (type, kNumberOfNativeFields , native_fields);
25+ Dart_Handle private_constructor_name = Dart_NewStringFromCString (" _" );
26+ Dart_Handle wrapper = Dart_New (type, private_constructor_name, 0 , nullptr );
3027 TONIC_DCHECK (!LogIfError (wrapper));
3128
29+ Dart_Handle res = Dart_SetNativeInstanceField (
30+ wrapper, kPeerIndex , reinterpret_cast <intptr_t >(this ));
31+ TONIC_DCHECK (!LogIfError (res));
32+ res = Dart_SetNativeInstanceField (wrapper, kWrapperInfoIndex ,
33+ reinterpret_cast <intptr_t >(&info));
34+ TONIC_DCHECK (!LogIfError (res));
35+
3236 this ->RetainDartWrappableReference (); // Balanced in FinalizeDartWrapper.
3337 dart_wrapper_ = Dart_NewWeakPersistentHandle (
3438 wrapper, this , GetAllocationSize (), &FinalizeDartWrapper);
0 commit comments