commit | 764c36e42838198e783b6a76194d1f583edc619a | [log] [tgz] |
---|---|---|
author | Prerak Mann <31154435+mannprerak2@users.noreply.github.com> | Wed Jul 08 17:57:44 2020 +0530 |
committer | GitHub <noreply@github.com> | Wed Jul 08 14:27:44 2020 +0200 |
tree | fcc457e3cbc820c54964e80b7cbabbb2527a9ff2 | |
parent | 993627e11c17ca73ad71ee131f15b3b0c8c82e89 [diff] |
Support for Prefix and Names in config. (#20) - Support for global prefix and prefix replacement in functions/structs/enums - Handles all internal name collisions (such as those between - dylib identifier, ffi import prefix, any typedefs generated, array helper classes, expanded array items, declarations, init function) if a collision occurs its suffixed by `_cr<int>` - Added tests for prefixing and collisions
Experimental binding generator for FFI bindings.
For some header file example.h:
int sum(int a, int b);
Add configurations to Pubspec File:
ffigen: output: 'generated_bindings.dart' headers: - 'example.h'
Output (generated_bindings.dart).
DynamicLibrary _dylib; /// Initialises dynamic library void init(DynamicLibrary dylib) { _dylib = dylib; } int sum(int a,int b) { return _sum(a,b); } final _dart_sum _sum = _dylib.lookupFunction<_c_sum, _dart_sum>('sum'); typedef _c_sum = Int32 Function(Int32 a,Int32 b); typedef _dart_sum = int Function(int a,int b);
pubspec.yaml
.ffigen
(or directly under a seperate yaml file which when u specify it passing --config filename
when running the tool)pub run ffigen
.A dynamic library for a wrapper to libclang needs to be generated as it is used by the parser submodule.
sudo apt-get install libclang-dev
.cd tool/wrapped_libclang
, then run dart build.dart
.cd tool\wrapped_libclang
, then run dart build.dart
.cd tool/wrapped_libclang
, then run dart build.dart
.cd examples/<example_u_want_to_run>
, Run pub get
.pub run ffigen
.Dynamic library for some tests need to be built before running the examples.
cd test/native_functions_test
.dart build_test_dylib.dart
.Run tests from the root of the package with pub run test
.