findTypeDef method
TypeDef?
findTypeDef(
- String name, {
- PreferredArchitecture preferredArchitecture = PreferredArchitecture.x64,
Return the first typedef object matching the given name.
Returns null if no typedefs match the name.
Implementation
TypeDef? findTypeDef(String name,
{PreferredArchitecture preferredArchitecture =
PreferredArchitecture.x64}) {
final matchingTypeDefs = _typedefsByName[name];
if (matchingTypeDefs == null) return null;
if (matchingTypeDefs.length == 1) return matchingTypeDefs.first;
// More than one typedef, so we find the one that matches the preferred
// architecture.
for (final typeDef in matchingTypeDefs) {
final supportedArch = typeDef.supportedArchitectures;
if (preferredArchitecture == PreferredArchitecture.x64 &&
supportedArch.x64) return typeDef;
if (preferredArchitecture == PreferredArchitecture.arm64 &&
supportedArch.arm64) return typeDef;
if (preferredArchitecture == PreferredArchitecture.x86 &&
supportedArch.x86) return typeDef;
}
return null;
}