mirror of https://github.com/mono/CppSharp.git
6 changed files with 138 additions and 10 deletions
@ -0,0 +1,57 @@ |
|||||||
|
using CppSharp.AST.Extensions; |
||||||
|
using CppSharp.Generators; |
||||||
|
using CppSharp.Generators.CLI; |
||||||
|
using CppSharp.Generators.CSharp; |
||||||
|
using CppSharp.Types; |
||||||
|
|
||||||
|
namespace TypeMaps.Gen |
||||||
|
{ |
||||||
|
[TypeMap("QList")] |
||||||
|
public class QList : TypeMap |
||||||
|
{ |
||||||
|
public override bool DoesMarshalling |
||||||
|
{ |
||||||
|
get { return false; } |
||||||
|
} |
||||||
|
|
||||||
|
public override string CLISignature(CLITypePrinterContext ctx) |
||||||
|
{ |
||||||
|
return "TypeMaps::QList^"; |
||||||
|
} |
||||||
|
|
||||||
|
public override void CLIMarshalToManaged(MarshalContext ctx) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public override void CLIMarshalToNative(MarshalContext ctx) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public override string CSharpSignature(CSharpTypePrinterContext ctx) |
||||||
|
{ |
||||||
|
if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native) |
||||||
|
{ |
||||||
|
if (Type.IsAddress()) |
||||||
|
{ |
||||||
|
return "QList.Internal*"; |
||||||
|
} |
||||||
|
return "QList.Internal"; |
||||||
|
} |
||||||
|
return "QList"; |
||||||
|
} |
||||||
|
|
||||||
|
public override void CSharpMarshalToManaged(MarshalContext ctx) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public override void CSharpMarshalToNative(MarshalContext ctx) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public override void CSharpMarshalCopyCtorToManaged(MarshalContext ctx) |
||||||
|
{ |
||||||
|
ctx.SupportBefore.WriteLine("var __instance = new {0}.Internal();", ctx.ReturnType); |
||||||
|
ctx.SupportBefore.WriteLine("__instance.i = {0}.i;", ctx.ReturnVarName); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
#include "TypeMaps.h" |
||||||
|
#include <string.h> |
||||||
|
|
||||||
|
QList::QList() : i(5) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
QList HasQList::getList() |
||||||
|
{ |
||||||
|
return list; |
||||||
|
} |
@ -0,0 +1,40 @@ |
|||||||
|
using System.Linq; |
||||||
|
using CppSharp.AST; |
||||||
|
using CppSharp.Generators; |
||||||
|
using CppSharp.Utils; |
||||||
|
|
||||||
|
namespace CppSharp.Tests |
||||||
|
{ |
||||||
|
public class TypeMaps : GeneratorTest |
||||||
|
{ |
||||||
|
public TypeMaps(GeneratorKind kind) |
||||||
|
: base("TypeMaps", kind) |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public override void SetupPasses(Driver driver) |
||||||
|
{ |
||||||
|
if (driver.Options.IsCSharpGenerator) |
||||||
|
driver.Options.GenerateAbstractImpls = true; |
||||||
|
driver.Options.GenerateVirtualTables = true; |
||||||
|
driver.Options.GenerateCopyConstructors = true; |
||||||
|
driver.Options.MarshalCharAsManagedChar = true; |
||||||
|
driver.Options.GenerateProperties = true; |
||||||
|
driver.Options.GenerateConversionOperators = true; |
||||||
|
} |
||||||
|
|
||||||
|
public override void Preprocess(Driver driver, ASTContext ctx) |
||||||
|
{ |
||||||
|
ctx.SetClassAsValueType("HasQList"); |
||||||
|
ctx.FindCompleteClass("QList").Constructors.First(c => c.IsCopyConstructor).GenerationKind = GenerationKind.None; |
||||||
|
ctx.IgnoreClassWithName("IgnoredType"); |
||||||
|
} |
||||||
|
|
||||||
|
public static void Main(string[] args) |
||||||
|
{ |
||||||
|
ConsoleDriver.Run(new TypeMaps(GeneratorKind.CLI)); |
||||||
|
ConsoleDriver.Run(new TypeMaps(GeneratorKind.CSharp)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
#include "../Tests.h" |
||||||
|
|
||||||
|
class DLL_API QList |
||||||
|
{ |
||||||
|
public: |
||||||
|
QList(); |
||||||
|
int i; |
||||||
|
}; |
||||||
|
|
||||||
|
class DLL_API HasQList |
||||||
|
{ |
||||||
|
public: |
||||||
|
QList getList(); |
||||||
|
private: |
||||||
|
QList list; |
||||||
|
}; |
Loading…
Reference in new issue