Skip to content

Commit

Permalink
Fix large test
Browse files Browse the repository at this point in the history
  • Loading branch information
liamappelbe committed Nov 12, 2024
1 parent bccd016 commit b77e3ff
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 54 deletions.
4 changes: 2 additions & 2 deletions pkgs/ffigen/lib/src/code_generator/type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
24 changes: 1 addition & 23 deletions pkgs/ffigen/test/large_integration_tests/large_objc_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -80,7 +58,7 @@ void main() {
unnamedEnumConstants: randomFilter,
globals: randomFilter,
typedefs: randomFilter,
objcInterfaces: interfaceFilter,
objcInterfaces: randomFilter,
objcProtocols: randomFilter,
objcCategories: randomFilter,
externalVersions: ExternalVersions(
Expand Down
55 changes: 33 additions & 22 deletions pkgs/objective_c/lib/src/objective_c_bindings_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class NSArray extends NSObject {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(_class_NSArray, _sel_supportsSecureCoding);
}

Expand Down Expand Up @@ -654,7 +654,7 @@ class NSCharacterSet extends NSObject {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(
_class_NSCharacterSet, _sel_supportsSecureCoding);
}
Expand Down Expand Up @@ -930,7 +930,7 @@ class NSData extends NSObject {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(_class_NSData, _sel_supportsSecureCoding);
}

Expand Down Expand Up @@ -1305,7 +1305,7 @@ class NSDate extends NSObject {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(_class_NSDate, _sel_supportsSecureCoding);
}

Expand Down Expand Up @@ -1485,7 +1485,7 @@ class NSDictionary extends NSObject {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(_class_NSDictionary, _sel_supportsSecureCoding);
}

Expand Down Expand Up @@ -1709,7 +1709,7 @@ class NSError extends NSObject {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(_class_NSError, _sel_supportsSecureCoding);
}

Expand Down Expand Up @@ -1944,7 +1944,7 @@ class NSIndexSet extends NSObject {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(_class_NSIndexSet, _sel_supportsSecureCoding);
}

Expand Down Expand Up @@ -2627,7 +2627,7 @@ class NSMutableArray extends NSArray {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(
_class_NSMutableArray, _sel_supportsSecureCoding);
}
Expand Down Expand Up @@ -2860,7 +2860,7 @@ class NSMutableData extends NSData {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(
_class_NSMutableData, _sel_supportsSecureCoding);
}
Expand Down Expand Up @@ -3152,7 +3152,7 @@ class NSMutableDictionary extends NSDictionary {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(
_class_NSMutableDictionary, _sel_supportsSecureCoding);
}
Expand Down Expand Up @@ -3305,7 +3305,7 @@ class NSMutableIndexSet extends NSIndexSet {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(
_class_NSMutableIndexSet, _sel_supportsSecureCoding);
}
Expand Down Expand Up @@ -3540,7 +3540,7 @@ class NSMutableOrderedSet extends NSOrderedSet {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(
_class_NSMutableOrderedSet, _sel_supportsSecureCoding);
}
Expand Down Expand Up @@ -3793,7 +3793,7 @@ class NSMutableSet extends NSSet {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(_class_NSMutableSet, _sel_supportsSecureCoding);
}

Expand Down Expand Up @@ -4075,7 +4075,7 @@ class NSMutableString extends NSString {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(
_class_NSMutableString, _sel_supportsSecureCoding);
}
Expand Down Expand Up @@ -4493,7 +4493,7 @@ class NSNumber extends NSValue {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(_class_NSNumber, _sel_supportsSecureCoding);
}

Expand Down Expand Up @@ -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');
Expand All @@ -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<objc.ObjCSelector> aSelector) {
_objc_msgSend_1d9e4oe(
Expand All @@ -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 =
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -5328,7 +5339,7 @@ class NSOrderedSet extends NSObject {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(_class_NSOrderedSet, _sel_supportsSecureCoding);
}

Expand Down Expand Up @@ -5862,7 +5873,7 @@ class NSSet extends NSObject {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(_class_NSSet, _sel_supportsSecureCoding);
}

Expand Down Expand Up @@ -6426,7 +6437,7 @@ class NSString extends NSObject {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(_class_NSString, _sel_supportsSecureCoding);
}

Expand Down Expand Up @@ -7735,7 +7746,7 @@ class NSURL extends NSObject {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(_class_NSURL, _sel_supportsSecureCoding);
}

Expand Down Expand Up @@ -8335,7 +8346,7 @@ class NSValue extends NSObject {
}

/// supportsSecureCoding
static bool supportsSecureCoding() {
static bool getSupportsSecureCoding() {
return _objc_msgSend_91o635(_class_NSValue, _sel_supportsSecureCoding);
}

Expand Down

0 comments on commit b77e3ff

Please sign in to comment.