|
|
|
@ -11,6 +11,63 @@ using Type = CppSharp.AST.Type;
@@ -11,6 +11,63 @@ using Type = CppSharp.AST.Type;
|
|
|
|
|
|
|
|
|
|
namespace CppSharp.Tests |
|
|
|
|
{ |
|
|
|
|
public class CSharpTestsGenerator : GeneratorTest |
|
|
|
|
{ |
|
|
|
|
public CSharpTestsGenerator(GeneratorKind kind) |
|
|
|
|
: base("CSharp", kind) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override void SetupPasses(Driver driver) |
|
|
|
|
{ |
|
|
|
|
driver.Context.TranslationUnitPasses.AddPass(new TestAttributesPass()); |
|
|
|
|
driver.Options.MarshalCharAsManagedChar = true; |
|
|
|
|
driver.Options.GenerateDefaultValuesForArguments = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override void Preprocess(Driver driver, ASTContext ctx) |
|
|
|
|
{ |
|
|
|
|
ctx.SetClassAsValueType("TestCopyConstructorVal"); |
|
|
|
|
ctx.SetClassAsValueType("QGenericArgument"); |
|
|
|
|
ctx.SetClassAsValueType("StructWithPrivateFields"); |
|
|
|
|
ctx.SetClassAsValueType("QPoint"); |
|
|
|
|
ctx.SetClassAsValueType("QSize"); |
|
|
|
|
ctx.SetClassAsValueType("QRect"); |
|
|
|
|
|
|
|
|
|
ctx.IgnoreClassWithName("IgnoredTypeInheritingNonIgnoredWithNoEmptyCtor"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override void Postprocess(Driver driver, ASTContext ctx) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void Main(string[] args) |
|
|
|
|
{ |
|
|
|
|
ConsoleDriver.Run(new CSharpTestsGenerator(GeneratorKind.CSharp)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public class TestAttributesPass : TranslationUnitPass |
|
|
|
|
{ |
|
|
|
|
public override bool VisitFunctionDecl(Function function) |
|
|
|
|
{ |
|
|
|
|
if (AlreadyVisited(function) || function.Name != "obsolete") |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
var attribute = new Attribute |
|
|
|
|
{ |
|
|
|
|
Type = typeof(ObsoleteAttribute), |
|
|
|
|
Value = string.Format("\"{0} is obsolete.\"", function.Name) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function.Attributes.Add(attribute); |
|
|
|
|
|
|
|
|
|
return base.VisitFunctionDecl(function); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#region Type Maps
|
|
|
|
|
|
|
|
|
|
[TypeMap("QFlags")] |
|
|
|
|
public class QFlags : TypeMap |
|
|
|
|
{ |
|
|
|
@ -151,59 +208,6 @@ namespace CppSharp.Tests
@@ -151,59 +208,6 @@ namespace CppSharp.Tests
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public class TestAttributesPass : TranslationUnitPass |
|
|
|
|
{ |
|
|
|
|
public override bool VisitFunctionDecl(Function function) |
|
|
|
|
{ |
|
|
|
|
if (AlreadyVisited(function) || function.Name != "obsolete") |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
var attribute = new Attribute |
|
|
|
|
{ |
|
|
|
|
Type = typeof(ObsoleteAttribute), |
|
|
|
|
Value = string.Format("\"{0} is obsolete.\"", function.Name) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function.Attributes.Add(attribute); |
|
|
|
|
|
|
|
|
|
return base.VisitFunctionDecl(function); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public class CSharpTestsGenerator : GeneratorTest |
|
|
|
|
{ |
|
|
|
|
public CSharpTestsGenerator(GeneratorKind kind) |
|
|
|
|
: base("CSharp", kind) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override void SetupPasses(Driver driver) |
|
|
|
|
{ |
|
|
|
|
driver.Context.TranslationUnitPasses.AddPass(new TestAttributesPass()); |
|
|
|
|
driver.Options.MarshalCharAsManagedChar = true; |
|
|
|
|
driver.Options.GenerateDefaultValuesForArguments = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override void Preprocess(Driver driver, ASTContext ctx) |
|
|
|
|
{ |
|
|
|
|
ctx.SetClassAsValueType("TestCopyConstructorVal"); |
|
|
|
|
ctx.SetClassAsValueType("QGenericArgument"); |
|
|
|
|
ctx.SetClassAsValueType("StructWithPrivateFields"); |
|
|
|
|
ctx.SetClassAsValueType("QPoint"); |
|
|
|
|
ctx.SetClassAsValueType("QSize"); |
|
|
|
|
ctx.SetClassAsValueType("QRect"); |
|
|
|
|
|
|
|
|
|
ctx.IgnoreClassWithName("IgnoredTypeInheritingNonIgnoredWithNoEmptyCtor"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override void Postprocess(Driver driver, ASTContext ctx) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void Main(string[] args) |
|
|
|
|
{ |
|
|
|
|
ConsoleDriver.Run(new CSharpTestsGenerator(GeneratorKind.CSharp)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endregion
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|