From 2049a881bdd069e95bd16d84ba7a4e3ad2da6f35 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Wed, 19 Feb 2020 09:25:15 -0800 Subject: [PATCH] Revert "Remove usage of Dart_AllocateWithNativeFields from tonic (#16588)" This reverts commit 4941ff7bf608e0bca764e1edad769a3f8cca797f. --- lib/ui/painting.dart | 6 ------ third_party/tonic/dart_wrappable.cc | 14 +++++--------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/ui/painting.dart b/lib/ui/painting.dart index 8e7e8ea697e5b..e44287a96a573 100644 --- a/lib/ui/painting.dart +++ b/lib/ui/painting.dart @@ -1890,12 +1890,6 @@ 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]. diff --git a/third_party/tonic/dart_wrappable.cc b/third_party/tonic/dart_wrappable.cc index b5edf4f8f55a9..96b5e44ed80fd 100644 --- a/third_party/tonic/dart_wrappable.cc +++ b/third_party/tonic/dart_wrappable.cc @@ -22,17 +22,13 @@ Dart_Handle DartWrappable::CreateDartWrapper(DartState* dart_state) { Dart_PersistentHandle type = dart_state->class_library().GetClass(info); TONIC_DCHECK(!LogIfError(type)); - Dart_Handle private_constructor_name = Dart_NewStringFromCString("_"); - Dart_Handle wrapper = Dart_New(type, private_constructor_name, 0, nullptr); + intptr_t native_fields[kNumberOfNativeFields]; + native_fields[kPeerIndex] = reinterpret_cast(this); + native_fields[kWrapperInfoIndex] = reinterpret_cast(&info); + Dart_Handle wrapper = + Dart_AllocateWithNativeFields(type, kNumberOfNativeFields, native_fields); TONIC_DCHECK(!LogIfError(wrapper)); - Dart_Handle res = Dart_SetNativeInstanceField( - wrapper, kPeerIndex, reinterpret_cast(this)); - TONIC_DCHECK(!LogIfError(res)); - res = Dart_SetNativeInstanceField(wrapper, kWrapperInfoIndex, - reinterpret_cast(&info)); - TONIC_DCHECK(!LogIfError(res)); - this->RetainDartWrappableReference(); // Balanced in FinalizeDartWrapper. dart_wrapper_ = Dart_NewWeakPersistentHandle( wrapper, this, GetAllocationSize(), &FinalizeDartWrapper);