diff --git a/src/Generator/Generators/C/CppMarshal.cs b/src/Generator/Generators/C/CppMarshal.cs index e0425e9f..d60a5d65 100644 --- a/src/Generator/Generators/C/CppMarshal.cs +++ b/src/Generator/Generators/C/CppMarshal.cs @@ -25,7 +25,7 @@ namespace CppSharp.Generators.Cpp TypeMap typeMap; if (Context.Context.TypeMaps.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling) { - typeMap.CppMarshalToManaged(Context); + typeMap.MarshalToManaged(Context); return false; } @@ -173,7 +173,7 @@ namespace CppSharp.Generators.Cpp typeMap.DoesMarshalling) { typeMap.Type = typedef; - typeMap.CppMarshalToManaged(Context); + typeMap.MarshalToManaged(Context); return typeMap.IsValueType; } @@ -193,7 +193,7 @@ namespace CppSharp.Generators.Cpp if (Context.Context.TypeMaps.FindTypeMap(template, out typeMap) && typeMap.DoesMarshalling) { typeMap.Type = template; - typeMap.CppMarshalToManaged(Context); + typeMap.MarshalToManaged(Context); return true; } @@ -341,7 +341,7 @@ namespace CppSharp.Generators.Cpp TypeMap typeMap; if (Context.Context.TypeMaps.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling) { - typeMap.CppMarshalToNative(Context); + typeMap.MarshalToNative(Context); return false; } @@ -478,7 +478,7 @@ namespace CppSharp.Generators.Cpp if (Context.Context.TypeMaps.FindTypeMap(decl.Type, out typeMap) && typeMap.DoesMarshalling) { - typeMap.CppMarshalToNative(Context); + typeMap.MarshalToNative(Context); return typeMap.IsValueType; } @@ -516,7 +516,7 @@ namespace CppSharp.Generators.Cpp if (Context.Context.TypeMaps.FindTypeMap(template, out typeMap) && typeMap.DoesMarshalling) { typeMap.Type = template; - typeMap.CppMarshalToNative(Context); + typeMap.MarshalToNative(Context); return true; } @@ -563,7 +563,7 @@ namespace CppSharp.Generators.Cpp if (Context.Context.TypeMaps.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling) { - typeMap.CppMarshalToNative(Context); + typeMap.MarshalToNative(Context); return; } diff --git a/src/Generator/Generators/C/CppTypePrinter.cs b/src/Generator/Generators/C/CppTypePrinter.cs index edfcdcd9..a8ea5caf 100644 --- a/src/Generator/Generators/C/CppTypePrinter.cs +++ b/src/Generator/Generators/C/CppTypePrinter.cs @@ -68,7 +68,7 @@ namespace CppSharp.Generators.C typePrinter.PushContext(ContextKind); typePrinter.PushScope(ScopeKind); - var typeName = typeMap.CppSignatureType(typePrinterContext).Visit(typePrinter); + var typeName = typeMap.SignatureType(typePrinterContext).Visit(typePrinter); result = new TypePrinterResult(typeName) { TypeMap = typeMap }; return true; diff --git a/src/Generator/Generators/NAPI/NAPIMarshal.cs b/src/Generator/Generators/NAPI/NAPIMarshal.cs index c0cf7008..3eb23b52 100644 --- a/src/Generator/Generators/NAPI/NAPIMarshal.cs +++ b/src/Generator/Generators/NAPI/NAPIMarshal.cs @@ -26,7 +26,7 @@ namespace CppSharp.Generators.NAPI TypeMap typeMap; if (Context.Context.TypeMaps.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling) { - typeMap.CppMarshalToManaged(Context); + typeMap.MarshalToManaged(Context); return false; } @@ -194,7 +194,7 @@ namespace CppSharp.Generators.NAPI typeMap.DoesMarshalling) { typeMap.Type = typedef; - typeMap.CppMarshalToManaged(Context); + typeMap.MarshalToManaged(Context); return typeMap.IsValueType; } @@ -214,7 +214,7 @@ namespace CppSharp.Generators.NAPI if (Context.Context.TypeMaps.FindTypeMap(template, out typeMap) && typeMap.DoesMarshalling) { typeMap.Type = template; - typeMap.CppMarshalToManaged(Context); + typeMap.MarshalToManaged(Context); return true; } @@ -343,7 +343,7 @@ namespace CppSharp.Generators.NAPI TypeMap typeMap; if (Context.Context.TypeMaps.FindTypeMap(type, out typeMap) && typeMap.DoesMarshalling) { - typeMap.CppMarshalToNative(Context); + typeMap.MarshalToNative(Context); return false; } @@ -591,7 +591,7 @@ namespace CppSharp.Generators.NAPI if (Context.Context.TypeMaps.FindTypeMap(decl.Type, out typeMap) && typeMap.DoesMarshalling) { - typeMap.CppMarshalToNative(Context); + typeMap.MarshalToNative(Context); return typeMap.IsValueType; } @@ -628,7 +628,7 @@ namespace CppSharp.Generators.NAPI if (Context.Context.TypeMaps.FindTypeMap(template, out typeMap) && typeMap.DoesMarshalling) { typeMap.Type = template; - typeMap.CppMarshalToNative(Context); + typeMap.MarshalToNative(Context); return true; } diff --git a/src/Generator/Types/TypeMap.cs b/src/Generator/Types/TypeMap.cs index 7834552c..282abe60 100644 --- a/src/Generator/Types/TypeMap.cs +++ b/src/Generator/Types/TypeMap.cs @@ -58,7 +58,7 @@ namespace CppSharp.Types { case var _ when ReferenceEquals(kind, GeneratorKind.C): case var _ when ReferenceEquals(kind, GeneratorKind.CPlusPlus): - return CppSignatureType(ctx); + return new CILType(typeof(object)); case var _ when ReferenceEquals(kind, GeneratorKind.CLI): return CLISignatureType(ctx); case var _ when ReferenceEquals(kind, GeneratorKind.CSharp): @@ -75,7 +75,7 @@ namespace CppSharp.Types { case var _ when ReferenceEquals(kind, GeneratorKind.C): case var _ when ReferenceEquals(kind, GeneratorKind.CPlusPlus): - CppMarshalToNative(ctx); + ctx.Return.Write(ctx.Parameter.Name); return; case var _ when ReferenceEquals(kind, GeneratorKind.CLI): CLIMarshalToNative(ctx); @@ -95,7 +95,7 @@ namespace CppSharp.Types { case var _ when ReferenceEquals(kind, GeneratorKind.C): case var _ when ReferenceEquals(kind, GeneratorKind.CPlusPlus): - CppMarshalToManaged(ctx); + ctx.Return.Write(ctx.ReturnVarName); return; case var _ when ReferenceEquals(kind, GeneratorKind.CLI): CLIMarshalToManaged(ctx); @@ -158,30 +158,6 @@ namespace CppSharp.Types } #endregion - - #region C++ backend - - public virtual Type CppSignatureType(TypePrinterContext ctx) - { - return new CILType(typeof(object)); - } - - public virtual void CppTypeReference(CLITypeReference collector, ASTRecord record) - { - throw new NotImplementedException(); - } - - public virtual void CppMarshalToNative(MarshalContext ctx) - { - ctx.Return.Write(ctx.Parameter.Name); - } - - public virtual void CppMarshalToManaged(MarshalContext ctx) - { - ctx.Return.Write(ctx.ReturnVarName); - } - - #endregion } public interface ITypeMapDatabase diff --git a/tests/dotnet/CLI/CLI.Gen.cs b/tests/dotnet/CLI/CLI.Gen.cs index 3ec8c1dc..5bd1a77c 100644 --- a/tests/dotnet/CLI/CLI.Gen.cs +++ b/tests/dotnet/CLI/CLI.Gen.cs @@ -29,13 +29,6 @@ namespace CppSharp.Tests return new CILType(typeof(string)); } - public override Type CppSignatureType(TypePrinterContext ctx) - { - var tagType = ctx.Type as TagType; - var typePrinter = new CppTypePrinter(Context); - return new CustomType(tagType.Declaration.Visit(typePrinter)); - } - public override void CLIMarshalToManaged(MarshalContext ctx) { ctx.Return.Write("clix::marshalString({0}.m_str)", ctx.ReturnVarName);