Browse Source

Added a way to find a type maps from a given type.

pull/1/head
triton 13 years ago
parent
commit
f8c16c0ca7
  1. 19
      src/Generator/Types/TypeMap.cs

19
src/Generator/Types/TypeMap.cs

@ -64,6 +64,7 @@ namespace Cxxi.Types
public interface ITypeMapDatabase public interface ITypeMapDatabase
{ {
bool FindTypeMap(Declaration decl, out TypeMap typeMap); bool FindTypeMap(Declaration decl, out TypeMap typeMap);
bool FindTypeMap(Type type, out TypeMap typeMap);
bool FindTypeMap(string name, out TypeMap typeMap); bool FindTypeMap(string name, out TypeMap typeMap);
} }
@ -107,6 +108,24 @@ namespace Cxxi.Types
return FindTypeMap(decl.QualifiedOriginalName, out typeMap); return FindTypeMap(decl.QualifiedOriginalName, out typeMap);
} }
public bool FindTypeMap(Type type, out TypeMap typeMap)
{
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);
if (FindTypeMap(output, out typeMap))
return true;
return false;
}
public bool FindTypeMap(string name, out TypeMap typeMap) public bool FindTypeMap(string name, out TypeMap typeMap)
{ {
System.Type type; System.Type type;

Loading…
Cancel
Save