@ -52,9 +52,7 @@ namespace CppSharp.Generators.CSharp
public class CSharpTypePrinter : ITypePrinter < CSharpTypePrinterResult > ,
public class CSharpTypePrinter : ITypePrinter < CSharpTypePrinterResult > ,
IDeclVisitor < CSharpTypePrinterResult >
IDeclVisitor < CSharpTypePrinterResult >
{
{
public ASTContext AstContext { get ; set ; }
private Driver driver ;
private readonly ITypeMapDatabase TypeMapDatabase ;
private readonly DriverOptions driverOptions ;
private readonly Stack < CSharpTypePrinterContextKind > contexts ;
private readonly Stack < CSharpTypePrinterContextKind > contexts ;
@ -65,11 +63,9 @@ namespace CppSharp.Generators.CSharp
public CSharpTypePrinterContext Context ;
public CSharpTypePrinterContext Context ;
public CSharpTypePrinter ( ITypeMapDatabase database , DriverOptions driverOptions , ASTContext context )
public CSharpTypePrinter ( Driver driver )
{
{
TypeMapDatabase = database ;
this . driver = driver ;
this . driverOptions = driverOptions ;
AstContext = context ;
contexts = new Stack < CSharpTypePrinterContextKind > ( ) ;
contexts = new Stack < CSharpTypePrinterContextKind > ( ) ;
PushContext ( CSharpTypePrinterContextKind . Managed ) ;
PushContext ( CSharpTypePrinterContextKind . Managed ) ;
@ -93,7 +89,7 @@ namespace CppSharp.Generators.CSharp
return string . Empty ;
return string . Empty ;
TypeMap typeMap ;
TypeMap typeMap ;
if ( TypeMap Database . FindTypeMap ( tag . Declaration , out typeMap ) )
if ( this . driver . TypeDatabase . FindTypeMap ( tag . Declaration , out typeMap ) )
{
{
typeMap . Type = tag ;
typeMap . Type = tag ;
Context . CSharpKind = ContextKind ;
Context . CSharpKind = ContextKind ;
@ -269,7 +265,7 @@ namespace CppSharp.Generators.CSharp
var decl = typedef . Declaration ;
var decl = typedef . Declaration ;
TypeMap typeMap ;
TypeMap typeMap ;
if ( TypeMap Database . FindTypeMap ( decl , out typeMap ) )
if ( this . driver . TypeDatabase . FindTypeMap ( decl , out typeMap ) )
{
{
typeMap . Type = typedef ;
typeMap . Type = typedef ;
Context . CSharpKind = ContextKind ;
Context . CSharpKind = ContextKind ;
@ -314,7 +310,7 @@ namespace CppSharp.Generators.CSharp
var decl = template . Template . TemplatedDecl ;
var decl = template . Template . TemplatedDecl ;
TypeMap typeMap = null ;
TypeMap typeMap = null ;
if ( TypeMap Database . FindTypeMap ( template , out typeMap ) )
if ( this . driver . TypeDatabase . FindTypeMap ( template , out typeMap ) )
{
{
typeMap . Declaration = decl ;
typeMap . Declaration = decl ;
typeMap . Type = template ;
typeMap . Type = template ;
@ -386,7 +382,7 @@ namespace CppSharp.Generators.CSharp
case PrimitiveType . Void : return "void" ;
case PrimitiveType . Void : return "void" ;
case PrimitiveType . Char16 :
case PrimitiveType . Char16 :
case PrimitiveType . WideChar : return "char" ;
case PrimitiveType . WideChar : return "char" ;
case PrimitiveType . Char : return driverOptions . MarshalCharAsManagedChar ? "char" : "sbyte" ;
case PrimitiveType . Char : return this . driver . Options . MarshalCharAsManagedChar ? "char" : "sbyte" ;
case PrimitiveType . UChar : return "byte" ;
case PrimitiveType . UChar : return "byte" ;
case PrimitiveType . Short : return "short" ;
case PrimitiveType . Short : return "short" ;
case PrimitiveType . UShort : return "ushort" ;
case PrimitiveType . UShort : return "ushort" ;