-
Notifications
You must be signed in to change notification settings - Fork 52
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
Support @Native
fields and addressOf
#860
Changes from 18 commits
ddb0a4a
99366b8
b9d738c
01e7752
fac544f
d3e9841
305c357
5e4b97d
f521df2
bc19c46
44be567
d4b1388
b9a548f
cb88681
a9a1255
7a858de
2f96aaa
0abde28
4021f28
81bce63
127e5b1
ba586af
3c5bb80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,6 @@ jobs: | |
coverage_web: false | ||
checks: "version,changelog,license,do-not-submit,breaking" | ||
use-flutter: true | ||
sdk: dev | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it work if you put an actual version number here instead of "dev"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the health check is running as intended, only the publish validation workflow needed the dev version. The health check fails due to a missing license on a golden file which never had a license header (and on the libclang bindings file, which probably shouldn't have a Dart license header). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, that should not have a header file. Though I'm still seeing Dart versio issues on the CI?
https://github.com/dart-lang/native/actions/runs/7402310627/job/20139919918?pr=860 @mosuem Any guidance on how to make the health check happy?
(I'm almost inclined to ignore or disable the health check, as it seems too strict for this repo.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will check it out. Thanks for dogfooding the health workflow :) |
||
permissions: | ||
pull-requests: write |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
// 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 | ||
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') | ||
assetId: 'package:ffinative_example/generated_bindings.dart') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, reusing the symbol. Side note which does not have to be addressed in this CL: Should we consider generating @DefaultAsset('package:ffinative_example/generated_bindings.dart')
library; instead of an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should do that, especially considering that there can only be a single There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please file an issue for us to do this later, or add it in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've removed the |
||
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') | ||
external int subtract( | ||
int a, | ||
|
@@ -25,7 +29,6 @@ external int subtract( | |
|
||
/// 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') | ||
external ffi.Pointer<ffi.Int> multiply( | ||
int a, | ||
|
@@ -34,7 +37,6 @@ external ffi.Pointer<ffi.Int> multiply( | |
|
||
/// 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') | ||
external ffi.Pointer<ffi.Float> divide( | ||
int a, | ||
|
@@ -43,9 +45,32 @@ external ffi.Pointer<ffi.Float> divide( | |
|
||
/// 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') | ||
external ffi.Pointer<ffi.Double> dividePrecision( | ||
double a, | ||
double b, | ||
); | ||
|
||
@ffi.Native<ffi.Int>( | ||
assetId: 'package:ffinative_example/generated_bindings.dart') | ||
external int log_level; | ||
|
||
@ffi.Array.multi([5]) | ||
@ffi.Native<ffi.Array<ffi.Int>>( | ||
assetId: 'package:ffinative_example/generated_bindings.dart') | ||
external ffi.Array<ffi.Int> array; | ||
|
||
/// Version of the native C library | ||
@ffi.Native<ffi.Pointer<ffi.Char>>( | ||
assetId: 'package:ffinative_example/generated_bindings.dart') | ||
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); | ||
simolus3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ffi.Pointer<ffi.Pointer<ffi.Char>> get library_version => | ||
ffi.Native.addressOf(self.library_version); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe update the commented stuff to 3.3.0, and file an issue to update this when 3.3.0 beta is released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done - #876.