-
Notifications
You must be signed in to change notification settings - Fork 69
Support @Native
fields and addressOf
#860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
ddb0a4a
Implement native fields and addressOf
simolus3 99366b8
Add changelog entry
simolus3 b9d738c
Fix missing type name
simolus3 01e7752
Support array fields
simolus3 fac544f
Merge remote-tracking branch 'upstream/main' into native-fields
simolus3 d3e9841
Include asset id if desired
simolus3 305c357
Add generation tests
simolus3 5e4b97d
Fix license headers
simolus3 f521df2
Use dev sdk for tests
simolus3 bc19c46
Use self imports
simolus3 44be567
Raise SDK constraints
simolus3 d4b1388
Update expectations
simolus3 b9a548f
Review feedback
simolus3 cb88681
Happy new year dear health check
simolus3 a9a1255
Merge remote-tracking branch 'upstream/main' into native-fields
simolus3 7a858de
More review feedback
simolus3 2f96aaa
Fix tests
simolus3 0abde28
Use dev SDK
simolus3 4021f28
Bring back upper SDK bound
simolus3 81bce63
Remove version from health job
simolus3 127e5b1
Add comments for 3.3 release
simolus3 ba586af
Update health.yaml
mosuem 3c5bb80
Revert license header change in test
simolus3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 34 additions & 14 deletions
48
pkgs/ffigen/example/ffinative/lib/generated_bindings.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,71 @@ | ||
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
// ignore_for_file: deprecated_member_use | ||
|
||
// AUTO GENERATED FILE, DO NOT EDIT. | ||
// | ||
// Generated by `package:ffigen`. | ||
// ignore_for_file: type=lint | ||
@ffi.DefaultAsset('package:ffinative_example/generated_bindings.dart') | ||
library; | ||
|
||
import 'dart:ffi' as ffi; | ||
import '' as self; | ||
|
||
/// Adds 2 integers. | ||
@ffi.Native<ffi.Int Function(ffi.Int, ffi.Int)>( | ||
symbol: 'sum', assetId: 'package:ffinative_example/generated_bindings.dart') | ||
@ffi.Native<ffi.Int Function(ffi.Int, ffi.Int)>() | ||
external int sum( | ||
int a, | ||
int b, | ||
); | ||
|
||
/// Subtracts 2 integers. | ||
@ffi.Native<ffi.Int Function(ffi.Int, ffi.Int)>( | ||
symbol: 'subtract', | ||
assetId: 'package:ffinative_example/generated_bindings.dart') | ||
@ffi.Native<ffi.Int Function(ffi.Int, ffi.Int)>() | ||
external int subtract( | ||
int a, | ||
int b, | ||
); | ||
|
||
/// Multiplies 2 integers, returns pointer to an integer,. | ||
@ffi.Native<ffi.Pointer<ffi.Int> Function(ffi.Int, ffi.Int)>( | ||
symbol: 'multiply', | ||
assetId: 'package:ffinative_example/generated_bindings.dart') | ||
@ffi.Native<ffi.Pointer<ffi.Int> Function(ffi.Int, ffi.Int)>() | ||
external ffi.Pointer<ffi.Int> multiply( | ||
int a, | ||
int b, | ||
); | ||
|
||
/// Divides 2 integers, returns pointer to a float. | ||
@ffi.Native<ffi.Pointer<ffi.Float> Function(ffi.Int, ffi.Int)>( | ||
symbol: 'divide', | ||
assetId: 'package:ffinative_example/generated_bindings.dart') | ||
@ffi.Native<ffi.Pointer<ffi.Float> Function(ffi.Int, ffi.Int)>() | ||
external ffi.Pointer<ffi.Float> divide( | ||
int a, | ||
int b, | ||
); | ||
|
||
/// Divides 2 floats, returns a pointer to double. | ||
@ffi.Native<ffi.Pointer<ffi.Double> Function(ffi.Float, ffi.Float)>( | ||
symbol: 'dividePrecision', | ||
assetId: 'package:ffinative_example/generated_bindings.dart') | ||
@ffi.Native<ffi.Pointer<ffi.Double> Function(ffi.Float, ffi.Float)>() | ||
external ffi.Pointer<ffi.Double> dividePrecision( | ||
double a, | ||
double b, | ||
); | ||
|
||
@ffi.Native<ffi.Int>() | ||
external int log_level; | ||
|
||
@ffi.Array.multi([5]) | ||
@ffi.Native<ffi.Array<ffi.Int>>() | ||
external ffi.Array<ffi.Int> array; | ||
|
||
/// Version of the native C library | ||
@ffi.Native<ffi.Pointer<ffi.Char>>() | ||
external final ffi.Pointer<ffi.Char> library_version; | ||
|
||
const addresses = _SymbolAddresses(); | ||
|
||
class _SymbolAddresses { | ||
const _SymbolAddresses(); | ||
ffi.Pointer<ffi.NativeFunction<ffi.Int Function(ffi.Int, ffi.Int)>> get sum => | ||
ffi.Native.addressOf(self.sum); | ||
ffi.Pointer<ffi.Pointer<ffi.Char>> get library_version => | ||
ffi.Native.addressOf(self.library_version); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.