public static int indexSourceFileFullArgv(CXIndexAction @param0, CXClientData @client_data, IndexerCallbacks[] @index_callbacks, uint @index_callbacks_size, uint @index_options, string @source_filename, string[] @command_line_args, int @num_command_line_args, CXUnsavedFile[] @unsaved_files, uint @num_unsaved_files, out CXTranslationUnit @out_TU, uint @TU_options)
        {
            var arr = new _CXUnsavedFile[unsaved_files.Length];

            try
            {
                BeginCXUnsavedFileMarshal(ref arr, ref unsaved_files);
                return(indexSourceFileFullArgv(param0, client_data, index_callbacks, index_callbacks_size, index_options, source_filename, command_line_args, num_command_line_args, arr, num_unsaved_files, out out_TU, TU_options));
            }
            finally
            {
                EndCXUnsavedFileMarshal(ref arr);
            }
        }
Exemple #2
0
 public static extern int indexTranslationUnit(CXIndexAction @param0, CXClientData @client_data, out IndexerCallbacks @index_callbacks, uint @index_callbacks_size, uint @index_options, CXTranslationUnit @param5);
Exemple #3
0
 public static extern int indexSourceFile(CXIndexAction @param0, CXClientData @client_data, out IndexerCallbacks @index_callbacks, uint @index_callbacks_size, uint @index_options, [MarshalAs(UnmanagedType.LPStr)] string @source_filename, string[] @command_line_args, int @num_command_line_args, out CXUnsavedFile @unsaved_files, uint @num_unsaved_files, out CXTranslationUnit @out_TU, uint @TU_options);
Exemple #4
0
 public static extern void getInclusions(CXTranslationUnit @tu, CXInclusionVisitor @visitor, CXClientData @client_data);
Exemple #5
0
 public static extern uint visitChildren(CXCursor @parent, CXCursorVisitor @visitor, CXClientData @client_data);
Exemple #6
0
 public void GetInclusions(CXInclusionVisitor visitor, CXClientData clientData) => clang.getInclusions(this, visitor, clientData);
Exemple #7
0
 public CXChildVisitResult VisitChildren(CXCursorVisitor visitor, CXClientData clientData) => (CXChildVisitResult)clang.visitChildren(this, visitor, clientData);
 private static extern int indexSourceFileFullArgv(CXIndexAction @param0, CXClientData @client_data, IntPtr @index_callbacks, uint @index_callbacks_size, uint @index_options, [MarshalAs(UnmanagedType.LPStr)] string @source_filename, string[] @command_line_args, int @num_command_line_args, [MarshalAs(UnmanagedType.LPArray)] _CXUnsavedFile[] @unsaved_files, uint @num_unsaved_files, out CXTranslationUnit @out_TU, uint @TU_options);
Exemple #9
0
        public static CXChildVisitResult cursorVisitor(CXCursor cursor, CXCursor parent, IntPtr client_data)
        {
            m_sparams.Clear();

            if (clang.getCursorKind(cursor) == CXCursorKind.CXCursor_CXXMethod ||
                clang.getCursorKind(cursor) == CXCursorKind.CXCursor_Constructor ||
                clang.getCursorKind(cursor) == CXCursorKind.CXCursor_Destructor)
            {

                if (m_getSelected && !m_selected.Equals(cursor))
                {
                    Console.WriteLine(clang.getCursorSpelling(m_selected).ToString());
                    return CXChildVisitResult.CXChildVisit_Recurse;
                }

                uint isDecl = clang.isCursorDefinition(cursor);
                if (isDecl == 0)
                {
                    CXClientData xx = new CXClientData();
                    var thisTU = clang.Cursor_getTranslationUnit(cursor);

                    var cloc = clang.getCursorLocation(cursor);
                    CXFile file;
                    uint line, col, offset;
                    clang.getFileLocation(cloc, out file, out line, out col, out offset);
                    string thisFile = clang.getFileName(file).ToString();

                    if (thisFile != m_file)
                    {
                        return CXChildVisitResult.CXChildVisit_Recurse;
                    }
                    clang.visitChildren(cursor, cursorVisitorMethodCollector, xx);

                    string methodName = clang.getCursorSpelling(cursor).ToString();
                    var classCursor = clang.getCursorSemanticParent(cursor);
                    string classType = clang.getCursorType(classCursor).ToString();
                    string retType = clang.getCursorResultType(cursor).ToString();

                    string methodSig = "";
                    if (clang.getCursorKind(cursor) == CXCursorKind.CXCursor_CXXMethod)
                    {
                        if (classType.Length > 0)
                            methodSig = retType + " " + classType + "::" + methodName + "(";
                        else
                            methodSig = retType + " " + methodName + "(";
                    }
                    else
                    {
                        if (classType.Length > 0)
                            methodSig = classType + "::" + methodName + "(";
                        else
                            methodSig = methodName + "(";
                    }
                    if (m_sparams.Count > 0)
                    {
                        for (int i = 0; i < m_sparams.Count - 1; i++)
                        {
                            methodSig += m_sparams[i].Item1 + " " + m_sparams[i].Item2 + ", ";
                        }
                        methodSig += m_sparams.Last().Item1 + " " + m_sparams.Last().Item2;
                    }
                    methodSig += ")";
                    m_outcpp += methodSig + "\n{\n\n}\n\n";
                }
            }

            return CXChildVisitResult.CXChildVisit_Recurse;
        }
Exemple #10
0
        public static string getFunction(string headerFilename, uint line, uint col)
        {
            var index = clang.createIndex(0, 0);
            CXUnsavedFile unsavedfile;
            m_file = headerFilename;
            m_outcpp = "";
            List<string> cargs = new List<string> { "-x", "c++", "-std=c++11", "-isystem", Path.GetDirectoryName(m_file).ToString() };

            foreach (string a in getIncludes())
            {
                cargs.Add("-isystem");
                cargs.Add(a);
            }

            var TU = clang.parseTranslationUnit(index, m_file,
                cargs.ToArray(), cargs.Count(), out unsavedfile, 0, (uint)CXTranslationUnit_Flags.CXTranslationUnit_None);

            var file = clang.getFile(TU, m_file);

            var sloc = clang.getLocation(TU, file, line, col);

            m_getSelected = true;

            m_selected = clang.getCursor(TU, sloc);

            var cursor = clang.getTranslationUnitCursor(TU);
            CXClientData s = new CXClientData();

            clang.visitChildren(cursor, cursorVisitor, s);

            Console.WriteLine(m_outcpp);

            clang.disposeTranslationUnit(TU);
            clang.disposeIndex(index);
            return m_outcpp;
        }
Exemple #11
0
        public static string getCPP(string headerFilename)
        {
            var index = clang.createIndex(0, 0);
            CXUnsavedFile unsavedfile;
            m_file = headerFilename;
            m_outcpp = "#include <" + Path.GetFileName(m_file) + "> \n\n";
            List<string> cargs = new List<string>{ "-x", "c++", "-std=c++11", "-isystem", Path.GetDirectoryName(m_file).ToString() };

            foreach (string a in getIncludes())
            {
                cargs.Add("-isystem");
                cargs.Add(a);
            }
            var TU = clang.parseTranslationUnit(index, m_file,
                cargs.ToArray(), cargs.Count, out unsavedfile, 0, (uint)CXTranslationUnit_Flags.CXTranslationUnit_None);

            m_getSelected = false;

            var cursor = clang.getTranslationUnitCursor(TU);
            CXClientData s = new CXClientData();

            clang.visitChildren(cursor, cursorVisitor, s);

            clang.disposeTranslationUnit(TU);
            clang.disposeIndex(index);
            return m_outcpp;
        }
Exemple #12
0
 public CXVisitorResult VisitFields(CXFieldVisitor visitor, CXClientData clientData) => (CXVisitorResult)clang.Type_visitFields(this, visitor, clientData);