Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Fix doc comment missing on struct/union array fields, update test, ve… #593

Merged
merged 5 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
10 changes: 5 additions & 5 deletions lib/src/code_generator/compound.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/header_parser/sub_parsers/functiondecl_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ List<Func>? parseFunctionDeclaration(clang_types.CXCursor cursor) {

// 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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just discovered this by accident when parsing -

extern void abcd();
[WARNING]: Skipping variadic-argument config for function abcd since its not variadic.

This didn't affect the flow, but generated a misleading log for every variadic function there would be in the source code

varArgFunctions = config.varArgFunctions[funcName]!;
} else {
_logger.warning(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions test/header_parser_tests/comment_markup.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ struct Com4{

/* Single line field comment. */
float b;

/* Comment on array member. */
int c[3];
};
Original file line number Diff line number Diff line change
Expand Up @@ -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<ffi.Int> c;
}