Skip to content

Commit 648b1fd

Browse files
committed
Add generic type map handling methods for later refactoring of generators.
1 parent 1ad118c commit 648b1fd

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

src/Generator/Types/TypeMap.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,57 @@ public class TypeMap
5050
/// </summary>
5151
public virtual bool DoesMarshalling => true;
5252

53+
public virtual Type SignatureType(GeneratorKind kind, TypePrinterContext ctx)
54+
{
55+
switch (kind)
56+
{
57+
case GeneratorKind.CPlusPlus:
58+
return CppSignatureType(ctx);
59+
case GeneratorKind.CLI:
60+
return CLISignatureType(ctx);
61+
case GeneratorKind.CSharp:
62+
return CSharpSignatureType(ctx);
63+
default:
64+
throw new System.NotImplementedException();
65+
}
66+
}
67+
68+
public virtual void MarshalToNative(GeneratorKind kind, MarshalContext ctx)
69+
{
70+
switch (kind)
71+
{
72+
case GeneratorKind.CPlusPlus:
73+
CppMarshalToNative(ctx);
74+
return;
75+
case GeneratorKind.CLI:
76+
CLIMarshalToNative(ctx);
77+
return;
78+
case GeneratorKind.CSharp:
79+
CSharpMarshalToNative(ctx as CSharpMarshalContext);
80+
return;
81+
default:
82+
throw new System.NotImplementedException();
83+
}
84+
}
85+
86+
public virtual void MarshalToManaged(GeneratorKind kind, MarshalContext ctx)
87+
{
88+
switch (kind)
89+
{
90+
case GeneratorKind.CPlusPlus:
91+
CppMarshalToManaged(ctx);
92+
return;
93+
case GeneratorKind.CLI:
94+
CLIMarshalToManaged(ctx);
95+
return;
96+
case GeneratorKind.CSharp:
97+
CSharpMarshalToManaged(ctx as CSharpMarshalContext);
98+
return;
99+
default:
100+
throw new System.NotImplementedException();
101+
}
102+
}
103+
53104
#region C# backend
54105

55106
public virtual Type CSharpSignatureType(TypePrinterContext ctx)

0 commit comments

Comments
 (0)