Browse Source

Extract the MarshalContext and MarshalPrinter classes into their own file.

pull/1/head
triton 12 years ago
parent
commit
a9392afa50
  1. 36
      src/Generator/Generators/CLI/CLIMarshal.cs
  2. 38
      src/Generator/Generators/Marshal.cs
  3. 26
      src/Generator/Types/TypeMap.cs

36
src/Generator/Generators/CLI/CLIMarshal.cs

@ -4,42 +4,6 @@ using Cxxi.Types;
namespace Cxxi.Generators.CLI namespace Cxxi.Generators.CLI
{ {
public abstract class MarshalPrinter : ITypeVisitor<bool>, IDeclVisitor<bool>
{
public MarshalContext Context { get; private set; }
protected MarshalPrinter(MarshalContext ctx)
{
Context = ctx;
}
public abstract bool VisitTagType(TagType tag, TypeQualifiers quals);
public abstract bool VisitArrayType(ArrayType array, TypeQualifiers quals);
public abstract bool VisitFunctionType(FunctionType function, TypeQualifiers quals);
public abstract bool VisitPointerType(PointerType pointer, TypeQualifiers quals);
public abstract bool VisitMemberPointerType(MemberPointerType member, TypeQualifiers quals);
public abstract bool VisitBuiltinType(BuiltinType builtin, TypeQualifiers quals);
public abstract bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals);
public abstract bool VisitTemplateSpecializationType(TemplateSpecializationType template, TypeQualifiers quals);
public abstract bool VisitPrimitiveType(PrimitiveType type, TypeQualifiers quals);
public abstract bool VisitDeclaration(Declaration decl, TypeQualifiers quals);
public abstract bool VisitTemplateParameterType(TemplateParameterType param, TypeQualifiers quals);
public abstract bool VisitDeclaration(Declaration decl);
public abstract bool VisitClassDecl(Class @class);
public abstract bool VisitFieldDecl(Field field);
public abstract bool VisitFunctionDecl(Function function);
public abstract bool VisitMethodDecl(Method method);
public abstract bool VisitParameterDecl(Parameter parameter);
public abstract bool VisitTypedefDecl(TypedefDecl typedef);
public abstract bool VisitEnumDecl(Enumeration @enum);
public abstract bool VisitVariableDecl(Variable variable);
public abstract bool VisitClassTemplateDecl(ClassTemplate template);
public abstract bool VisitFunctionTemplateDecl(FunctionTemplate template);
public abstract bool VisitMacroDefinition(MacroDefinition macro);
public abstract bool VisitNamespace(Namespace @namespace);
public abstract bool VisitEvent(Event @event);
}
public class CLIMarshalNativeToManagedPrinter : MarshalPrinter public class CLIMarshalNativeToManagedPrinter : MarshalPrinter
{ {

38
src/Generator/Generators/Marshal.cs

@ -0,0 +1,38 @@
namespace Cxxi.Generators
{
public class MarshalContext
{
public MarshalContext(Driver driver)
{
Driver = driver;
SupportBefore = new TextGenerator();
Return = new TextGenerator();
}
public Driver Driver { get; private set; }
public MarshalPrinter MarshalToManaged;
public MarshalPrinter MarshalToNative;
public TextGenerator SupportBefore { get; private set; }
public TextGenerator Return { get; private set; }
public string ReturnVarName { get; set; }
public Type ReturnType { get; set; }
public string ArgName { get; set; }
public Parameter Parameter { get; set; }
public int ParameterIndex { get; set; }
public Function Function { get; set; }
}
public abstract class MarshalPrinter : AstVisitor
{
public MarshalContext Context { get; private set; }
protected MarshalPrinter(MarshalContext ctx)
{
Context = ctx;
}
}
}

26
src/Generator/Types/TypeMap.cs

@ -5,32 +5,6 @@ using Cxxi.Generators.CLI;
namespace Cxxi.Types namespace Cxxi.Types
{ {
public class MarshalContext
{
public MarshalContext(Driver driver)
{
Driver = driver;
SupportBefore = new TextGenerator();
Return = new TextGenerator();
}
public Driver Driver { get; private set; }
public CLIMarshalNativeToManagedPrinter MarshalToManaged;
public CLIMarshalManagedToNativePrinter MarshalToNative;
public TextGenerator SupportBefore { get; private set; }
public TextGenerator Return { get; private set; }
public string ReturnVarName { get; set; }
public Type ReturnType { get; set; }
public string ArgName { get; set; }
public Parameter Parameter { get; set; }
public int ParameterIndex { get; set; }
public Function Function { get; set; }
}
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class TypeMapAttribute : Attribute public class TypeMapAttribute : Attribute
{ {

Loading…
Cancel
Save