From a9392afa500379b056f579e651ff2a8d7884a868 Mon Sep 17 00:00:00 2001 From: triton Date: Thu, 4 Apr 2013 14:47:20 +0100 Subject: [PATCH] Extract the MarshalContext and MarshalPrinter classes into their own file. --- src/Generator/Generators/CLI/CLIMarshal.cs | 36 -------------------- src/Generator/Generators/Marshal.cs | 38 ++++++++++++++++++++++ src/Generator/Types/TypeMap.cs | 26 --------------- 3 files changed, 38 insertions(+), 62 deletions(-) create mode 100644 src/Generator/Generators/Marshal.cs diff --git a/src/Generator/Generators/CLI/CLIMarshal.cs b/src/Generator/Generators/CLI/CLIMarshal.cs index a79ffa37..12611276 100644 --- a/src/Generator/Generators/CLI/CLIMarshal.cs +++ b/src/Generator/Generators/CLI/CLIMarshal.cs @@ -4,42 +4,6 @@ using Cxxi.Types; namespace Cxxi.Generators.CLI { - public abstract class MarshalPrinter : ITypeVisitor, IDeclVisitor - { - 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 { diff --git a/src/Generator/Generators/Marshal.cs b/src/Generator/Generators/Marshal.cs new file mode 100644 index 00000000..eac24b5c --- /dev/null +++ b/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; + } + } +} diff --git a/src/Generator/Types/TypeMap.cs b/src/Generator/Types/TypeMap.cs index c475774f..e10f01eb 100644 --- a/src/Generator/Types/TypeMap.cs +++ b/src/Generator/Types/TypeMap.cs @@ -5,32 +5,6 @@ using Cxxi.Generators.CLI; 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)] public class TypeMapAttribute : Attribute {