Exemple #1
0
 private void Visit(TranslationUnit tu)
 {
     var result = new SourceFile();
     tu.Cursor.VisitChildren((cursor, parent) => {
         if (!cursor.Location.IsValid) {
             return Cursor.ChildVisitResult.Continue;
         }
         if (cursor.IsDeclaration) {
             Console.WriteLine("Declaration: " + cursor);
         }
         if (cursor.IsDefinition) {
             Console.WriteLine("Definition: " + cursor);
         }
         return _breakOn.Contains(cursor.Kind) ?
             Cursor.ChildVisitResult.Break :
             Cursor.ChildVisitResult.Recurse;
     });
 }
Exemple #2
0
 internal ObjCProtocolExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCProtocolExpr, CX_StmtClass.CX_StmtClass_ObjCProtocolExpr)
 {
     Debug.Assert(NumChildren is 0);
     _protocol = new Lazy <ObjCProtocolDecl>(() => TranslationUnit.GetOrCreate <ObjCProtocolDecl>(Handle.Referenced));
 }
 internal AttributedType(CXType handle) : base(handle, CXTypeKind.CXType_Attributed, CX_TypeClass.CX_TypeClass_Attributed)
 {
     _equivalentType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.EquivalentType));
     _modifiedType   = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.ModifiedType));
 }
Exemple #4
0
 internal LabelStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_LabelStmt, CX_StmtClass.CX_StmtClass_LabelStmt)
 {
     _decl    = new Lazy <LabelDecl>(() => TranslationUnit.GetOrCreate <LabelDecl>(Handle.Referenced));
     _subStmt = new Lazy <Stmt>(() => TranslationUnit.GetOrCreate <Stmt>(Handle.SubStmt));
 }
Exemple #5
0
 internal DependentSizedMatrixType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentSizedMatrix)
 {
     _rowExpr    = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(handle.RowExpr));
     _columnExpr = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(handle.ColumnExpr));
 }
Exemple #6
0
 private protected AdjustedType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass)
 {
     _adjustedType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.AdjustedType));
     _originalType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.OriginalType));
 }
Exemple #7
0
 private protected VectorType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass)
 {
     _elementType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.ElementType));
 }
Exemple #8
0
 internal SizeOfPackExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SizeOfPackExpr)
 {
     _pack = new Lazy <NamedDecl>(() => TranslationUnit.GetOrCreate <NamedDecl>(Handle.Referenced));
 }
 internal LValueReferenceType(CXType handle) : base(handle, CXTypeKind.CXType_LValueReference, CX_TypeClass.CX_TypeClass_LValueReference)
 {
     _desugaredType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.Desugar()));
 }
Exemple #10
0
 internal TypedefType(CXType handle) : base(handle, CXTypeKind.CXType_Typedef)
 {
     _decl = new Lazy <TypedefNameDecl>(() => TranslationUnit.GetOrCreate <TypedefNameDecl>(Handle.Declaration));
 }
        private protected RedeclarableTemplateDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastRedeclarableTemplate < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstRedeclarableTemplate))
            {
                throw new ArgumentException(nameof(handle));
            }

            _instantiatedFromMemberTemplate = new Lazy <RedeclarableTemplateDecl>(() => TranslationUnit.GetOrCreate <RedeclarableTemplateDecl>(Handle.SpecializedCursorTemplate));
        }
 internal SubstTemplateTypeParmType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_SubstTemplateTypeParm)
 {
     _desugaredType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.Desugar()));
 }
Exemple #13
0
 internal BuiltinType(CXType handle) : base(handle, handle.kind, CX_TypeClass.CX_TypeClass_Builtin)
 {
     _desugaredType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.Desugar()));
 }
Exemple #14
0
 internal MemberExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_MemberExpr)
 {
     _base       = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.SubExpr));
     _memberDecl = new Lazy <ValueDecl>(() => TranslationUnit.GetOrCreate <ValueDecl>(Handle.Referenced));
 }
Exemple #15
0
        public static int Run(InvocationContext context)
        {
            var additionalArgs         = context.ParseResult.ValueForOption <string[]>("additional");
            var configSwitches         = context.ParseResult.ValueForOption <string[]>("config");
            var defineMacros           = context.ParseResult.ValueForOption <string[]>("define-macro");
            var excludedNames          = context.ParseResult.ValueForOption <string[]>("exclude");
            var files                  = context.ParseResult.ValueForOption <string[]>("file");
            var fileDirectory          = context.ParseResult.ValueForOption <string>("file-directory");
            var headerFile             = context.ParseResult.ValueForOption <string>("headerFile");
            var includeDirectories     = context.ParseResult.ValueForOption <string[]>("include-directory");
            var language               = context.ParseResult.ValueForOption <string>("language");
            var libraryPath            = context.ParseResult.ValueForOption <string>("libraryPath");
            var methodClassName        = context.ParseResult.ValueForOption <string>("methodClassName");
            var methodPrefixToStrip    = context.ParseResult.ValueForOption <string>("prefixStrip");
            var namespaceName          = context.ParseResult.ValueForOption <string>("namespace");
            var outputLocation         = context.ParseResult.ValueForOption <string>("output");
            var remappedNameValuePairs = context.ParseResult.ValueForOption <string[]>("remap");
            var std = context.ParseResult.ValueForOption <string>("std");
            var testOutputLocation            = context.ParseResult.ValueForOption <string>("test-output");
            var traversalNames                = context.ParseResult.ValueForOption <string[]>("traverse");
            var withAttributeNameValuePairs   = context.ParseResult.ValueForOption <string[]>("with-attribute");
            var withCallConvNameValuePairs    = context.ParseResult.ValueForOption <string[]>("with-callconv");
            var withLibraryPathNameValuePairs = context.ParseResult.ValueForOption <string[]>("with-librarypath");
            var withSetLastErrors             = context.ParseResult.ValueForOption <string[]>("with-setlasterror");
            var withTypeNameValuePairs        = context.ParseResult.ValueForOption <string[]>("with-type");
            var withUsingNameValuePairs       = context.ParseResult.ValueForOption <string[]>("with-using");
            var suppressGcMethods             = context.ParseResult.ValueForOption <string[]>("suppress-gc");

            var errorList = new List <string>();

            if (!files.Any())
            {
                errorList.Add("Error: No input C/C++ files provided. Use --file or -f");
            }

            if (string.IsNullOrWhiteSpace(namespaceName))
            {
                errorList.Add("Error: No namespace provided. Use --namespace or -n");
            }

            if (string.IsNullOrWhiteSpace(outputLocation))
            {
                errorList.Add("Error: No output file location provided. Use --output or -o");
            }

            ParseKeyValuePairs(remappedNameValuePairs, errorList, out Dictionary <string, string> remappedNames);
            ParseKeyValuePairs(withAttributeNameValuePairs, errorList, out Dictionary <string, IReadOnlyList <string> > withAttributes);
            ParseKeyValuePairs(withCallConvNameValuePairs, errorList, out Dictionary <string, string> withCallConvs);
            ParseKeyValuePairs(withLibraryPathNameValuePairs, errorList, out Dictionary <string, string> withLibraryPath);
            ParseKeyValuePairs(withTypeNameValuePairs, errorList, out Dictionary <string, string> withTypes);
            ParseKeyValuePairs(withUsingNameValuePairs, errorList, out Dictionary <string, IReadOnlyList <string> > withUsings);

            var configOptions = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? PInvokeGeneratorConfigurationOptions.None : PInvokeGeneratorConfigurationOptions.GenerateUnixTypes;

            foreach (var configSwitch in configSwitches)
            {
                switch (configSwitch)
                {
                case "compatible-codegen":
                {
                    configOptions |= PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode;
                    configOptions &= ~PInvokeGeneratorConfigurationOptions.GeneratePreviewCode;
                    break;
                }

                case "default-remappings":
                {
                    configOptions &= ~PInvokeGeneratorConfigurationOptions.NoDefaultRemappings;
                    break;
                }

                case "exclude-com-proxies":
                {
                    configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeComProxies;
                    break;
                }

                case "exclude-empty-records":
                {
                    configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeEmptyRecords;
                    break;
                }

                case "exclude-enum-operators":
                {
                    configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeEnumOperators;
                    break;
                }

                case "explicit-vtbls":
                {
                    configOptions |= PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls;
                    break;
                }

                case "generate-aggressive-inlining":
                {
                    configOptions |= PInvokeGeneratorConfigurationOptions.GenerateAggressiveInlining;
                    break;
                }

                case "generate-macro-bindings":
                {
                    configOptions |= PInvokeGeneratorConfigurationOptions.GenerateMacroBindings;
                    break;
                }

                case "generate-tests-nunit":
                {
                    if (string.IsNullOrWhiteSpace(testOutputLocation))
                    {
                        errorList.Add("Error: No test output file location provided. Use --test-output or -to");
                    }

                    if (configOptions.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsXUnit))
                    {
                        errorList.Add("Cannot generate both NUnit and XUnit tests.");
                    }
                    configOptions |= PInvokeGeneratorConfigurationOptions.GenerateTestsNUnit;
                    break;
                }

                case "generate-tests-xunit":
                {
                    if (string.IsNullOrWhiteSpace(testOutputLocation))
                    {
                        errorList.Add("Error: No test output file location provided. Use --test-output or -to");
                    }

                    if (configOptions.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsNUnit))
                    {
                        errorList.Add("Cannot generate both NUnit and XUnit tests.");
                    }
                    configOptions |= PInvokeGeneratorConfigurationOptions.GenerateTestsXUnit;
                    break;
                }

                case "implicit-vtbls":
                {
                    configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls;
                    break;
                }

                case "latest-codegen":
                {
                    configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode;
                    configOptions &= ~PInvokeGeneratorConfigurationOptions.GeneratePreviewCode;
                    break;
                }

                case "log-exclusions":
                {
                    configOptions |= PInvokeGeneratorConfigurationOptions.LogExclusions;
                    break;
                }

                case "log-visited-files":
                {
                    configOptions |= PInvokeGeneratorConfigurationOptions.LogVisitedFiles;
                    break;
                }

                case "multi-file":
                {
                    configOptions |= PInvokeGeneratorConfigurationOptions.GenerateMultipleFiles;
                    break;
                }

                case "no-default-remappings":
                {
                    configOptions |= PInvokeGeneratorConfigurationOptions.NoDefaultRemappings;
                    break;
                }

                case "preview-codegen":
                {
                    configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode;
                    configOptions |= PInvokeGeneratorConfigurationOptions.GeneratePreviewCode;
                    break;
                }

                case "preview-codegen-nint":
                {
                    configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode;
                    configOptions |= PInvokeGeneratorConfigurationOptions.GeneratePreviewCodeNint;
                    break;
                }

                case "preview-codegen-fnptr":
                {
                    configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode;
                    configOptions |= PInvokeGeneratorConfigurationOptions.GeneratePreviewCodeFnptr;
                    break;
                }

                case "single-file":
                {
                    configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateMultipleFiles;
                    break;
                }

                case "unix-types":
                {
                    configOptions |= PInvokeGeneratorConfigurationOptions.GenerateUnixTypes;
                    break;
                }

                case "windows-types":
                {
                    configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateUnixTypes;
                    break;
                }

                default:
                {
                    errorList.Add($"Error: Unrecognized config switch: {configSwitch}.");
                    break;
                }
                }
            }

            if (!string.IsNullOrWhiteSpace(testOutputLocation) && !configOptions.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsNUnit) && !configOptions.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsXUnit))
            {
                errorList.Add("Error: No test format provided. Use --config generate-tests-nunit or --config generate-tests-xunit");
            }

            if (errorList.Any())
            {
                foreach (var error in errorList)
                {
                    context.Console.Error.Write(error);
                    context.Console.Error.Write(Environment.NewLine);
                }
                context.Console.Error.Write(Environment.NewLine);

                new HelpBuilder(context.Console).Write(s_rootCommand);
                return(-1);
            }

            var clangCommandLineArgs = new string[]
            {
                $"--language={language}",               // Treat subsequent input files as having type <language>
                $"--std={std}",                         // Language standard to compile for
                "-Wno-pragma-once-outside-header"       // We are processing files which may be header files
            };

            clangCommandLineArgs = clangCommandLineArgs.Concat(includeDirectories.Select(x => "--include-directory=" + x)).ToArray();
            clangCommandLineArgs = clangCommandLineArgs.Concat(defineMacros.Select(x => "--define-macro=" + x)).ToArray();
            clangCommandLineArgs = clangCommandLineArgs.Concat(additionalArgs).ToArray();

            foreach (var arg in clangCommandLineArgs)
            {
                Console.WriteLine(arg);
            }

            var translationFlags = CXTranslationUnit_Flags.CXTranslationUnit_None;

            translationFlags |= CXTranslationUnit_Flags.CXTranslationUnit_IncludeAttributedTypes;                           // Include attributed types in CXType
            translationFlags |= CXTranslationUnit_Flags.CXTranslationUnit_VisitImplicitAttributes;                          // Implicit attributes should be visited

            var config = new PInvokeGeneratorConfiguration(libraryPath, namespaceName, outputLocation, testOutputLocation, configOptions, excludedNames, headerFile, methodClassName, methodPrefixToStrip, remappedNames, traversalNames, withAttributes, withCallConvs, withLibraryPath, withSetLastErrors, withTypes, withUsings, suppressGcMethods);

            if (config.GenerateMacroBindings)
            {
                translationFlags |= CXTranslationUnit_Flags.CXTranslationUnit_DetailedPreprocessingRecord;
            }

            var exitCode = 0;

            using (var pinvokeGenerator = new PInvokeGenerator(config))
            {
                foreach (var file in files)
                {
                    var filePath = Path.Combine(fileDirectory, file);

                    var translationUnitError = CXTranslationUnit.TryParse(pinvokeGenerator.IndexHandle, filePath, clangCommandLineArgs, Array.Empty <CXUnsavedFile>(), translationFlags, out var handle);
                    var skipProcessing       = false;

                    if (translationUnitError != CXErrorCode.CXError_Success)
                    {
                        Console.WriteLine($"Error: Parsing failed for '{filePath}' due to '{translationUnitError}'.");
                        skipProcessing = true;
                    }
                    else if (handle.NumDiagnostics != 0)
                    {
                        Console.WriteLine($"Diagnostics for '{filePath}':");

                        for (uint i = 0; i < handle.NumDiagnostics; ++i)
                        {
                            using var diagnostic = handle.GetDiagnostic(i);

                            Console.Write("    ");
                            Console.WriteLine(diagnostic.Format(CXDiagnostic.DefaultDisplayOptions).ToString());

                            skipProcessing |= (diagnostic.Severity == CXDiagnosticSeverity.CXDiagnostic_Error);
                            skipProcessing |= (diagnostic.Severity == CXDiagnosticSeverity.CXDiagnostic_Fatal);
                        }
                    }

                    if (skipProcessing)
                    {
                        Console.WriteLine($"Skipping '{filePath}' due to one or more errors listed above.");
                        Console.WriteLine();

                        exitCode = -1;
                        continue;
                    }

                    try
                    {
                        using var translationUnit = TranslationUnit.GetOrCreate(handle);
                        Console.WriteLine($"Processing '{filePath}'");
                        pinvokeGenerator.GenerateBindings(translationUnit, filePath, clangCommandLineArgs, translationFlags);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }

                if (pinvokeGenerator.Diagnostics.Count != 0)
                {
                    Console.WriteLine("Diagnostics for binding generation:");

                    foreach (var diagnostic in pinvokeGenerator.Diagnostics)
                    {
                        Console.Write("    ");
                        Console.WriteLine(diagnostic);

                        if (diagnostic.Level == DiagnosticLevel.Warning)
                        {
                            if (exitCode >= 0)
                            {
                                exitCode++;
                            }
                        }
                        else if (diagnostic.Level == DiagnosticLevel.Error)
                        {
                            if (exitCode >= 0)
                            {
                                exitCode = -1;
                            }
                            else
                            {
                                exitCode--;
                            }
                        }
                    }
                }
            }

            return(exitCode);
        }
 internal DependentSizedExtVectorType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentSizedExtVector)
 {
     _elementType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.ElementType));
     _sizeExpr    = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.SizeExpr));
 }
Exemple #17
0
 internal ObjCTypeParamType(CXType handle) : base(handle, CXTypeKind.CXType_ObjCTypeParam, CX_TypeClass.CX_TypeClass_ObjCTypeParam)
 {
     _decl = new Lazy <ObjCTypeParamDecl>(() => TranslationUnit.GetOrCreate <ObjCTypeParamDecl>(Handle.Declaration));
 }
 internal CXXDestructorDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Destructor, CX_DeclKind.CX_DeclKind_CXXDestructor)
 {
     _operatorDelete        = new Lazy <FunctionDecl>(() => TranslationUnit.GetOrCreate <FunctionDecl>(Handle.GetSubDecl(0)));
     _operatorDeleteThisArg = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.GetExpr(0)));
 }
        void ReadHeader(string headerFile)
        {
            Console.Write('.');

            var unsavedFiles = new UnsavedFile[] { };
            if (headerFile.EndsWith("PosixThreadSupport.h"))
            {
                List<string> clangOptionsPThread = new List<string>(clangOptions);
                clangOptionsPThread.Add("-DUSE_PTHREADS");
                currentTU = index.CreateTranslationUnit(headerFile, clangOptionsPThread.ToArray(), unsavedFiles, TranslationUnitFlags.SkipFunctionBodies);
            }
            else
            {
                currentTU = index.CreateTranslationUnit(headerFile, clangOptions.ToArray(), unsavedFiles, TranslationUnitFlags.SkipFunctionBodies);
            }
            var cur = currentTU.Cursor;
            cur.VisitChildren(HeaderVisitor);
            currentTU.Dispose();
            currentTU = null;
            headerQueue.Remove(headerFile);
        }
 internal EnumConstantDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_EnumConstantDecl, CX_DeclKind.CX_DeclKind_EnumConstant)
 {
     _initExpr = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.InitExpr));
 }
 internal CXXBindTemporaryExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr)
 {
     _subExpr = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.SubExpr));
 }
 internal MacroQualifiedType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_MacroQualified)
 {
     _desugaredType  = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.Desugar()));
     _modifiedType   = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.ModifiedType));
     _underlyingType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.UnderlyingType));
 }
Exemple #23
0
 internal IndirectFieldDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_IndirectField)
 {
     _anonField = new Lazy <FieldDecl>(() => TranslationUnit.GetOrCreate <FieldDecl>(Handle.GetSubDecl(0)));
     _varDecl   = new Lazy <VarDecl>(() => TranslationUnit.GetOrCreate <VarDecl>(Handle.GetSubDecl(1)));
 }
 internal NamespaceAliasDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_NamespaceAlias, CX_DeclKind.CX_DeclKind_NamespaceAlias)
 {
     _aliasedNamespace = new Lazy <NamedDecl>(() => TranslationUnit.GetOrCreate <NamedDecl>(Handle.GetSubDecl(0)));
     _namespace        = new Lazy <NamespaceDecl>(() => TranslationUnit.GetOrCreate <NamespaceDecl>(Handle.GetSubDecl(1)));
 }
Exemple #25
0
 private protected DeducedType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass)
 {
     _deducedType   = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.DeducedType));
     _desugaredType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.Desugar()));
 }
Exemple #26
0
 internal DependentExtIntType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentExtInt)
 {
     _numBitsExpr = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(handle.NumBitsExpr));
 }
Exemple #27
0
 internal ElaboratedType(CXType handle) : base(handle, CXTypeKind.CXType_Elaborated, CX_TypeClass.CX_TypeClass_Elaborated)
 {
     _namedType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.NamedType));
 }
 internal PackExpansionType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_PackExpansion)
 {
     _pattern = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.OriginalType));
 }
Exemple #29
0
 internal DecltypeType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Decltype)
 {
     _desugaredType  = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.Desugar()));
     _underlyingExpr = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.UnderlyingExpr));
     _underlyingType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.UnderlyingType));
 }
Exemple #30
0
 internal AddrLabelExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_AddrLabelExpr, CX_StmtClass.CX_StmtClass_AddrLabelExpr)
 {
     Debug.Assert(NumChildren is 0);
     _label = new Lazy <LabelDecl>(() => TranslationUnit.GetOrCreate <LabelDecl>(Handle.Referenced));
 }
 internal CompoundAssignOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CompoundAssignOperator, CX_StmtClass.CX_StmtClass_CompoundAssignOperator)
 {
     _computationLHSType    = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(handle.ComputationLhsType));
     _computationResultType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(handle.ComputationResultType));
 }
 internal ConstructorUsingShadowDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ConstructorUsingShadow)
 {
     _constructedBaseClass           = new Lazy <CXXRecordDecl>(() => TranslationUnit.GetOrCreate <CXXRecordDecl>(Handle.ConstructedBaseClass));
     _constructedBaseClassShadowDecl = new Lazy <ConstructorUsingShadowDecl>(() => TranslationUnit.GetOrCreate <ConstructorUsingShadowDecl>(Handle.ConstructedBaseClassShadowDecl));
     _nominatedBaseClass             = new Lazy <CXXRecordDecl>(() => TranslationUnit.GetOrCreate <CXXRecordDecl>(Handle.NominatedBaseClass));
     _nominatedBaseClassShadowDecl   = new Lazy <ConstructorUsingShadowDecl>(() => TranslationUnit.GetOrCreate <ConstructorUsingShadowDecl>(Handle.NominatedBaseClassShadowDecl));
 }