Fix doc comment missing on struct/union array fields, update test, ve… (#593)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c6919af..1b70ff7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 9.0.1
+
+- Fix doc comment missing on struct/union array fields.
+
# 9.0.0
- Added a JSON schema for FFIgen config files.
diff --git a/lib/src/code_generator/compound.dart b/lib/src/code_generator/compound.dart
index 894d379..db75582 100644
--- a/lib/src/code_generator/compound.dart
+++ b/lib/src/code_generator/compound.dart
@@ -134,17 +134,17 @@
const depth = ' ';
for (final m in members) {
m.name = localUniqueNamer.makeUnique(m.name);
+ if (m.dartDoc != null) {
+ s.write('$depth/// ');
+ s.writeAll(m.dartDoc!.split('\n'), '\n$depth/// ');
+ s.write('\n');
+ }
if (m.type is ConstantArray) {
s.write('$depth@${w.ffiLibraryPrefix}.Array.multi(');
s.write('${_getArrayDimensionLengths(m.type)})\n');
s.write('${depth}external ${_getInlineArrayTypeString(m.type, w)} ');
s.write('${m.name};\n\n');
} else {
- if (m.dartDoc != null) {
- s.write('$depth/// ');
- s.writeAll(m.dartDoc!.split('\n'), '\n$depth/// ');
- s.write('\n');
- }
if (!sameDartAndCType(m.type, w)) {
s.write('$depth@${m.type.getCType(w)}()\n');
}
diff --git a/lib/src/header_parser/sub_parsers/functiondecl_parser.dart b/lib/src/header_parser/sub_parsers/functiondecl_parser.dart
index 94d5ed0..552a0d4 100644
--- a/lib/src/header_parser/sub_parsers/functiondecl_parser.dart
+++ b/lib/src/header_parser/sub_parsers/functiondecl_parser.dart
@@ -70,8 +70,8 @@
// Initialized with a single value with no prefix and empty var args.
var varArgFunctions = [VarArgFunction('', [])];
- if (clang.clang_isFunctionTypeVariadic(cursor.type()) == 1) {
- if (config.varArgFunctions.containsKey(funcName)) {
+ if (config.varArgFunctions.containsKey(funcName)) {
+ if (clang.clang_isFunctionTypeVariadic(cursor.type()) == 1) {
varArgFunctions = config.varArgFunctions[funcName]!;
} else {
_logger.warning(
diff --git a/pubspec.yaml b/pubspec.yaml
index 68a0862..3a8e0c1 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -3,7 +3,7 @@
# BSD-style license that can be found in the LICENSE file.
name: ffigen
-version: 9.0.0
+version: 9.0.1
description: Generator for FFI bindings, using LibClang to parse C header files.
repository: https://github.com/dart-lang/ffigen
diff --git a/test/header_parser_tests/comment_markup.h b/test/header_parser_tests/comment_markup.h
index b3912da..635c2c3 100644
--- a/test/header_parser_tests/comment_markup.h
+++ b/test/header_parser_tests/comment_markup.h
@@ -23,4 +23,7 @@
/* Single line field comment. */
float b;
+
+ /* Comment on array member. */
+ int c[3];
};
diff --git a/test/header_parser_tests/expected_bindings/_expected_comment_markup_bindings.dart b/test/header_parser_tests/expected_bindings/_expected_comment_markup_bindings.dart
index 0575478..91d9908 100644
--- a/test/header_parser_tests/expected_bindings/_expected_comment_markup_bindings.dart
+++ b/test/header_parser_tests/expected_bindings/_expected_comment_markup_bindings.dart
@@ -61,4 +61,8 @@
/// Single line field comment.
@ffi.Float()
external double b;
+
+ /// Comment on array member.
+ @ffi.Array.multi([3])
+ external ffi.Array<ffi.Int> c;
}