dcdfcc2b8d
This reverts commit1800039c2a. The changesfd2e9b9f1aandc20f9eaf6fare relanded as is. Reason for revert was fixed separately in https://dart-review.googlesource.com/c/sdk/+/341621 TEST=ci CoreLibraryReviewExempt: Implementation change only. Issue: https://github.com/dart-lang/sdk/issues/54172 Issue: https://github.com/dart-lang/sdk/issues/39692 Change-Id: I1a2324768502e5ffbce328127938c0d3c96c38ba Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341642 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
56 lines
1.4 KiB
Markdown
56 lines
1.4 KiB
Markdown
# Pragmas used in the FFI implementation
|
|
|
|
## Native Assets
|
|
|
|
This pragma is used for passing native assets to the VM.
|
|
|
|
```
|
|
@pragma('vm:ffi:native-assets', {
|
|
'format-version': [1, 0, 0],
|
|
'native-assets': {
|
|
'linux_x64': {
|
|
'package:foo/foo.dart': ['absolute', '/path/to/libfoo.so']
|
|
}
|
|
}
|
|
})
|
|
library 'vm:native-assets';
|
|
```
|
|
|
|
Related files:
|
|
|
|
* [pkg/vm/lib/native_assets/load_and_validate.dart](../../../pkg/vm/lib/native_assets/load_and_validate.dart)
|
|
* [pkg/vm/test/native_assets_validator_test.dart](../../../pkg/vm/test/native_assets_validator_test.dart)
|
|
* [runtime/lib/ffi_dynamic_library.cc](../../../runtime/lib/ffi_dynamic_library.cc)
|
|
* [runtime/vm/ffi/native_assets.cc](../../../runtime/vm/ffi/native_assets.cc)
|
|
|
|
## Native
|
|
|
|
The fully expanded version of `@Native` passed to the VM.
|
|
|
|
```
|
|
@pragma(
|
|
'vm:ffi:native',
|
|
Native<IntPtr Function(Pointer<Void>, IntPtr)>(
|
|
symbol: 'MyClass_MyMethod',
|
|
assetId: '<library uri>',
|
|
),
|
|
)
|
|
external int _myFunction$FfiNative(Pointer<Void> self, int x);
|
|
```
|
|
|
|
This is passed as a pragma so it is treated consistently with other pragmas.
|
|
|
|
Related files:
|
|
|
|
* [runtime/vm/kernel_loader.cc](../../../runtime/vm/kernel_loader.cc)
|
|
* [runtime/vm/object.cc](../../../runtime/vm/object.cc)
|
|
|
|
## FFI Calls
|
|
|
|
This pragma is used to mark Dart closures which perform FFI calls:
|
|
|
|
```
|
|
@pragma('vm:ffi:call-closure', _FfiCall<Int32 Function(Int32)>(isLeaf: false))
|
|
int #ffiCall0(int arg1) => _ffiCall<int>(target);
|
|
```
|