Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f2f8c34

Browse files
authored
Revert "Remove usage of Dart_AllocateWithNativeFields from tonic (#16588)" (#16684)
This reverts commit 4941ff7.
1 parent 8dba815 commit f2f8c34

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

lib/ui/painting.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,12 +1890,6 @@ class Path extends NativeFieldWrapperClass2 {
18901890
/// Create a new empty [Path] object.
18911891
@pragma('vm:entry-point')
18921892
Path() { _constructor(); }
1893-
1894-
// Workaround for tonic, which expects classes with native fields to have a
1895-
// private constructor.
1896-
@pragma('vm:entry-point')
1897-
Path._() { _constructor(); }
1898-
18991893
void _constructor() native 'Path_constructor';
19001894

19011895
/// Creates a copy of another [Path].

third_party/tonic/dart_wrappable.cc

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,13 @@ Dart_Handle DartWrappable::CreateDartWrapper(DartState* dart_state) {
2222
Dart_PersistentHandle type = dart_state->class_library().GetClass(info);
2323
TONIC_DCHECK(!LogIfError(type));
2424

25-
Dart_Handle private_constructor_name = Dart_NewStringFromCString("_");
26-
Dart_Handle wrapper = Dart_New(type, private_constructor_name, 0, nullptr);
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);
2730
TONIC_DCHECK(!LogIfError(wrapper));
2831

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-
3632
this->RetainDartWrappableReference(); // Balanced in FinalizeDartWrapper.
3733
dart_wrapper_ = Dart_NewWeakPersistentHandle(
3834
wrapper, this, GetAllocationSize(), &FinalizeDartWrapper);

0 commit comments

Comments
 (0)