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

Commit b5e5e0a

Browse files
committed
Migrate @FfiNative to @Native
1 parent dfe67f4 commit b5e5e0a

File tree

11 files changed

+241
-245
lines changed

11 files changed

+241
-245
lines changed

lib/ui/compositing.dart

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Scene extends NativeFieldWrapperClass1 {
3434
return Image._(image, image.width, image.height);
3535
}
3636

37-
@FfiNative<Handle Function(Pointer<Void>, Uint32, Uint32, Handle)>('Scene::toImageSync')
37+
@Native<Handle Function(Pointer<Void>, Uint32, Uint32, Handle)>(symbol: 'Scene::toImageSync')
3838
external String? _toImageSync(int width, int height, _Image outImage);
3939

4040
/// Creates a raster image representation of the current state of the scene.
@@ -58,7 +58,7 @@ class Scene extends NativeFieldWrapperClass1 {
5858
);
5959
}
6060

61-
@FfiNative<Handle Function(Pointer<Void>, Uint32, Uint32, Handle)>('Scene::toImage')
61+
@Native<Handle Function(Pointer<Void>, Uint32, Uint32, Handle)>(symbol: 'Scene::toImage')
6262
external String? _toImage(int width, int height, _Callback<_Image?> callback);
6363

6464
/// Releases the resources used by this scene.
@@ -67,7 +67,7 @@ class Scene extends NativeFieldWrapperClass1 {
6767
///
6868
/// This can't be a leaf call because the native function calls Dart API
6969
/// (Dart_SetNativeInstanceField).
70-
@FfiNative<Void Function(Pointer<Void>)>('Scene::dispose')
70+
@Native<Void Function(Pointer<Void>)>(symbol: 'Scene::dispose')
7171
external void dispose();
7272
}
7373

@@ -235,7 +235,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
235235
_constructor();
236236
}
237237

238-
@FfiNative<Void Function(Handle)>('SceneBuilder::Create')
238+
@Native<Void Function(Handle)>(symbol: 'SceneBuilder::Create')
239239
external void _constructor();
240240

241241
// Layers used in this scene.
@@ -332,7 +332,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
332332
return layer;
333333
}
334334

335-
@FfiNative<Void Function(Pointer<Void>, Handle, Handle, Handle)>('SceneBuilder::pushTransformHandle')
335+
@Native<Void Function(Pointer<Void>, Handle, Handle, Handle)>(symbol: 'SceneBuilder::pushTransformHandle')
336336
external void _pushTransform(EngineLayer layer, Float64List matrix4, EngineLayer? oldLayer);
337337

338338
/// Pushes an offset operation onto the operation stack.
@@ -357,7 +357,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
357357
return layer;
358358
}
359359

360-
@FfiNative<Void Function(Pointer<Void>, Handle, Double, Double, Handle)>('SceneBuilder::pushOffset')
360+
@Native<Void Function(Pointer<Void>, Handle, Double, Double, Handle)>(symbol: 'SceneBuilder::pushOffset')
361361
external void _pushOffset(EngineLayer layer, double dx, double dy, EngineLayer? oldLayer);
362362

363363
/// Pushes a rectangular clip operation onto the operation stack.
@@ -386,7 +386,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
386386
return layer;
387387
}
388388

389-
@FfiNative<Void Function(Pointer<Void>, Handle, Double, Double, Double, Double, Int32, Handle)>('SceneBuilder::pushClipRect')
389+
@Native<Void Function(Pointer<Void>, Handle, Double, Double, Double, Double, Int32, Handle)>(symbol: 'SceneBuilder::pushClipRect')
390390
external void _pushClipRect(
391391
EngineLayer outEngineLayer,
392392
double left,
@@ -421,7 +421,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
421421
return layer;
422422
}
423423

424-
@FfiNative<Void Function(Pointer<Void>, Handle, Handle, Int32, Handle)>('SceneBuilder::pushClipRRect')
424+
@Native<Void Function(Pointer<Void>, Handle, Handle, Int32, Handle)>(symbol: 'SceneBuilder::pushClipRRect')
425425
external void _pushClipRRect(EngineLayer layer, Float32List rrect, int clipBehavior, EngineLayer? oldLayer);
426426

427427
/// Pushes a path clip operation onto the operation stack.
@@ -449,7 +449,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
449449
return layer;
450450
}
451451

452-
@FfiNative<Void Function(Pointer<Void>, Handle, Pointer<Void>, Int32, Handle)>('SceneBuilder::pushClipPath')
452+
@Native<Void Function(Pointer<Void>, Handle, Pointer<Void>, Int32, Handle)>(symbol: 'SceneBuilder::pushClipPath')
453453
external void _pushClipPath(EngineLayer layer, Path path, int clipBehavior, EngineLayer? oldLayer);
454454

455455
/// Pushes an opacity operation onto the operation stack.
@@ -477,7 +477,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
477477
return layer;
478478
}
479479

480-
@FfiNative<Void Function(Pointer<Void>, Handle, Int32, Double, Double, Handle)>('SceneBuilder::pushOpacity')
480+
@Native<Void Function(Pointer<Void>, Handle, Int32, Double, Double, Handle)>(symbol: 'SceneBuilder::pushOpacity')
481481
external void _pushOpacity(EngineLayer layer, int alpha, double dx, double dy, EngineLayer? oldLayer);
482482

483483
/// Pushes a color filter operation onto the operation stack.
@@ -505,7 +505,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
505505
return layer;
506506
}
507507

508-
@FfiNative<Void Function(Pointer<Void>, Handle, Pointer<Void>, Handle)>('SceneBuilder::pushColorFilter')
508+
@Native<Void Function(Pointer<Void>, Handle, Pointer<Void>, Handle)>(symbol: 'SceneBuilder::pushColorFilter')
509509
external void _pushColorFilter(EngineLayer layer, _ColorFilter filter, EngineLayer? oldLayer);
510510

511511
/// Pushes an image filter operation onto the operation stack.
@@ -534,7 +534,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
534534
return layer;
535535
}
536536

537-
@FfiNative<Void Function(Pointer<Void>, Handle, Pointer<Void>, Double, Double, Handle)>('SceneBuilder::pushImageFilter')
537+
@Native<Void Function(Pointer<Void>, Handle, Pointer<Void>, Double, Double, Handle)>(symbol: 'SceneBuilder::pushImageFilter')
538538
external void _pushImageFilter(EngineLayer outEngineLayer, _ImageFilter filter, double dx, double dy, EngineLayer? oldLayer);
539539

540540
/// Pushes a backdrop filter operation onto the operation stack.
@@ -561,7 +561,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
561561
return layer;
562562
}
563563

564-
@FfiNative<Void Function(Pointer<Void>, Handle, Pointer<Void>, Int32, Handle)>('SceneBuilder::pushBackdropFilter')
564+
@Native<Void Function(Pointer<Void>, Handle, Pointer<Void>, Int32, Handle)>(symbol: 'SceneBuilder::pushBackdropFilter')
565565
external void _pushBackdropFilter(EngineLayer outEngineLayer, _ImageFilter filter, int blendMode, EngineLayer? oldLayer);
566566

567567
/// Pushes a shader mask operation onto the operation stack.
@@ -599,8 +599,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
599599
return layer;
600600
}
601601

602-
@FfiNative<Void Function(Pointer<Void>, Handle, Pointer<Void>, Double, Double, Double, Double, Int32, Int32, Handle)>(
603-
'SceneBuilder::pushShaderMask')
602+
@Native<Void Function(Pointer<Void>, Handle, Pointer<Void>, Double, Double, Double, Double, Int32, Int32, Handle)>(symbol: 'SceneBuilder::pushShaderMask')
604603
external void _pushShaderMask(
605604
EngineLayer engineLayer,
606605
Shader shader,
@@ -649,7 +648,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
649648
return layer;
650649
}
651650

652-
@FfiNative<Void Function(Pointer<Void>, Handle, Pointer<Void>, Double, Int32, Int32, Int32, Handle)>('SceneBuilder::pushPhysicalShape')
651+
@Native<Void Function(Pointer<Void>, Handle, Pointer<Void>, Double, Int32, Int32, Int32, Handle)>(symbol: 'SceneBuilder::pushPhysicalShape')
653652
external void _pushPhysicalShape(
654653
EngineLayer outEngineLayer,
655654
Path path,
@@ -672,7 +671,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
672671
_pop();
673672
}
674673

675-
@FfiNative<Void Function(Pointer<Void>)>('SceneBuilder::pop', isLeaf: true)
674+
@Native<Void Function(Pointer<Void>)>(symbol: 'SceneBuilder::pop', isLeaf: true)
676675
external void _pop();
677676

678677
/// Add a retained engine layer subtree from previous frames.
@@ -712,7 +711,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
712711
_addRetained(wrapper._nativeLayer!);
713712
}
714713

715-
@FfiNative<Void Function(Pointer<Void>, Handle)>('SceneBuilder::addRetained')
714+
@Native<Void Function(Pointer<Void>, Handle)>(symbol: 'SceneBuilder::addRetained')
716715
external void _addRetained(EngineLayer retainedLayer);
717716

718717
/// Adds an object to the scene that displays performance statistics.
@@ -743,7 +742,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
743742
_addPerformanceOverlay(enabledOptions, bounds.left, bounds.right, bounds.top, bounds.bottom);
744743
}
745744

746-
@FfiNative<Void Function(Pointer<Void>, Uint64, Double, Double, Double, Double)>('SceneBuilder::addPerformanceOverlay', isLeaf: true)
745+
@Native<Void Function(Pointer<Void>, Uint64, Double, Double, Double, Double)>(symbol: 'SceneBuilder::addPerformanceOverlay', isLeaf: true)
747746
external void _addPerformanceOverlay(int enabledOptions, double left, double right, double top, double bottom);
748747

749748
/// Adds a [Picture] to the scene.
@@ -778,7 +777,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
778777
_addPicture(offset.dx, offset.dy, picture, hints);
779778
}
780779

781-
@FfiNative<Void Function(Pointer<Void>, Double, Double, Pointer<Void>, Int32)>('SceneBuilder::addPicture')
780+
@Native<Void Function(Pointer<Void>, Double, Double, Pointer<Void>, Int32)>(symbol: 'SceneBuilder::addPicture')
782781
external void _addPicture(double dx, double dy, Picture picture, int hints);
783782

784783
/// Adds a backend texture to the scene.
@@ -804,7 +803,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
804803
_addTexture(offset.dx, offset.dy, width, height, textureId, freeze, filterQuality.index);
805804
}
806805

807-
@FfiNative<Void Function(Pointer<Void>, Double, Double, Double, Double, Int64, Bool, Int32)>('SceneBuilder::addTexture', isLeaf: true)
806+
@Native<Void Function(Pointer<Void>, Double, Double, Double, Double, Int64, Bool, Int32)>(symbol: 'SceneBuilder::addTexture', isLeaf: true)
808807
external void _addTexture(double dx, double dy, double width, double height, int textureId, bool freeze, int filterQuality);
809808

810809
/// Adds a platform view (e.g an iOS UIView) to the scene.
@@ -833,7 +832,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
833832
_addPlatformView(offset.dx, offset.dy, width, height, viewId);
834833
}
835834

836-
@FfiNative<Void Function(Pointer<Void>, Double, Double, Double, Double, Int64)>('SceneBuilder::addPlatformView', isLeaf: true)
835+
@Native<Void Function(Pointer<Void>, Double, Double, Double, Double, Int64)>(symbol: 'SceneBuilder::addPlatformView', isLeaf: true)
837836
external void _addPlatformView(double dx, double dy, double width, double height, int viewId);
838837

839838
/// Sets a threshold after which additional debugging information should be recorded.
@@ -842,7 +841,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
842841
/// interested in using this feature, please contact [flutter-dev](https://groups.google.com/forum/#!forum/flutter-dev).
843842
/// We'll hopefully be able to figure out how to make this feature more useful
844843
/// to you.
845-
@FfiNative<Void Function(Pointer<Void>, Uint32)>('SceneBuilder::setRasterizerTracingThreshold', isLeaf: true)
844+
@Native<Void Function(Pointer<Void>, Uint32)>(symbol: 'SceneBuilder::setRasterizerTracingThreshold', isLeaf: true)
846845
external void setRasterizerTracingThreshold(int frameInterval);
847846

848847
/// Sets whether the raster cache should checkerboard cached entries. This is
@@ -860,14 +859,14 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
860859
///
861860
/// Currently this interface is difficult to use by end-developers. If you're
862861
/// interested in using this feature, please contact [flutter-dev](https://groups.google.com/forum/#!forum/flutter-dev).
863-
@FfiNative<Void Function(Pointer<Void>, Bool)>('SceneBuilder::setCheckerboardRasterCacheImages', isLeaf: true)
862+
@Native<Void Function(Pointer<Void>, Bool)>(symbol: 'SceneBuilder::setCheckerboardRasterCacheImages', isLeaf: true)
864863
external void setCheckerboardRasterCacheImages(bool checkerboard);
865864

866865
/// Sets whether the compositor should checkerboard layers that are rendered
867866
/// to offscreen bitmaps.
868867
///
869868
/// This is only useful for debugging purposes.
870-
@FfiNative<Void Function(Pointer<Void>, Bool)>('SceneBuilder::setCheckerboardOffscreenLayers', isLeaf: true)
869+
@Native<Void Function(Pointer<Void>, Bool)>(symbol: 'SceneBuilder::setCheckerboardOffscreenLayers', isLeaf: true)
871870
external void setCheckerboardOffscreenLayers(bool checkerboard);
872871

873872
/// Finishes building the scene.
@@ -884,6 +883,6 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
884883
return scene;
885884
}
886885

887-
@FfiNative<Void Function(Pointer<Void>, Handle)>('SceneBuilder::build')
886+
@Native<Void Function(Pointer<Void>, Handle)>(symbol: 'SceneBuilder::build')
888887
external void _build(Scene outScene);
889888
}

lib/ui/dart_ui.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ typedef CanvasPathMeasure PathMeasure;
5555
typedef CanvasGradient Gradient;
5656
typedef CanvasPath Path;
5757

58-
// List of native static functions used as @FfiNative functions.
58+
// List of native static functions used as @Native functions.
5959
// Items are tuples of ('function_name', 'parameter_count'), where:
6060
// 'function_name' is the fully qualified name of the native function.
6161
// 'parameter_count' is the number of parameters the function has.
@@ -65,8 +65,8 @@ typedef CanvasPath Path;
6565
// bindings.
6666
// If the name does not match a native function, the template will fail to
6767
// instatiate, resulting in a compile time error.
68-
// - Resolve the native function pointer associated with an @FfiNative function.
69-
// If there is a mismatch between name or parameter count an @FfiNative is
68+
// - Resolve the native function pointer associated with an @Native function.
69+
// If there is a mismatch between name or parameter count an @Native is
7070
// trying to resolve, an exception will be thrown.
7171
#define FFI_FUNCTION_LIST(V) \
7272
/* Constructors */ \
@@ -117,7 +117,7 @@ typedef CanvasPath Path;
117117
V(DartPluginRegistrant_EnsureInitialized, 0) \
118118
V(Vertices::init, 6)
119119

120-
// List of native instance methods used as @FfiNative functions.
120+
// List of native instance methods used as @Native functions.
121121
// Items are tuples of ('class_name', 'method_name', 'parameter_count'), where:
122122
// 'class_name' is the name of the class containing the method.
123123
// 'method_name' is the name of the method.
@@ -129,8 +129,8 @@ typedef CanvasPath Path;
129129
// bindings.
130130
// If the name does not match a native function, the template will fail to
131131
// instatiate, resulting in a compile time error.
132-
// - Resolve the native function pointer associated with an @FfiNative function.
133-
// If there is a mismatch between names or parameter count an @FfiNative is
132+
// - Resolve the native function pointer associated with an @Native function.
133+
// If there is a mismatch between names or parameter count an @Native is
134134
// trying to resolve, an exception will be thrown.
135135
#define FFI_METHOD_LIST(V) \
136136
V(Canvas, clipPath, 3) \

lib/ui/experiments/scene.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,25 @@ class SceneNode extends NativeFieldWrapperClass1 {
105105
});
106106
}
107107

108-
@FfiNative<Void Function(Handle)>('SceneNode::Create')
108+
@Native<Void Function(Handle)>(symbol: 'SceneNode::Create')
109109
external void _constructor();
110110

111-
@FfiNative<Handle Function(Pointer<Void>, Handle, Handle)>('SceneNode::initFromAsset')
111+
@Native<Handle Function(Pointer<Void>, Handle, Handle)>(symbol: 'SceneNode::initFromAsset')
112112
external String _initFromAsset(String assetKey, _Callback<void> completionCallback);
113113

114-
@FfiNative<Void Function(Pointer<Void>, Handle)>('SceneNode::initFromTransform')
114+
@Native<Void Function(Pointer<Void>, Handle)>(symbol: 'SceneNode::initFromTransform')
115115
external void _initFromTransform(Float64List matrix4);
116116

117-
@FfiNative<Void Function(Pointer<Void>, Handle)>('SceneNode::AddChild')
117+
@Native<Void Function(Pointer<Void>, Handle)>(symbol: 'SceneNode::AddChild')
118118
external void _addChild(SceneNode sceneNode);
119119

120-
@FfiNative<Void Function(Pointer<Void>, Handle)>('SceneNode::SetTransform')
120+
@Native<Void Function(Pointer<Void>, Handle)>(symbol: 'SceneNode::SetTransform')
121121
external void _setTransform(Float64List matrix4);
122122

123-
@FfiNative<Void Function(Pointer<Void>, Handle, Bool, Bool, Double, Double)>('SceneNode::SetAnimationState')
123+
@Native<Void Function(Pointer<Void>, Handle, Bool, Bool, Double, Double)>(symbol: 'SceneNode::SetAnimationState')
124124
external void _setAnimationState(String animationName, bool playing, bool loop, double weight, double timeScale);
125125

126-
@FfiNative<Void Function(Pointer<Void>, Handle, Double)>('SceneNode::SeekAnimation')
126+
@Native<Void Function(Pointer<Void>, Handle, Double)>(symbol: 'SceneNode::SeekAnimation')
127127
external void _seekAnimation(String animationName, double time);
128128

129129
/// Returns a fresh instance of [SceneShader].
@@ -203,12 +203,12 @@ class SceneShader extends Shader {
203203
_dispose();
204204
}
205205

206-
@FfiNative<Void Function(Handle, Handle)>('SceneShader::Create')
206+
@Native<Void Function(Handle, Handle)>(symbol: 'SceneShader::Create')
207207
external void _constructor(SceneNode node);
208208

209-
@FfiNative<Void Function(Pointer<Void>, Handle)>('SceneShader::SetCameraTransform')
209+
@Native<Void Function(Pointer<Void>, Handle)>(symbol: 'SceneShader::SetCameraTransform')
210210
external void _setCameraTransform(Float64List matrix4);
211211

212-
@FfiNative<Void Function(Pointer<Void>)>('SceneShader::Dispose')
212+
@Native<Void Function(Pointer<Void>)>(symbol: 'SceneShader::Dispose')
213213
external void _dispose();
214214
}

lib/ui/isolate_name_server.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ class IsolateNameServer {
7070
return _removePortNameMapping(name);
7171
}
7272

73-
@FfiNative<Handle Function(Handle)>('IsolateNameServerNatives::LookupPortByName')
73+
@Native<Handle Function(Handle)>(symbol: 'IsolateNameServerNatives::LookupPortByName')
7474
external static SendPort? _lookupPortByName(String name);
7575

76-
@FfiNative<Bool Function(Handle, Handle)>('IsolateNameServerNatives::RegisterPortWithName')
76+
@Native<Bool Function(Handle, Handle)>(symbol: 'IsolateNameServerNatives::RegisterPortWithName')
7777
external static bool _registerPortWithName(SendPort port, String name);
7878

79-
@FfiNative<Bool Function(Handle)>('IsolateNameServerNatives::RemovePortNameMapping')
79+
@Native<Bool Function(Handle)>(symbol: 'IsolateNameServerNatives::RemovePortNameMapping')
8080
external static bool _removePortNameMapping(String name);
8181
}

lib/ui/natives.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DartPluginRegistrant {
1818
_ensureInitialized();
1919
}
2020
}
21-
@FfiNative<Void Function()>('DartPluginRegistrant_EnsureInitialized')
21+
@Native<Void Function()>(symbol: 'DartPluginRegistrant_EnsureInitialized')
2222
external static void _ensureInitialized();
2323
}
2424

@@ -32,10 +32,10 @@ void _printDebug(String arg) {
3232
}
3333

3434
class _Logger {
35-
@FfiNative<Void Function(Handle)>('DartRuntimeHooks::Logger_PrintString')
35+
@Native<Void Function(Handle)>(symbol: 'DartRuntimeHooks::Logger_PrintString')
3636
external static void _printString(String? s);
3737

38-
@FfiNative<Void Function(Handle)>('DartRuntimeHooks::Logger_PrintDebugString')
38+
@Native<Void Function(Handle)>(symbol: 'DartRuntimeHooks::Logger_PrintDebugString')
3939
external static void _printDebugString(String? s);
4040
}
4141

@@ -108,13 +108,13 @@ List<int> saveCompilationTrace() {
108108
throw UnimplementedError();
109109
}
110110

111-
@FfiNative<Void Function(Handle)>('DartRuntimeHooks::ScheduleMicrotask')
111+
@Native<Void Function(Handle)>(symbol: 'DartRuntimeHooks::ScheduleMicrotask')
112112
external void _scheduleMicrotask(void Function() callback);
113113

114-
@FfiNative<Handle Function(Handle)>('DartRuntimeHooks::GetCallbackHandle')
114+
@Native<Handle Function(Handle)>(symbol: 'DartRuntimeHooks::GetCallbackHandle')
115115
external int? _getCallbackHandle(Function closure);
116116

117-
@FfiNative<Handle Function(Int64)>('DartRuntimeHooks::GetCallbackFromHandle')
117+
@Native<Handle Function(Int64)>(symbol: 'DartRuntimeHooks::GetCallbackFromHandle')
118118
external Function? _getCallbackFromHandle(int handle);
119119

120120
typedef _PrintClosure = void Function(String line);

0 commit comments

Comments
 (0)