public HandleRefTypeMap(TypedefNameDecl td, BindingContext ctx, TypeMapDatabase dataBase)
 {
     Context         = ctx;
     Type            = td.Type;
     TypeMapDatabase = dataBase;
     InjectedType    = new TagType(new Class( )
     {
         Name      = td.Name,
         Namespace = td.Namespace
     });
 }
Exemplo n.º 2
0
 public Driver(DriverOptions options, IDiagnosticConsumer diagnostics)
 {
     Options               = options;
     Diagnostics           = diagnostics;
     Project               = new Project();
     ASTContext            = new ASTContext();
     Symbols               = new SymbolContext();
     TypeDatabase          = new TypeMapDatabase();
     TranslationUnitPasses = new PassBuilder <TranslationUnitPass>(this);
     GeneratorOutputPasses = new PassBuilder <GeneratorOutputPass>(this);
 }
Exemplo n.º 3
0
 public Driver(DriverOptions options, IDiagnosticConsumer diagnostics)
 {
     Options                 = options;
     Diagnostics             = diagnostics;
     Parser                  = new Parser(Options);
     Parser.OnHeaderParsed  += OnFileParsed;
     Parser.OnLibraryParsed += OnFileParsed;
     TypeDatabase            = new TypeMapDatabase();
     TranslationUnitPasses   = new PassBuilder <TranslationUnitPass>(this);
     GeneratorOutputPasses   = new PassBuilder <GeneratorOutputPass>(this);
 }
Exemplo n.º 4
0
        public BindingContext(DriverOptions options, ParserOptions parserOptions = null)
        {
            Options       = options;
            ParserOptions = parserOptions;

            Symbols  = new SymbolContext();
            TypeMaps = new TypeMapDatabase();

            TranslationUnitPasses = new PassBuilder <TranslationUnitPass>(this);
            GeneratorOutputPasses = new PassBuilder <GeneratorOutputPass>(this);
        }
Exemplo n.º 5
0
        public BindingContext(DriverOptions options, ParserOptions parserOptions = null)
        {
            Options       = options;
            ParserOptions = parserOptions;

            Symbols   = new SymbolContext();
            Delegates = new Dictionary <Function, DelegatesPass.DelegateDefinition>();

            TypeMaps = new TypeMapDatabase();

            TranslationUnitPasses = new PassBuilder <TranslationUnitPass>(this);
            GeneratorOutputPasses = new PassBuilder <GeneratorOutputPass>(this);
        }
Exemplo n.º 6
0
        public BindingContext(IDiagnostics diagnostics, DriverOptions options, ParserOptions parserOptions = null)
        {
            Options       = options;
            Diagnostics   = diagnostics;
            ParserOptions = parserOptions;

            Symbols   = new SymbolContext();
            Delegates = new Dictionary <Function, DelegatesPass.DelegateDefinition>();

            TypeDatabase = new TypeMapDatabase();
            TypeDatabase.SetupTypeMaps(Options.GeneratorKind);

            TranslationUnitPasses = new PassBuilder <TranslationUnitPass>(this);
            GeneratorOutputPasses = new PassBuilder <GeneratorOutputPass>(this);
        }
Exemplo n.º 7
0
        public bool FindTypeMap(CppSharp.AST.Type type, out TypePrinterResult result)
        {
            result = null;

            if (!ResolveTypeMaps)
            {
                return(false);
            }

            TypeMap typeMap;

            if (!TypeMapDatabase.FindTypeMap(type, out typeMap) || typeMap.IsIgnored)
            {
                return(false);
            }

            var typePrinterContext = new TypePrinterContext
            {
                Type        = type,
                Kind        = Kind,
                MarshalKind = MarshalKind
            };

            var typePrinter = new CppTypePrinter(Context)
            {
                PrintFlavorKind     = PrintFlavorKind,
                ScopeKind           = ScopeKind,
                PrintTypeQualifiers = PrintTypeQualifiers,
                PrintTypeModifiers  = PrintTypeModifiers,
                ResolveTypeMaps     = false
            };

            typePrinter.PushContext(ContextKind);

            var typeName = typeMap.CppSignatureType(typePrinterContext).Visit(typePrinter);

            result = new TypePrinterResult(typeName)
            {
                TypeMap = typeMap
            };

            return(true);
        }
Exemplo n.º 8
0
        public override TypePrinterResult VisitTagType(TagType tag, TypeQualifiers quals)
        {
            TypeMap typeMap = null;

            if (TypeMapDatabase.FindTypeMap(tag, out typeMap))
            {
                var typePrinterContext = new TypePrinterContext {
                    Type = tag
                };
                return(typeMap.CLISignatureType(typePrinterContext).ToString());
            }

            Declaration decl = tag.Declaration;

            if (decl == null)
            {
                return(string.Empty);
            }

            return(VisitDeclaration(decl, quals));
        }
Exemplo n.º 9
0
        public override TypePrinterResult VisitTemplateSpecializationType(
            TemplateSpecializationType template, TypeQualifiers quals)
        {
            var decl = template.Template.TemplatedDecl;

            if (decl == null)
            {
                return(string.Empty);
            }

            TypeMap typeMap = null;

            if (TypeMapDatabase.FindTypeMap(template, out typeMap) && !typeMap.IsIgnored)
            {
                var typePrinterContext = new TypePrinterContext {
                    Type = template
                };
                return(typeMap.CLISignatureType(typePrinterContext).ToString());
            }

            return(decl.Name);
        }
Exemplo n.º 10
0
        public override TypePrinterResult VisitTagType(TagType tag,
                                                       TypeQualifiers quals)
        {
            TypeMap typeMap;

            if (ResolveTypeMaps && TypeMapDatabase.FindTypeMap(tag, out typeMap) &&
                !typeMap.IsIgnored)
            {
                var typePrinterContext = new TypePrinterContext {
                    Type = tag
                };
                var type = typeMap.CppSignatureType(typePrinterContext).ToString();
                return(new TypePrinterResult(type)
                {
                    TypeMap = typeMap
                });
            }

            var qual = GetStringQuals(quals);

            return($"{qual}{tag.Declaration.Visit(this)}");
        }
Exemplo n.º 11
0
 public static void FindEvents(this PassBuilder builder,
     TypeMapDatabase database)
 {
     var pass = new FindEventsPass(database);
     builder.AddPass(pass);
 }