Sha256: 9a6581cc3d0e6e03caec911e54e73977cc535c9f03d168fda925e32f20841595
Contents?: true
Size: 1.9 KB
Versions: 3
Compression:
Stored size: 1.9 KB
Contents
// // main.cpp // ASTDump // // Created by JP Simard on 6/5/14. // Copyright (c) 2014 Realm. All rights reserved. // #include <iostream> #include "clang-c/Index.h" ////////////////////////////////////////// // Print XML from translation unit ////////////////////////////////////////// void printXMLFromTU(CXTranslationUnit tu) { printf("<?xml version=\"1.0\"?>\n<jazz>"); clang_visitChildrenWithBlock(clang_getTranslationUnitCursor(tu), ^enum CXChildVisitResult(CXCursor cursor, CXCursor parent) { CXComment comment = clang_Cursor_getParsedComment(cursor); if (clang_Comment_getKind(comment) == CXComment_FullComment) { printf("%s\n", clang_getCString(clang_FullComment_getAsXML(comment))); } return CXChildVisit_Recurse; }); printf("</jazz>"); } ////////////////////////////////////////// // Make translation unit from index/file ////////////////////////////////////////// CXTranslationUnit tuFromIndexAndFile(CXIndex index, const char *filename) { const char *args[] = { "-x", "objective-c", "-isysroot", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" }; int numArgs = sizeof(args) / sizeof(*args); return clang_createTranslationUnitFromSourceFile(index, filename, numArgs, args, 0, NULL); } ////////////////////////////////////////// // Print XML from filename ////////////////////////////////////////// void printXMLFromFile(const char *filename) { CXIndex index = clang_createIndex(0, 1); CXTranslationUnit tu = tuFromIndexAndFile(index, filename); printXMLFromTU(tu); clang_disposeTranslationUnit(tu); clang_disposeIndex(index); } ////////////////////////////////////////// // Program entry ////////////////////////////////////////// int main(int argc, const char * argv[]) { printXMLFromFile(argv[1]); return 0; }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
jazzy-0.0.4 | parser/ASTDump/main.cpp |
jazzy-0.0.3 | parser/ASTDump/main.cpp |
jazzy-0.0.2 | parser/ASTDump/main.cpp |