Browse Source

TypeMap: prepare refactoring into a modular design

pull/1802/head
Deadlocklogic 3 years ago
parent
commit
6268b1c3c8
  1. 14
      src/Generator/Generators/QuickJS/QuickJSMarshal.cs
  2. 9
      src/Generator/Types/TypeMap.cs

14
src/Generator/Generators/QuickJS/QuickJSMarshal.cs

@ -25,7 +25,7 @@ namespace CppSharp.Generators.Cpp @@ -25,7 +25,7 @@ namespace CppSharp.Generators.Cpp
TypeMap typeMap;
if (Context.Context.TypeMaps.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling)
{
typeMap.MarshalToManaged(GeneratorKind.QuickJS, Context);
typeMap.MarshalToManaged(Context);
return false;
}
@ -210,7 +210,7 @@ namespace CppSharp.Generators.Cpp @@ -210,7 +210,7 @@ namespace CppSharp.Generators.Cpp
typeMap.DoesMarshalling)
{
typeMap.Type = typedef;
typeMap.MarshalToManaged(GeneratorKind.QuickJS, Context);
typeMap.MarshalToManaged(Context);
return typeMap.IsValueType;
}
@ -232,7 +232,7 @@ namespace CppSharp.Generators.Cpp @@ -232,7 +232,7 @@ namespace CppSharp.Generators.Cpp
if (Context.Context.TypeMaps.FindTypeMap(template, out typeMap) && typeMap.DoesMarshalling)
{
typeMap.Type = template;
typeMap.MarshalToManaged(GeneratorKind.QuickJS, Context);
typeMap.MarshalToManaged(Context);
return true;
}
@ -385,7 +385,7 @@ namespace CppSharp.Generators.Cpp @@ -385,7 +385,7 @@ namespace CppSharp.Generators.Cpp
TypeMap typeMap;
if (Context.Context.TypeMaps.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling)
{
typeMap.MarshalToNative(GeneratorKind.QuickJS, Context);
typeMap.MarshalToNative(Context);
return false;
}
@ -583,7 +583,7 @@ namespace CppSharp.Generators.Cpp @@ -583,7 +583,7 @@ namespace CppSharp.Generators.Cpp
if (Context.Context.TypeMaps.FindTypeMap(decl.Type, out typeMap) &&
typeMap.DoesMarshalling)
{
typeMap.MarshalToNative(GeneratorKind.QuickJS, Context);
typeMap.MarshalToNative(Context);
return typeMap.IsValueType;
}
@ -625,7 +625,7 @@ namespace CppSharp.Generators.Cpp @@ -625,7 +625,7 @@ namespace CppSharp.Generators.Cpp
if (Context.Context.TypeMaps.FindTypeMap(template, out typeMap) && typeMap.DoesMarshalling)
{
typeMap.Type = template;
typeMap.MarshalToNative(GeneratorKind.QuickJS, Context);
typeMap.MarshalToNative(Context);
return true;
}
@ -672,7 +672,7 @@ namespace CppSharp.Generators.Cpp @@ -672,7 +672,7 @@ namespace CppSharp.Generators.Cpp
if (Context.Context.TypeMaps.FindTypeMap(type, out typeMap) &&
typeMap.DoesMarshalling)
{
typeMap.MarshalToNative(GeneratorKind.QuickJS, Context);
typeMap.MarshalToNative(Context);
return;
}

9
src/Generator/Types/TypeMap.cs

@ -51,8 +51,9 @@ namespace CppSharp.Types @@ -51,8 +51,9 @@ namespace CppSharp.Types
/// </summary>
public virtual bool DoesMarshalling => true;
public virtual Type SignatureType(GeneratorKind kind, TypePrinterContext ctx)
public virtual Type SignatureType(TypePrinterContext ctx, GeneratorKind kind = null)
{
kind ??= Context.Options.GeneratorKind;
switch (kind)
{
case var _ when ReferenceEquals(kind, GeneratorKind.C):
@ -67,8 +68,9 @@ namespace CppSharp.Types @@ -67,8 +68,9 @@ namespace CppSharp.Types
}
}
public virtual void MarshalToNative(GeneratorKind kind, MarshalContext ctx)
public virtual void MarshalToNative(MarshalContext ctx, GeneratorKind kind = null)
{
kind ??= Context.Options.GeneratorKind;
switch (kind)
{
case var _ when ReferenceEquals(kind, GeneratorKind.C):
@ -86,8 +88,9 @@ namespace CppSharp.Types @@ -86,8 +88,9 @@ namespace CppSharp.Types
}
}
public virtual void MarshalToManaged(GeneratorKind kind, MarshalContext ctx)
public virtual void MarshalToManaged(MarshalContext ctx, GeneratorKind kind = null)
{
kind ??= Context.Options.GeneratorKind;
switch (kind)
{
case var _ when ReferenceEquals(kind, GeneratorKind.C):

Loading…
Cancel
Save