From bfb6f3a975fc208a743e1ea92764d141de40100e Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Wed, 15 Nov 2023 12:06:51 +0100 Subject: [PATCH] [ffigen] Update urls after repo merge --- pkgs/ffigen/README.md | 5 +- pkgs/ffigen/example/README.md | 10 +-- .../example/libclang-example/config.yaml | 5 +- pkgs/ffigen/example/swift/example.dart | 2 +- .../sub_parsers/compounddecl_parser.dart | 6 +- .../sub_parsers/objcinterfacedecl_parser.dart | 3 +- pkgs/ffigen/test/README.md | 9 +-- .../header_parser_tests/struct_fptr_fields.h | 65 +++++++++---------- .../test/native_objc_test/string_test.m | 10 +-- 9 files changed, 59 insertions(+), 56 deletions(-) diff --git a/pkgs/ffigen/README.md b/pkgs/ffigen/README.md index 12e9003d3..b5845c341 100644 --- a/pkgs/ffigen/README.md +++ b/pkgs/ffigen/README.md @@ -1,6 +1,7 @@ -[![pub package](https://img.shields.io/pub/v/ffigen.svg)](https://pub.dev/packages/ffigen) -[![ffigen](https://github.com/dart-lang/native/actions/workflows/ffigen.yml/badge.svg)](https://github.com/dart-lang/native/actions/workflows/ffigen.yml) +[![Build Status](https://github.com/dart-lang/native/actions/workflows/ffigen.yml/badge.svg)](https://github.com/dart-lang/native/actions/workflows/ffigen.yml) [![Coverage Status](https://coveralls.io/repos/github/dart-lang/native/badge.svg?branch=main)](https://coveralls.io/github/dart-lang/native?branch=main) +[![pub package](https://img.shields.io/pub/v/ffigen.svg)](https://pub.dev/packages/ffigen) +[![package publisher](https://img.shields.io/pub/publisher/ffigen.svg)](https://pub.dev/packages/ffigen/publisher) Binding generator for [FFI](https://dart.dev/guides/libraries/c-interop) bindings. diff --git a/pkgs/ffigen/example/README.md b/pkgs/ffigen/example/README.md index cb1ce8cd3..405ceac96 100644 --- a/pkgs/ffigen/example/README.md +++ b/pkgs/ffigen/example/README.md @@ -1,7 +1,7 @@ ## Examples -- [Simple](https://github.com/dart-lang/ffigen/tree/main/example/simple) -- [cJSON](https://github.com/dart-lang/ffigen/tree/main/example/c_json) -- [LibClang](https://github.com/dart-lang/ffigen/tree/main/example/libclang-example) -- [ObjectiveC](https://github.com/dart-lang/ffigen/tree/main/example/objective_c) -- [Swift](https://github.com/dart-lang/ffigen/tree/main/example/swift) +- [Simple](https://github.com/dart-lang/native/tree/main/pkgs/ffigen/example/simple) +- [cJSON](https://github.com/dart-lang/native/tree/main/pkgs/ffigen/example/c_json) +- [LibClang](https://github.com/dart-lang/native/tree/main/pkgs/ffigen/example/libclang-example) +- [ObjectiveC](https://github.com/dart-lang/native/tree/main/pkgs/ffigen/example/objective_c) +- [Swift](https://github.com/dart-lang/native/tree/main/pkgs/ffigen/example/swift) diff --git a/pkgs/ffigen/example/libclang-example/config.yaml b/pkgs/ffigen/example/libclang-example/config.yaml index 69c111e76..6b3db356d 100644 --- a/pkgs/ffigen/example/libclang-example/config.yaml +++ b/pkgs/ffigen/example/libclang-example/config.yaml @@ -10,7 +10,8 @@ output: 'generated_bindings.dart' # - '/usr/local/opt/llvm' # Bash style Glob matching is also supported. -# TODO(11): Globs dont work on windows if they begin with '.' or '..'. +# TODO(https://github.com/dart-lang/ffigen/issues/11): Globs dont work on +# windows if they begin with '.' or '..'. headers: entry-points: - ../../third_party/libclang/include/clang-c/Index.h @@ -33,7 +34,7 @@ functions: - 'clang_.*' # Typedefs for Native and Dart type for these functions will be generated. structs: include: - - 'CX.*' + - 'CX.*' enums: include: - 'CXTypeKind' # Full names are given higher priority than regexp. diff --git a/pkgs/ffigen/example/swift/example.dart b/pkgs/ffigen/example/swift/example.dart index 0e6d9282c..c9dd5ba44 100644 --- a/pkgs/ffigen/example/swift/example.dart +++ b/pkgs/ffigen/example/swift/example.dart @@ -6,7 +6,7 @@ import 'dart:ffi'; import 'swift_api_bindings.dart'; void main() { - // TODO(#443): Add a test for this. + // TODO(https://github.com/dart-lang/ffigen/issues/443): Add a test for this. final lib = SwiftLibrary(DynamicLibrary.open('libswiftapi.dylib')); final object = SwiftClass.new1(lib); print(object.sayHello()); diff --git a/pkgs/ffigen/lib/src/header_parser/sub_parsers/compounddecl_parser.dart b/pkgs/ffigen/lib/src/header_parser/sub_parsers/compounddecl_parser.dart index 8c700c96a..8b162a3e2 100644 --- a/pkgs/ffigen/lib/src/header_parser/sub_parsers/compounddecl_parser.dart +++ b/pkgs/ffigen/lib/src/header_parser/sub_parsers/compounddecl_parser.dart @@ -255,11 +255,13 @@ int _compoundMembersVisitor(clang_types.CXCursor cursor, final mt = cursor.toCodeGenType(); if (mt is IncompleteArray) { - // TODO(68): Structs with flexible Array Members are not supported. + // TODO(https://github.com/dart-lang/ffigen/issues/68): Structs with + // flexible Array Members are not supported. parsed.flexibleArrayMember = true; } if (clang.clang_getFieldDeclBitWidth(cursor) != -1) { - // TODO(84): Struct with bitfields are not suppoorted. + // TODO(https://github.com/dart-lang/ffigen/issues/84): Struct with + // bitfields are not suppoorted. parsed.bitFieldMember = true; } if (mt is HandleType) { diff --git a/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart b/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart index dc3b78657..4fa57c3a3 100644 --- a/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart +++ b/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart @@ -302,7 +302,8 @@ BindingType? parseObjCCategoryDeclaration(clang_types.CXCursor cursor) { return null; } - // TODO(#347): Currently any interface with a category bypasses the filters. + // TODO(https://github.com/dart-lang/ffigen/issues/347): Currently any + // interface with a category bypasses the filters. final itf = itfCursor.type().toCodeGenType(); if (itf is! ObjCInterface) { _logger.severe( diff --git a/pkgs/ffigen/test/README.md b/pkgs/ffigen/test/README.md index dc57474a2..0f4c50c9b 100644 --- a/pkgs/ffigen/test/README.md +++ b/pkgs/ffigen/test/README.md @@ -1,6 +1,3 @@ -[![Build Status](https://github.com/dart-lang/ffigen/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/ffigen/actions?query=workflow%3A"Dart+CI") -[![Coverage Status](https://coveralls.io/repos/github/dart-lang/ffigen/badge.svg?branch=main)](https://coveralls.io/github/dart-lang/ffigen?branch=main) - # ffigen testing ## Running Tests @@ -23,18 +20,18 @@ Some tests verify that the generated Dart FFI bindings match a golden file. For example, the test -[`test/native_test/native_test.dart`](https://github.com/dart-lang/ffigen/blob/main/test/native_test/native_test.dart) +[`test/native_test/native_test.dart`](https://github.com/dart-lang/native/tree/main/pkgs/ffigen/test/native_test/native_test.dart) works by: 1. Loading the dynamic library for - [`test/native_test/native_test.c`](https://github.com/dart-lang/ffigen/blob/main/test/native_test/native_test.c) + [`test/native_test/native_test.c`](https://github.com/dart-lang/native/tree/main/pkgs/ffigen/test/native_test/native_test.c) (which was generated by `dart run test/setup.dart`). 2. Generating binding files for that dynamic library in the `test/debug_generated` directory. 3. Comparing the golden file (i.e. - [`test/native_test/_expected_native_test_bindings.dart`](https://github.com/dart-lang/ffigen/blob/main/test/native_test/_expected_native_test_bindings.dart)) + [`test/native_test/_expected_native_test_bindings.dart`](https://github.com/dart-lang/native/tree/main/pkgs/ffigen/test/native_test/_expected_native_test_bindings.dart)) to the generated file and generating a test failure if they do not match. 4. Using the *golden* bindings to excercise the dynamic library. diff --git a/pkgs/ffigen/test/header_parser_tests/struct_fptr_fields.h b/pkgs/ffigen/test/header_parser_tests/struct_fptr_fields.h index e95d1ca8e..f760d8a7f 100644 --- a/pkgs/ffigen/test/header_parser_tests/struct_fptr_fields.h +++ b/pkgs/ffigen/test/header_parser_tests/struct_fptr_fields.h @@ -4,38 +4,37 @@ typedef int (*ArithmeticOperation)(int a, int b); -struct S -{ - // Function pointer field, but no parameters. - int (*func1)(void); - // Function pointer field with parameters. - int (*comparator)(int a, int b); - // Function pointer field with lot of parameters - int (*veryManyArguments)(double a, float b, char *c, int d, long long e); - // Function pointer field with parameters, but no names - int (*argsDontHaveNames)(int, int, int, float, char *); - // Function pointer through typedef - ArithmeticOperation operation; - // Pointer to function pointer - void (**sortPtr)(int *array, int len); - // Function pointer with a function pointer parameter - void (*sortBy)(int *array, int len, int (*evaluator)(int x)); - // Function where few parameters are named. This should not - // produce parameters in output. - void (*improperlyDeclaredParams)(int a, int, char); - // Function pointer with 2 function pointer parameters - void (*sortByWithFallback)(int *array, - int (*primaryEvaluator)(int x), - int (*fallbackEvaluator)(int x)); +struct S { + // Function pointer field, but no parameters. + int (*func1)(void); + // Function pointer field with parameters. + int (*comparator)(int a, int b); + // Function pointer field with lot of parameters + int (*veryManyArguments)(double a, float b, char *c, int d, long long e); + // Function pointer field with parameters, but no names + int (*argsDontHaveNames)(int, int, int, float, char *); + // Function pointer through typedef + ArithmeticOperation operation; + // Pointer to function pointer + void (**sortPtr)(int *array, int len); + // Function pointer with a function pointer parameter + void (*sortBy)(int *array, int len, int (*evaluator)(int x)); + // Function where few parameters are named. This should not + // produce parameters in output. + void (*improperlyDeclaredParams)(int a, int, char); + // Function pointer with 2 function pointer parameters + void (*sortByWithFallback)(int *array, int (*primaryEvaluator)(int x), + int (*fallbackEvaluator)(int x)); - // TODO(#545): Handle remaining cases of parsing param names - // --- - // Array of function pointers. Does not produce proper output right now. - void (*manyFunctions[2])(char a, char b); - // Function pointer returning function pointer. Does not produce valid output. - int (*(*functionReturningFunction)(int a, int b))(int c, int d); - // Function pointer returning function pointer. The return type has param - // names, but the function itself doesn't. This also shouldn't produce - // any parameters in output. - int (*(*functionReturningFunctionImproper)(int a, int b))(int, int); + // TODO(https://github.com/dart-lang/ffigen/issues/545): Handle remaining + // cases of parsing param names. + // --- + // Array of function pointers. Does not produce proper output right now. + void (*manyFunctions[2])(char a, char b); + // Function pointer returning function pointer. Does not produce valid output. + int (*(*functionReturningFunction)(int a, int b))(int c, int d); + // Function pointer returning function pointer. The return type has param + // names, but the function itself doesn't. This also shouldn't produce + // any parameters in output. + int (*(*functionReturningFunctionImproper)(int a, int b))(int, int); }; diff --git a/pkgs/ffigen/test/native_objc_test/string_test.m b/pkgs/ffigen/test/native_objc_test/string_test.m index 5add18c50..4184c1434 100644 --- a/pkgs/ffigen/test/native_objc_test/string_test.m +++ b/pkgs/ffigen/test/native_objc_test/string_test.m @@ -1,13 +1,15 @@ #import #import -// TODO(#309): strConcat should just be a static function. -@interface StringUtil : NSObject {} -+ (NSString*)strConcat:(NSString*)a with:(NSString*)b; +// TODO(https://github.com/dart-lang/ffigen/issues/309): strConcat should just +// be a static function. +@interface StringUtil : NSObject { +} ++ (NSString *)strConcat:(NSString *)a with:(NSString *)b; @end @implementation StringUtil -+ (NSString*)strConcat:(NSString*)a with:(NSString*)b { ++ (NSString *)strConcat:(NSString *)a with:(NSString *)b { return [a stringByAppendingString:b]; } @end