diff --git a/CHANGELOG.md b/CHANGELOG.md index c6919af9..1b70ff75 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 894d3799..db755826 100644 --- a/lib/src/code_generator/compound.dart +++ b/lib/src/code_generator/compound.dart @@ -134,17 +134,17 @@ abstract class Compound extends BindingType { 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/pubspec.yaml b/pubspec.yaml index 68a08628..3a8e0c15 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 b3912dab..603f8861 100644 --- a/test/header_parser_tests/comment_markup.h +++ b/test/header_parser_tests/comment_markup.h @@ -23,4 +23,7 @@ struct Com4{ /* 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 05754781..6509ec86 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 @@ final class Com4 extends ffi.Struct { /// Single line field comment. @ffi.Float() external double b; + + /// Comment on array member + @ffi.Array.multi([3]) + external ffi.Array c; }