-
Notifications
You must be signed in to change notification settings - Fork 55
Separate getDartType and getUserType #623
Changes from all commits
51e4bc7
876fa36
0dc2797
724085d
276f30c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,15 @@ import 'writer.dart'; | |
/// Represents a pointer. | ||
class PointerType extends Type { | ||
final Type child; | ||
PointerType(this.child); | ||
|
||
PointerType._(this.child); | ||
|
||
factory PointerType(Type child) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we maybe have something more general to recognize "internal-dart-types" and return the "user-visible-dart-types"? For example, if we have something more general we could also recognize It should probably be a separate pass. Rather than making a choice point in factory constructors of types. // Parse the bindings according to config object provided.
final library = parse(config);
final libraryTransformed = transform(library);
// Generate file for the parsed bindings.
final gen = File(config.output);
libraryTransformed.generateFile(gen); Or maybe because we already make choices in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the moment we can handle all these cases, including your |
||
if (child == objCObjectType) { | ||
return ObjCObjectPointer(); | ||
} | ||
return PointerType._(child); | ||
} | ||
|
||
@override | ||
void addDependencies(Set<Binding> dependencies) { | ||
|
@@ -33,7 +41,7 @@ class PointerType extends Type { | |
/// Represents a constant array, which has a fixed size. | ||
class ConstantArray extends PointerType { | ||
final int length; | ||
ConstantArray(this.length, Type child) : super(child); | ||
ConstantArray(this.length, Type child) : super._(child); | ||
|
||
@override | ||
Type get baseArrayType => child.baseArrayType; | ||
|
@@ -50,7 +58,7 @@ class ConstantArray extends PointerType { | |
|
||
/// Represents an incomplete array, which has an unknown size. | ||
class IncompleteArray extends PointerType { | ||
IncompleteArray(Type child) : super(child); | ||
IncompleteArray(Type child) : super._(child); | ||
|
||
@override | ||
Type get baseArrayType => child.baseArrayType; | ||
|
@@ -61,3 +69,14 @@ class IncompleteArray extends PointerType { | |
@override | ||
String cacheKey() => '${child.cacheKey()}[]'; | ||
} | ||
|
||
/// A pointer to an NSObject. | ||
class ObjCObjectPointer extends PointerType { | ||
factory ObjCObjectPointer() => _inst; | ||
|
||
static final _inst = ObjCObjectPointer._(); | ||
ObjCObjectPointer._() : super._(objCObjectType); | ||
|
||
@override | ||
String getDartType(Writer w) => 'NSObject'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup!
This special case is the
instancetype
right? The one that returns the type of the object itself even in subclasses.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep