зеркало из https://github.com/mono/CppSharp.git
Re-order declarations in CSharp test generator.
This commit is contained in:
Родитель
baa30f0aa2
Коммит
c4edb58881
|
@ -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
|
||||
{
|
||||
|
@ -59,7 +116,7 @@ namespace CppSharp.Tests
|
|||
if (templateSpecializationType != null)
|
||||
classTemplateSpecialization = templateSpecializationType.GetClassTemplateSpecialization();
|
||||
else
|
||||
classTemplateSpecialization = (ClassTemplateSpecialization) ((TagType) type).Declaration;
|
||||
classTemplateSpecialization = (ClassTemplateSpecialization)((TagType)type).Declaration;
|
||||
return classTemplateSpecialization.Arguments[0].Type.Type;
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +157,7 @@ namespace CppSharp.Tests
|
|||
{
|
||||
get
|
||||
{
|
||||
var type = (TemplateSpecializationType) Type;
|
||||
var type = (TemplateSpecializationType)Type;
|
||||
var pointeeType = type.Arguments[0].Type;
|
||||
var checker = new TypeIgnoreChecker(TypeMapDatabase);
|
||||
pointeeType.Visit(checker);
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче