Skip to content
This repository was archived by the owner on Jan 28, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Build test dylib and bindings
run: dart test/setup.dart
- name: Run VM tests
run: dart test --platform vm
run: dart test --platform vm --concurrency=1

test-mac:
needs: analyze
Expand All @@ -67,7 +67,7 @@ jobs:
- name: Build test dylib and bindings
run: dart test/setup.dart
- name: Run VM tests
run: dart test --platform vm
run: dart test --platform vm --concurrency=1
- name: Collect coverage
run: ./tool/coverage.sh
- name: Upload coverage
Expand All @@ -89,7 +89,7 @@ jobs:
- name: Build test dylib and bindings
run: dart test/setup.dart
- name: Run VM tests
run: dart test --platform vm
run: dart test --platform vm --concurrency=1

# Sanity check the latest `flutter create --template plugin_ffi`.
# This will break if we change the Flutter template or the generated code.
Expand Down
2 changes: 1 addition & 1 deletion example/c_json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ make
## Generating bindings
At the root of this example (`example/c_json`), run -
```
dart run ffigen
dart run ffigen --config config.yaml
```
This will generate bindings in a file: [cjson_generated_bindings.dart](./cjson_generated_bindings.dart)

Expand Down
1 change: 0 additions & 1 deletion example/c_json/cjson_generated_bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
// THE SOFTWARE.

// ignore_for_file: camel_case_types, non_constant_identifier_names

// AUTO GENERATED FILE, DO NOT EDIT.
//
// Generated by `package:ffigen`.
Expand Down
31 changes: 31 additions & 0 deletions example/c_json/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
output: 'cjson_generated_bindings.dart'
name: 'CJson'
description: 'Holds bindings to cJSON.'
headers:
entry-points:
- '../../third_party/cjson_library/cJSON.h'
include-directives:
- '**cJSON.h'
comments: false
preamble: |
// Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// ignore_for_file: camel_case_types, non_constant_identifier_names
33 changes: 0 additions & 33 deletions example/c_json/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,3 @@ dev_dependencies:
ffigen:
path: '../../'
lints: ^2.0.1

ffigen:
output: 'cjson_generated_bindings.dart'
name: 'CJson'
description: 'Holds bindings to cJSON.'
headers:
entry-points:
- '../../third_party/cjson_library/cJSON.h'
include-directives:
- '**cJSON.h'
comments: false
preamble: |
// Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// ignore_for_file: camel_case_types, non_constant_identifier_names
2 changes: 1 addition & 1 deletion example/ffinative/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ A simple example generating `FfiNative` bindings for a very small header file (`
## Generating bindings
At the root of this example (`example/simple`), run -
```
dart run ffigen
dart run ffigen --config config.yaml
```
This will generate bindings in a file: [generated_bindings.dart](./generated_bindings.dart).
10 changes: 10 additions & 0 deletions example/ffinative/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: NativeLibrary
ffi-native:
# asset: 'assetname' # (optional)
description: Bindings to `headers/example.h`.
output: 'generated_bindings.dart'
headers:
entry-points:
- 'headers/example.h'
preamble: |
// ignore_for_file: deprecated_member_use
12 changes: 0 additions & 12 deletions example/ffinative/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,3 @@ dev_dependencies:
ffigen:
path: '../../'
lints: ^2.0.0

ffigen:
name: NativeLibrary
ffi-native:
# asset: 'assetname' # (optional)
description: Bindings to `headers/example.h`.
output: 'generated_bindings.dart'
headers:
entry-points:
- 'headers/example.h'
preamble: |
// ignore_for_file: deprecated_member_use
74 changes: 74 additions & 0 deletions example/libclang-example/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
output: 'generated_bindings.dart'

# This will sort the bindings alphabetically.
# sort: true

# This is required if LLVM can't be found in default locations by ffigen.
# llvm-path:
# - '/usr/local/opt/llvm'

# Bash style Glob matching is also supported.
# TODO(11): Globs dont work on windows if they begin with '.' or '..'.
headers:
entry-points:
- ../../third_party/libclang/include/clang-c/Index.h
include-directives: # use glob syntax to match with header file path.
- '**CXString.h'
- '**Index.h'

compiler-opts:
- '-I../../third_party/libclang/include'
- '-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/'
- '-Wno-nullability-completeness'
functions:
include:
- 'clang_.*' # Can be a regexp, '.' matches any character.
symbol-address:
include:
- 'clang_.*' # Symbol Address for these functions will be exposed via addresses.
expose-typedefs:
include:
- 'clang_.*' # Typedefs for Native and Dart type for these functions will be generated.
structs:
include:
- 'CX.*'
enums:
include:
- 'CXTypeKind' # Full names are given higher priority than regexp.
- 'CXGlobalOptFlags'

library-imports:
custom_import: 'custom_import.dart'

# These can be used to map any typedef to a specific native type.
type-map:
typedefs:
'time_t':
lib: 'ffi'
c-type: 'Int64'
dart-type: 'int'
structs:
'CXCursorSetImpl':
lib: 'custom_import'
c-type: 'CXCursorSetImpl'
dart-type: 'CXCursorSetImpl'

# Default is 'NativeLibrary'
name: 'LibClang'

description: 'Holds bindings to LibClang.'

# Doc Comments for generated binings.
# Comments can be disabled by using comments: false
comments:
style: doxygen # Options - doxygen(default) / any.
length: full # Options - brief / full(default).

# The header of the file, this is pasted as it is.
preamble: |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM
// Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

// ignore_for_file: camel_case_types, non_constant_identifier_names
75 changes: 0 additions & 75 deletions example/libclang-example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,78 +13,3 @@ dev_dependencies:
ffigen:
path: '../../'
lints: ^2.0.1

ffigen:
output: 'generated_bindings.dart'

# This will sort the bindings alphabetically.
# sort: true

# This is required if LLVM can't be found in default locations by ffigen.
# llvm-path:
# - '/usr/local/opt/llvm'

# Bash style Glob matching is also supported.
# TODO(11): Globs dont work on windows if they begin with '.' or '..'.
headers:
entry-points:
- ../../third_party/libclang/include/clang-c/Index.h
include-directives: # use glob syntax to match with header file path.
- '**CXString.h'
- '**Index.h'

compiler-opts:
- '-I../../third_party/libclang/include'
- '-Wno-nullability-completeness'
functions:
include:
- 'clang_.*' # Can be a regexp, '.' matches any character.
symbol-address:
include:
- 'clang_.*' # Symbol Address for these functions will be exposed via addresses.
expose-typedefs:
include:
- 'clang_.*' # Typedefs for Native and Dart type for these functions will be generated.
structs:
include:
- 'CX.*'
enums:
include:
- 'CXTypeKind' # Full names are given higher priority than regexp.
- 'CXGlobalOptFlags'

library-imports:
custom_import: 'custom_import.dart'

# These can be used to map any typedef to a specific native type.
type-map:
typedefs:
'time_t':
lib: 'ffi'
c-type: 'Int64'
dart-type: 'int'
structs:
'CXCursorSetImpl':
lib: 'custom_import'
c-type: 'CXCursorSetImpl'
dart-type: 'CXCursorSetImpl'

# Default is 'NativeLibrary'
name: 'LibClang'

description: 'Holds bindings to LibClang.'

# Doc Comments for generated binings.
# Comments can be disabled by using comments: false
comments:
style: doxygen # Options - doxygen(default) / any.
length: full # Options - brief / full(default).

# The header of the file, this is pasted as it is.
preamble: |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM
// Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

// ignore_for_file: camel_case_types, non_constant_identifier_names
2 changes: 1 addition & 1 deletion example/libclang-example/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ The C header source files for libclang are in [third_party/libclang](/third_part
## Generating bindings
At the root of this example (`example/libclang-example`), run -
```
dart run ffigen
dart run ffigen --config config.yaml
```
This will generate bindings in a file: [generated_bindings.dart](./generated_bindings.dart).
2 changes: 1 addition & 1 deletion example/objective_c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ any of the fields or methods of `AVAudioPlayer`, so we're still able to use
At the root of this example (`example/objective_c`), run:

```
dart run ffigen
dart run ffigen --config config.yaml
```

This will generate [avf_audio_bindings.dart](./avf_audio_bindings.dart).
13 changes: 13 additions & 0 deletions example/objective_c/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: AVFAudio
description: Bindings for AVFAudio.
language: objc
output: 'avf_audio_bindings.dart'
exclude-all-by-default: true
objc-interfaces:
include:
- 'AVAudioPlayer'
headers:
entry-points:
- '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioPlayer.h'
preamble: |
// ignore_for_file: camel_case_types, non_constant_identifier_names, unused_element, unused_field, return_of_invalid_type, void_checks, annotate_overrides, no_leading_underscores_for_local_identifiers, library_private_types_in_public_api
15 changes: 0 additions & 15 deletions example/objective_c/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,3 @@ dev_dependencies:
ffigen:
path: '../../'
lints: ^2.0.0

ffigen:
name: AVFAudio
description: Bindings for AVFAudio.
language: objc
output: 'avf_audio_bindings.dart'
exclude-all-by-default: true
objc-interfaces:
include:
- 'AVAudioPlayer'
headers:
entry-points:
- '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioPlayer.h'
preamble: |
// ignore_for_file: camel_case_types, non_constant_identifier_names, unused_element, unused_field, return_of_invalid_type, void_checks, annotate_overrides, no_leading_underscores_for_local_identifiers, library_private_types_in_public_api
2 changes: 1 addition & 1 deletion example/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ A very simple example, generates bindings for a very small header file (`headers
## Generating bindings
At the root of this example (`example/simple`), run -
```
dart run ffigen
dart run ffigen --config config.yaml
```
This will generate bindings in a file: [generated_bindings.dart](./generated_bindings.dart).
6 changes: 6 additions & 0 deletions example/simple/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: NativeLibrary
description: Bindings to `headers/example.h`.
output: 'generated_bindings.dart'
headers:
entry-points:
- 'headers/example.h'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: newline at end of file

7 changes: 0 additions & 7 deletions example/simple/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,3 @@ dev_dependencies:
path: '../../'
lints: ^2.0.1

ffigen:
name: NativeLibrary
description: Bindings to `headers/example.h`.
output: 'generated_bindings.dart'
headers:
entry-points:
- 'headers/example.h'
2 changes: 1 addition & 1 deletion example/swift/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Once you have an Objective-C wrapper header, ffigen can parse it like
any other header:

```shell
dart run ffigen
dart run ffigen --config config.yaml
```

This will generate [swift_api_bindings.dart](./swift_api_bindings.dart),
Expand Down
Loading