未验证 提交 4941ff7b 编写于 作者: B Ben Konyi 提交者: GitHub

Remove usage of Dart_AllocateWithNativeFields from tonic (#16588)

This API is being removed from the Dart SDK.
上级 15e7f51b
......@@ -1890,6 +1890,12 @@ class Path extends NativeFieldWrapperClass2 {
/// Create a new empty [Path] object.
@pragma('vm:entry-point')
Path() { _constructor(); }
// Workaround for tonic, which expects classes with native fields to have a
// private constructor.
@pragma('vm:entry-point')
Path._() { _constructor(); }
void _constructor() native 'Path_constructor';
/// Creates a copy of another [Path].
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册