Browse Source

Improve formatting of TypeMapDatabase.cs.

pull/1187/merge
Joao Matos 7 years ago
parent
commit
33ce83ccff
  1. 7
      src/Generator/Types/TypeMapDatabase.cs

7
src/Generator/Types/TypeMapDatabase.cs

@ -52,6 +52,7 @@ namespace CppSharp.Types
public bool FindTypeMap(Type type, out TypeMap typeMap) public bool FindTypeMap(Type type, out TypeMap typeMap)
{ {
// Looks up the type in the cache map.
if (typeMaps.ContainsKey(type)) if (typeMaps.ContainsKey(type))
{ {
typeMap = typeMaps[type]; typeMap = typeMaps[type];
@ -65,6 +66,7 @@ namespace CppSharp.Types
if (specialization != null && if (specialization != null &&
FindTypeMap(specialization, out typeMap)) FindTypeMap(specialization, out typeMap))
return true; return true;
if (template.Template.TemplatedDecl != null) if (template.Template.TemplatedDecl != null)
{ {
if (FindTypeMap(template.Template.TemplatedDecl, if (FindTypeMap(template.Template.TemplatedDecl,
@ -73,14 +75,17 @@ namespace CppSharp.Types
typeMap.Type = type; typeMap.Type = type;
return true; return true;
} }
return false; return false;
} }
} }
Type desugared = type.Desugar(); Type desugared = type.Desugar();
desugared = (desugared.GetFinalPointee() ?? desugared).Desugar(); desugared = (desugared.GetFinalPointee() ?? desugared).Desugar();
bool printExtra = desugared.IsPrimitiveType() || bool printExtra = desugared.IsPrimitiveType() ||
(desugared.GetFinalPointee() ?? desugared).Desugar().IsPrimitiveType(); (desugared.GetFinalPointee() ?? desugared).Desugar().IsPrimitiveType();
var typePrinter = new CppTypePrinter var typePrinter = new CppTypePrinter
{ {
PrintTypeQualifiers = printExtra, PrintTypeQualifiers = printExtra,
@ -89,6 +94,7 @@ namespace CppSharp.Types
}; };
foreach (var resolveTypeDefs in new[] { true, false }) foreach (var resolveTypeDefs in new[] { true, false })
{
foreach (var typePrintScopeKind in foreach (var typePrintScopeKind in
new[] { TypePrintScopeKind.Local, TypePrintScopeKind.Qualified }) new[] { TypePrintScopeKind.Local, TypePrintScopeKind.Qualified })
{ {
@ -101,6 +107,7 @@ namespace CppSharp.Types
return true; return true;
} }
} }
}
typeMap = null; typeMap = null;
var typedef = type as TypedefType; var typedef = type as TypedefType;

Loading…
Cancel
Save