@ -16,6 +16,7 @@ namespace CppSharp.Generators.CSharp
public class CSharpTypePrinterContext : TypePrinterContext
public class CSharpTypePrinterContext : TypePrinterContext
{
{
public CSharpTypePrinterContextKind CSharpKind ;
public CSharpTypePrinterContextKind CSharpKind ;
public QualifiedType FullType ;
public CSharpTypePrinterContext ( )
public CSharpTypePrinterContext ( )
{
{
@ -214,14 +215,12 @@ namespace CppSharp.Generators.CSharp
if ( TypeMapDatabase . FindTypeMap ( decl , out typeMap ) )
if ( TypeMapDatabase . FindTypeMap ( decl , out typeMap ) )
{
{
typeMap . Type = typedef ;
typeMap . Type = typedef ;
var ctx = new CSharpTypePrinterContext
Context . CSharpKind = ContextKind ;
{
Context . Type = typedef ;
CSharpKind = ContextKind ,
Type = typedef
} ;
return new CSharpTypePrinterResult ( )
return new CSharpTypePrinterResult ( )
{
{
Type = typeMap . CSharpSignature ( ctx ) ,
Type = typeMap . CSharpSignature ( Context ) ,
TypeMap = typeMap
TypeMap = typeMap
} ;
} ;
}
}
@ -255,6 +254,7 @@ namespace CppSharp.Generators.CSharp
typeMap . Type = template ;
typeMap . Type = template ;
Context . Type = template ;
Context . Type = template ;
Context . CSharpKind = ContextKind ;
Context . CSharpKind = ContextKind ;
return new CSharpTypePrinterResult ( )
return new CSharpTypePrinterResult ( )
{
{
Type = GetCSharpSignature ( typeMap ) ,
Type = GetCSharpSignature ( typeMap ) ,
@ -474,4 +474,32 @@ namespace CppSharp.Generators.CSharp
return type . Visit ( this ) . Type ;
return type . Visit ( this ) . Type ;
}
}
}
}
public static class CSharpTypePrinterExtensions
{
public static CSharpTypePrinterResult CSharpType ( this QualifiedType type ,
CSharpTypePrinter printer )
{
printer . Context . FullType = type ;
return type . Visit ( printer ) ;
}
public static CSharpTypePrinterResult CSharpType ( this Type type ,
CSharpTypePrinter printer )
{
return CSharpType ( new QualifiedType ( type ) , printer ) ;
}
public static CSharpTypePrinterResult CSharpType ( this Declaration decl ,
CSharpTypePrinter printer )
{
if ( decl is ITypedDecl )
{
var type = ( decl as ITypedDecl ) . QualifiedType ;
printer . Context . FullType = type ;
}
return decl . Visit ( printer ) ;
}
}
}
}