Browse Source

Reworked type map finding to take typedefs in account by desugaring the type one layer at a time and searching for that typemap.

pull/34/merge
triton 12 years ago
parent
commit
362fff872d
  1. 31
      src/Generator/Types/TypeMap.cs

31
src/Generator/Types/TypeMap.cs

@ -132,20 +132,31 @@ namespace CppSharp.Types @@ -132,20 +132,31 @@ namespace CppSharp.Types
public bool FindTypeMap(Type type, out TypeMap typeMap)
{
var typePrinter = new CppTypePrinter(this);
var output = type.Visit(typePrinter);
typeMap = null;
if (FindTypeMap(output, out typeMap))
return true;
while (true)
{
var typePrinter = new CppTypePrinter(this);
var output = type.Visit(typePrinter);
if (FindTypeMap(output, out typeMap))
return true;
// Try to strip the global scope resolution operator.
if (output.StartsWith("::"))
output = output.Substring(2);
// Try to strip the global scope resolution operator.
if (output.StartsWith("::"))
output = output.Substring(2);
if (FindTypeMap(output, out typeMap))
return true;
if (FindTypeMap(output, out typeMap))
return true;
var desugaredType = type.Desugar();
if (desugaredType == type)
return false;
return false;
type = desugaredType;
}
return true;
}
public bool FindTypeMap(string name, out TypeMap typeMap)

Loading…
Cancel
Save