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

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
liamappelbe committed Sep 27, 2023
1 parent 2b9c728 commit 29cad88
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/src/code_generator/objc_built_in_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class $name implements ${w.ffiLibraryPrefix}.Finalizable {
String toString() {
final data = dataUsingEncoding_(
0x94000100 /* NSUTF16LittleEndianStringEncoding */);
return data.bytes.cast<${w.ffiPkgLibraryPrefix}.Utf16>().toDartString(
return data!.bytes.cast<${w.ffiPkgLibraryPrefix}.Utf16>().toDartString(
length: length);
}
''');
Expand Down
3 changes: 3 additions & 0 deletions lib/src/code_generator/objc_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ class $name extends ${superType?.name ?? '_ObjCWrapper'} {

String _getConvertedType(Type type, Writer w, String enclosingClass) {
if (type is ObjCInstanceType) return enclosingClass;
if (type is ObjCNullable && type.child is ObjCInstanceType) {
return '$enclosingClass?';
}
return type.getDartType(w);
}

Expand Down
11 changes: 7 additions & 4 deletions lib/src/code_generator/objc_nullable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ class ObjCNullable extends Type {
Type child;

ObjCNullable(this.child) {
assert(child is ObjCInterface ||
child is ObjCBlock ||
child is ObjCObjectPointer ||
child is ObjCInstanceType);
assert(isSupported(child));
}

static bool isSupported(Type type) =>
type is ObjCInterface ||
type is ObjCBlock ||
type is ObjCObjectPointer ||
type is ObjCInstanceType;

@override
void addDependencies(Set<Binding> dependencies) {
child.addDependencies(dependencies);
Expand Down
4 changes: 3 additions & 1 deletion lib/src/header_parser/type_extractor/extractor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ Type getCodeGenType(
);
final isNullable = clang.clang_Type_getNullability(cxtype) ==
clang_types.CXTypeNullabilityKind.CXTypeNullability_Nullable;
return isNullable ? ObjCNullable(innerType) : innerType;
return isNullable && ObjCNullable.isSupported(innerType)
? ObjCNullable(innerType)
: innerType;
default:
var typeSpellKey =
clang.clang_getTypeSpelling(cxtype).toStringAndDispose();
Expand Down

0 comments on commit 29cad88

Please sign in to comment.