Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
liamappelbe committed Oct 25, 2024
1 parent 77fd05b commit bbbbbe0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 38 deletions.
5 changes: 3 additions & 2 deletions pkgs/ffigen/lib/src/header_parser/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ List<Binding> _transformBindings(Config config, List<Binding> bindings) {
final included =
visit(ApplyConfigFiltersVisitation(config), bindings).included;

final byValueCompounds =
visit(FindByValueCompoundsVisitation(), FindByValueCompoundsVisitation.rootNodes(included)).byValueCompounds;
final byValueCompounds = visit(FindByValueCompoundsVisitation(),
FindByValueCompoundsVisitation.rootNodes(included))
.byValueCompounds;
visit(
ClearOpaqueCompoundMembersVisitation(config, byValueCompounds, included),
bindings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,18 @@ List<Func> parseFunctionDeclaration(clang_types.CXCursor cursor) {
}

if (returnType.isIncompleteCompound || incompleteStructParameter) {
_logger
.fine('---- Removed Function, reason: Incomplete struct pass/return by '
'value: ${cursor.completeStringRepr()}');
_logger.fine(
'---- Removed Function, reason: Incomplete struct pass/return by '
'value: ${cursor.completeStringRepr()}');
_logger.warning(
"Skipped Function '$funcName', Incomplete struct pass/return by "
'value not supported.');
// Returning null so that [addToBindings] function excludes this.
return funcs;
}

if (returnType.baseType is UnimplementedType || unimplementedParameterType) {
if (returnType.baseType is UnimplementedType ||
unimplementedParameterType) {
_logger.fine('---- Removed Function, reason: unsupported return type or '
'parameter type: ${cursor.completeStringRepr()}');
_logger.warning(
Expand Down Expand Up @@ -128,7 +129,8 @@ List<Func> parseFunctionDeclaration(clang_types.CXCursor cursor) {
varArgParameters: vaFunc.types
.map((ta) => Parameter(type: ta, name: 'va', objCConsumed: false))
.toList(),
exposeSymbolAddress: config.functionDecl.shouldIncludeSymbolAddress(decl),
exposeSymbolAddress:
config.functionDecl.shouldIncludeSymbolAddress(decl),
exposeFunctionTypedefs: config.shouldExposeFunctionTypedef(decl),
isLeaf: config.isLeafFunction(decl),
objCReturnsRetained: objCReturnsRetained,
Expand Down
10 changes: 6 additions & 4 deletions pkgs/ffigen/test/header_parser_tests/globals_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ ${strings.ignoreSourceErrors}: true

Library expectedLibrary() {
final globalStruct = Struct(name: 'EmptyStruct');
final globalStructAlias = Typealias(
name: 'EmptyStruct_Alias',
type: globalStruct,
);
return Library(
name: 'Bindings',
bindings: [
Expand Down Expand Up @@ -121,12 +125,10 @@ Library expectedLibrary() {
type: globalStruct,
exposeSymbolAddress: true,
),
globalStructAlias,
Global(
name: 'globalStruct_from_alias',
type: Typealias(
name: 'EmptyStruct_Alias',
type: globalStruct,
),
type: globalStructAlias,
exposeSymbolAddress: true,
)
],
Expand Down
60 changes: 33 additions & 27 deletions pkgs/ffigen/test/header_parser_tests/nested_parsing_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,40 @@ Library expectedLibrary() {
type: intType,
),
]);
final unnamedUnion1 = Union(
name: 'UnnamedUnion1',
members: [
CompoundMember(
name: 'a',
type: floatType,
),
],
);
final unnamedUnion2 = Union(
name: 'UnnamedUnion2',
members: [
CompoundMember(
name: 'b',
type: floatType,
),
],
);
final unnamedUnion3 = Union(
name: 'UnnamedUnion3',
members: [
CompoundMember(
name: 'd',
type: floatType,
),
],
);
return Library(
name: 'Bindings',
bindings: [
unnamedInternalStruct,
unnamedUnion1,
unnamedUnion2,
unnamedUnion3,
struct2,
Struct(name: 'Struct1', members: [
CompoundMember(
Expand Down Expand Up @@ -117,39 +147,15 @@ Library expectedLibrary() {
members: [
CompoundMember(
name: '',
type: Union(
name: 'UnnamedUnion1',
members: [
CompoundMember(
name: 'a',
type: floatType,
),
],
),
type: unnamedUnion1,
),
CompoundMember(
name: 'c',
type: Union(
name: 'UnnamedUnion2',
members: [
CompoundMember(
name: 'b',
type: floatType,
),
],
),
type: unnamedUnion2,
),
CompoundMember(
name: 'e',
type: Union(
name: 'UnnamedUnion3',
members: [
CompoundMember(
name: 'd',
type: floatType,
),
],
),
type: unnamedUnion3,
),
],
),
Expand Down

0 comments on commit bbbbbe0

Please sign in to comment.