[ffigen] Fix generation of duplicate constants with multiple entry points (#178)
diff --git a/pkgs/ffigen/CHANGELOG.md b/pkgs/ffigen/CHANGELOG.md index cd555c8..2c76c31 100644 --- a/pkgs/ffigen/CHANGELOG.md +++ b/pkgs/ffigen/CHANGELOG.md
@@ -1,3 +1,6 @@ +# 2.2.1 +- Fixed generation of duplicate constants suffixed with `_<int>` when using multiple entry points. + # 2.2.0 - Added subkey `symbol-address` to expose native symbol pointers for `functions` and `globals`.
diff --git a/pkgs/ffigen/lib/src/header_parser/sub_parsers/unnamed_enumdecl_parser.dart b/pkgs/ffigen/lib/src/header_parser/sub_parsers/unnamed_enumdecl_parser.dart index 584694d..4cac558 100644 --- a/pkgs/ffigen/lib/src/header_parser/sub_parsers/unnamed_enumdecl_parser.dart +++ b/pkgs/ffigen/lib/src/header_parser/sub_parsers/unnamed_enumdecl_parser.dart
@@ -55,15 +55,17 @@ /// Adds the parameter to func in [functiondecl_parser.dart]. void _addUnNamedEnumConstant(clang_types.CXCursor cursor) { - unnamedEnumConstants.add( - Constant( - usr: cursor.usr(), - originalName: cursor.spelling(), - name: config.unnamedEnumConstants.renameUsingConfig( - cursor.spelling(), - ), - rawType: 'int', - rawValue: clang.clang_getEnumConstantDeclValue(cursor).toString(), + _logger.fine( + '++++ Adding Constant from unnamed enum: ${cursor.completeStringRepr()}'); + final constant = Constant( + usr: cursor.usr(), + originalName: cursor.spelling(), + name: config.unnamedEnumConstants.renameUsingConfig( + cursor.spelling(), ), + rawType: 'int', + rawValue: clang.clang_getEnumConstantDeclValue(cursor).toString(), ); + bindingsIndex.addUnnamedEnumConstantToSeen(cursor.usr(), constant); + unnamedEnumConstants.add(constant); }
diff --git a/pkgs/ffigen/pubspec.yaml b/pkgs/ffigen/pubspec.yaml index 860f4e8..df6c00b 100644 --- a/pkgs/ffigen/pubspec.yaml +++ b/pkgs/ffigen/pubspec.yaml
@@ -3,7 +3,7 @@ # BSD-style license that can be found in the LICENSE file. name: ffigen -version: 2.2.0 +version: 2.2.1 homepage: https://github.com/dart-lang/ffigen description: Generator for FFI bindings, using LibClang to parse C header files.