Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions third_party/tonic/dart_wrappable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ Dart_Handle DartWrappable::CreateDartWrapper(DartState* dart_state) {
Dart_PersistentHandle type = dart_state->class_library().GetClass(info);
TONIC_DCHECK(!LogIfError(type));

intptr_t native_fields[kNumberOfNativeFields];
native_fields[kPeerIndex] = reinterpret_cast<intptr_t>(this);
native_fields[kWrapperInfoIndex] = reinterpret_cast<intptr_t>(&info);
Dart_Handle wrapper =
Dart_AllocateWithNativeFields(type, kNumberOfNativeFields, native_fields);
Dart_Handle private_constructor_name = Dart_NewStringFromCString("_");
Dart_Handle wrapper = Dart_New(type, private_constructor_name, 0, nullptr);
TONIC_DCHECK(!LogIfError(wrapper));

Dart_Handle res = Dart_SetNativeInstanceField(
wrapper, kPeerIndex, reinterpret_cast<intptr_t>(this));
TONIC_DCHECK(!LogIfError(res));
res = Dart_SetNativeInstanceField(wrapper, kWrapperInfoIndex,
reinterpret_cast<intptr_t>(&info));
TONIC_DCHECK(!LogIfError(res));

this->RetainDartWrappableReference(); // Balanced in FinalizeDartWrapper.
dart_wrapper_ = Dart_NewWeakPersistentHandle(
wrapper, this, GetAllocationSize(), &FinalizeDartWrapper);
Expand Down