diff --git a/pkgs/ffigen/lib/src/code_generator/type.dart b/pkgs/ffigen/lib/src/code_generator/type.dart index b60aed0cb..fe27ea0e1 100644 --- a/pkgs/ffigen/lib/src/code_generator/type.dart +++ b/pkgs/ffigen/lib/src/code_generator/type.dart @@ -43,7 +43,7 @@ abstract class Type extends AstNode { bool isSubtypeOf(Type other) => other.isSupertypeOf(this); /// Returns true if [this] is a supertype of [other]. That is this :> other. - bool isSupertypeOf(Type other) => this == other; + bool isSupertypeOf(Type other) => this.typealiasType == other.typealiasType; /// Returns the C type of the Type. This is the FFI compatible type that is /// passed to native code. @@ -190,7 +190,7 @@ abstract class BindingType extends NoLookUpBinding implements Type { bool isSubtypeOf(Type other) => other.isSupertypeOf(this); @override - bool isSupertypeOf(Type other) => this == other; + bool isSupertypeOf(Type other) => this.typealiasType == other.typealiasType; @override String getFfiDartType(Writer w) => getCType(w); diff --git a/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart b/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart index db4e70f0f..8e9720ce0 100644 --- a/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart +++ b/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'dart:io'; + import 'package:logging/logging.dart'; import '../../code_generator.dart'; @@ -180,6 +182,11 @@ void _parseSuperType(clang_types.CXCursor cursor, ObjCInterface itf) { setter.params .add(Parameter(name: 'value', type: fieldType, objCConsumed: false)); } + + if (fieldName == 'identifier') { + stderr.writeln("ZZZZZZZZZZZ: PROP ${decl.originalName}\t\t$getter\t\t$setter"); + } + return (getter, setter); } @@ -216,6 +223,11 @@ ObjCMethod? parseObjCMethod(clang_types.CXCursor cursor, Declaration itfDecl, ); _logger.fine(' > ${isClassMethod ? 'Class' : 'Instance'} method: ' '${method.originalName} ${cursor.completeStringRepr()}'); + + if (methodName == 'identifier') { + stderr.writeln("ZZZZZZZZZZZ: MTHD ${itfDecl.originalName}\t\t$method"); + } + var hasError = false; cursor.visitChildren((child) { switch (child.kind) { diff --git a/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcprotocoldecl_parser.dart b/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcprotocoldecl_parser.dart index d9ab7df2f..dde0a22c8 100644 --- a/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcprotocoldecl_parser.dart +++ b/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcprotocoldecl_parser.dart @@ -61,6 +61,12 @@ ObjCProtocol? parseObjCProtocolDeclaration(clang_types.CXCursor cursor) { protocol.superProtocols.add(superProtocol); } break; + case clang_types.CXCursorKind.CXCursor_ObjCPropertyDecl: + final (getter, setter) = + parseObjCProperty(child, decl, config.objcProtocols); + protocol.addMethod(getter); + protocol.addMethod(setter); + break; case clang_types.CXCursorKind.CXCursor_ObjCInstanceMethodDecl: case clang_types.CXCursorKind.CXCursor_ObjCClassMethodDecl: protocol.addMethod(parseObjCMethod(child, decl, config.objcProtocols)); diff --git a/pkgs/ffigen/lib/src/visitor/copy_methods_from_super_type.dart b/pkgs/ffigen/lib/src/visitor/copy_methods_from_super_type.dart index 65431f6f5..91a2ce11e 100644 --- a/pkgs/ffigen/lib/src/visitor/copy_methods_from_super_type.dart +++ b/pkgs/ffigen/lib/src/visitor/copy_methods_from_super_type.dart @@ -87,13 +87,7 @@ class CopyMethodsFromSuperTypesVisitation extends Visitation { for (final proto in protocols) { for (final m in proto.methods) { if (isNSObject) { - if (m.originalName == 'description' || m.originalName == 'hash') { - // TODO(https://github.com/dart-lang/native/issues/1220): Remove - // this special case. These methods only clash because they're - // sometimes declared as getters and sometimes as normal methods. - } else { - addMethod(m); - } + addMethod(m); } else if (!_excludedNSObjectMethods.contains(m.originalName)) { addMethod(m); } diff --git a/pkgs/ffigen/test/large_integration_tests/large_objc_test.dart b/pkgs/ffigen/test/large_integration_tests/large_objc_test.dart index 06ba75645..5d003f351 100644 --- a/pkgs/ffigen/test/large_integration_tests/large_objc_test.dart +++ b/pkgs/ffigen/test/large_integration_tests/large_objc_test.dart @@ -39,28 +39,6 @@ void main() { shouldIncludeMember: randInclude, ); - // TODO(https://github.com/dart-lang/native/issues/1220): Allow these. - const disallowedMethods = { - 'accessKey', - 'allowsCellularAccess', - 'allowsConstrainedNetworkAccess', - 'attributedString', - 'cachePolicy', - 'candidateListTouchBarItem', - 'delegate', - 'hyphenationFactor', - 'image', - 'isProxy', - 'objCType', - 'tag', - 'title', - }; - final interfaceFilter = DeclarationFilters( - shouldInclude: randInclude, - shouldIncludeMember: (_, method) => - randInclude() && !disallowedMethods.contains(method), - ); - const outFile = 'test/large_integration_tests/large_objc_bindings.dart'; const outObjCFile = 'test/large_integration_tests/large_objc_bindings.m'; final config = Config( @@ -80,7 +58,7 @@ void main() { unnamedEnumConstants: randomFilter, globals: randomFilter, typedefs: randomFilter, - objcInterfaces: interfaceFilter, + objcInterfaces: randomFilter, objcProtocols: randomFilter, objcCategories: randomFilter, externalVersions: ExternalVersions( diff --git a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart index a8117be61..67b86779e 100644 --- a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart @@ -412,7 +412,7 @@ class NSArray extends NSObject { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635(_class_NSArray, _sel_supportsSecureCoding); } @@ -654,7 +654,7 @@ class NSCharacterSet extends NSObject { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635( _class_NSCharacterSet, _sel_supportsSecureCoding); } @@ -930,7 +930,7 @@ class NSData extends NSObject { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635(_class_NSData, _sel_supportsSecureCoding); } @@ -1305,7 +1305,7 @@ class NSDate extends NSObject { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635(_class_NSDate, _sel_supportsSecureCoding); } @@ -1485,7 +1485,7 @@ class NSDictionary extends NSObject { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635(_class_NSDictionary, _sel_supportsSecureCoding); } @@ -1709,7 +1709,7 @@ class NSError extends NSObject { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635(_class_NSError, _sel_supportsSecureCoding); } @@ -1944,7 +1944,7 @@ class NSIndexSet extends NSObject { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635(_class_NSIndexSet, _sel_supportsSecureCoding); } @@ -2627,7 +2627,7 @@ class NSMutableArray extends NSArray { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635( _class_NSMutableArray, _sel_supportsSecureCoding); } @@ -2860,7 +2860,7 @@ class NSMutableData extends NSData { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635( _class_NSMutableData, _sel_supportsSecureCoding); } @@ -3152,7 +3152,7 @@ class NSMutableDictionary extends NSDictionary { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635( _class_NSMutableDictionary, _sel_supportsSecureCoding); } @@ -3305,7 +3305,7 @@ class NSMutableIndexSet extends NSIndexSet { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635( _class_NSMutableIndexSet, _sel_supportsSecureCoding); } @@ -3540,7 +3540,7 @@ class NSMutableOrderedSet extends NSOrderedSet { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635( _class_NSMutableOrderedSet, _sel_supportsSecureCoding); } @@ -3793,7 +3793,7 @@ class NSMutableSet extends NSSet { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635(_class_NSMutableSet, _sel_supportsSecureCoding); } @@ -4075,7 +4075,7 @@ class NSMutableString extends NSString { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635( _class_NSMutableString, _sel_supportsSecureCoding); } @@ -4493,7 +4493,7 @@ class NSNumber extends NSValue { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635(_class_NSNumber, _sel_supportsSecureCoding); } @@ -4901,7 +4901,7 @@ class NSObject extends objc.ObjCObjectBase { } /// debugDescription - NSString debugDescription1() { + NSString get debugDescription1 { if (!objc.respondsToSelector(this.ref.pointer, _sel_debugDescription)) { throw objc.UnimplementedOptionalMethodException( 'NSObject', 'debugDescription'); @@ -4910,6 +4910,12 @@ class NSObject extends objc.ObjCObjectBase { return NSString.castFromPointer(_ret, retain: true, release: true); } + /// description + NSString get description1 { + final _ret = _objc_msgSend_1x359cv(this.ref.pointer, _sel_description); + return NSString.castFromPointer(_ret, retain: true, release: true); + } + /// doesNotRecognizeSelector: void doesNotRecognizeSelector_(ffi.Pointer aSelector) { _objc_msgSend_1d9e4oe( @@ -4930,6 +4936,11 @@ class NSObject extends objc.ObjCObjectBase { return objc.ObjCObjectBase(_ret, retain: true, release: true); } + /// hash + int get hash1 { + return _objc_msgSend_xw2lbc(this.ref.pointer, _sel_hash); + } + /// init NSObject init() { final _ret = @@ -5040,7 +5051,7 @@ class NSObject extends objc.ObjCObjectBase { } /// superclass - objc.ObjCObjectBase superclass1() { + objc.ObjCObjectBase get superclass1 { final _ret = _objc_msgSend_1x359cv(this.ref.pointer, _sel_superclass); return objc.ObjCObjectBase(_ret, retain: true, release: true); } @@ -5328,7 +5339,7 @@ class NSOrderedSet extends NSObject { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635(_class_NSOrderedSet, _sel_supportsSecureCoding); } @@ -5862,7 +5873,7 @@ class NSSet extends NSObject { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635(_class_NSSet, _sel_supportsSecureCoding); } @@ -6426,7 +6437,7 @@ class NSString extends NSObject { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635(_class_NSString, _sel_supportsSecureCoding); } @@ -7735,7 +7746,7 @@ class NSURL extends NSObject { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635(_class_NSURL, _sel_supportsSecureCoding); } @@ -8335,7 +8346,7 @@ class NSValue extends NSObject { } /// supportsSecureCoding - static bool supportsSecureCoding() { + static bool getSupportsSecureCoding() { return _objc_msgSend_91o635(_class_NSValue, _sel_supportsSecureCoding); }