in lib/src/code_generator/type.dart [293:335]
String getDartType(Writer w) {
switch (broadType) {
case BroadType.NativeType:
return _primitives[nativeType!]!.dart;
case BroadType.Pointer:
return '${w.ffiLibraryPrefix}.Pointer<${child!.getCType(w)}>';
case BroadType.Compound:
return compound!.name;
case BroadType.Enum:
return _primitives[enumNativeType]!.dart;
case BroadType.NativeFunction:
return '${w.ffiLibraryPrefix}.NativeFunction<${nativeFunc!.type.getDartType(w)}>';
case BroadType
.IncompleteArray: // Array parameters are treated as Pointers in C.
return '${w.ffiLibraryPrefix}.Pointer<${child!.getCType(w)}>';
case BroadType
.ConstantArray: // Array parameters are treated as Pointers in C.
return '${w.ffiLibraryPrefix}.Pointer<${child!.getCType(w)}>';
case BroadType.Boolean: // Booleans are treated as uint8.
return _primitives[SupportedNativeType.Uint8]!.dart;
case BroadType.Handle:
return 'Object';
case BroadType.FunctionType:
return functionType!.getDartType(w);
case BroadType.ImportedType:
if (importedType!.cType == importedType!.dartType) {
return getCType(w);
} else {
return importedType!.dartType;
}
case BroadType.Typealias:
// Typealias cannot be used by name in Dart types unless both the C and
// Dart type of the underlying types are same.
if (typealias!.type.sameDartAndCType(w)) {
return typealias!.name;
} else {
return typealias!.type.getDartType(w);
}
case BroadType.Unimplemented:
throw UnimplementedError(
'dart type unknown for ${broadType.toString()}');
}
}