Skip to content

Commit

Permalink
Fix the bug
Browse files Browse the repository at this point in the history
  • Loading branch information
liamappelbe committed Sep 25, 2024
1 parent 88e1517 commit 732f198
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
11 changes: 0 additions & 11 deletions pkgs/ffigen/lib/src/code_generator/objc_methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,8 @@ mixin ObjCMethods {

bool _shouldIncludeMethod(ObjCMethod method) =>
method.childTypes.every((Type t) {
if (method.originalName ==
"initWithValidatedFormat:validFormatSpecifiers:locale:arguments:error:") {
print(
"\n\n\nDLFKgJSDLFKJGLSDKF\n\n\n$method\n$t\n${t is Typealias}\n${t is Typealias ? t.originalName : '---'}\n\n\n");
}
t = t.typealiasType.baseType;

// Ignore methods with variadic args.
// TODO(https://github.com/dart-lang/native/issues/1192): Remove this.
if (t is Struct && t.originalName == '__va_list_tag') {
return false;
}

// Ignore methods with block args or rets when we're generating in
// package:objective_c.
// TODO(https://github.com/dart-lang/native/issues/1180): Remove this.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ void _parseInterfaceMethod(
ObjCMethod? parseObjCMethod(clang_types.CXCursor cursor, Declaration itfDecl,
DeclarationFilters filters) {
final methodName = cursor.spelling();
final debug = methodName ==
"initWithValidatedFormat:validFormatSpecifiers:locale:arguments:error:";
final isClassMethod =
cursor.kind == clang_types.CXCursorKind.CXCursor_ObjCClassMethodDecl;
final isOptionalMethod = clang.clang_Cursor_isObjCOptional(cursor) != 0;
Expand Down Expand Up @@ -275,16 +273,24 @@ ObjCMethod? parseObjCMethod(clang_types.CXCursor cursor, Declaration itfDecl,
bool _parseMethodParam(clang_types.CXCursor cursor, String itfName,
ObjCMethod method, bool debug) {
final name = cursor.spelling();
final type = cursor.type().toCodeGenType();
if (debug) {
print("\t\t\t$name\t$type\t${cursor.type().completeStringRepr()}");
final cursorType = cursor.type();

// Ignore methods with variadic args.
// TODO(https://github.com/dart-lang/native/issues/1192): Remove this.
if (cursorType.kind == clang_types.CXTypeKind.CXType_Elaborated &&
cursorType.spelling == 'va_list') {
_logger.warning('Method "${method.originalName}" in instance '
'"$itfName" has variadic args, which are not currently supported');
return false;
}

final type = cursorType.toCodeGenType();
if (type.isIncompleteCompound) {
_logger.warning('Method "${method.originalName}" in instance '
'"$itfName" has incomplete '
'parameter type: $type.');
'"$itfName" has incomplete parameter type: $type.');
return false;
}

_logger.fine(
' >> Parameter: $type $name ${cursor.completeStringRepr()}');
final consumed =
Expand Down

0 comments on commit 732f198

Please sign in to comment.