From d4bb47a3a73430259ff7d108bb7238b3c695ba57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Tue, 21 Jul 2015 11:25:44 +0200 Subject: [PATCH 01/11] Edits to make make install work for juci --- CMakeLists.txt | 3 ++- src/CMakeLists.txt | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 99ac894..8ad95fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required (VERSION 2.8.4) set(project_name clangmm) project(${project_name}) -set(library_installation_path "/usr/local/lib/libclangmm/") +set(library_path "/usr/local/lib/") +set(include_path "/usr/local/include/") if(APPLE) set(Boost_USE_STATIC_LIBS "YES") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 478c921..3879c84 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,7 +48,5 @@ add_library(${project_name} SHARED ${header_files} ${cc_files}) include_directories(${LIBCLANG_INCLUDE_DIRS}) target_link_libraries(${project_name} ${LIBCLANG_LIBRARIES}) -install(TARGETS ${project_name} - LIBRARY DESTINATION ${library_installation_path}) -install(FILES ${header_files} - DESTINATION ${library_installation_path}/include) +install(TARGETS ${project_name} LIBRARY DESTINATION ${library_path}) +install(FILES ${header_files} DESTINATION ${include_path}/libclangmm) From f8641dc2a6244d9391eba43404fb3065fa1baa96 Mon Sep 17 00:00:00 2001 From: Geir Morten Larsen Date: Wed, 22 Jul 2015 17:27:58 +0200 Subject: [PATCH 02/11] Adding installation guide in a own folder --- docs/install.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 docs/install.md diff --git a/docs/install.md b/docs/install.md new file mode 100644 index 0000000..37e529e --- /dev/null +++ b/docs/install.md @@ -0,0 +1,25 @@ +# juCi++ +## Installation guide ## +## Linux +```sh +# Libraries +$ sudo apt-get install libboost-log-dev libclang-dev +# Programs +$sudo apt-get install make cmake gcc + +``` +Compile +```sh +# When git clone +$ cd path-to-cloned-from-folder/jucipp/juci +# When download zipped file, extraxt it to a folder of your choice +$ cd path-to-folder-extraxted-into/jucipp-master/juci +# In both cases above you can choose remove the jucipp folder, but remeber to apply changes to cd command as well. +$ cmake . +$ make +``` + +## Run +```sh +$ ./bin/juci +``` From ee4f02a1b5e13f07ebae7c74e15d1019aaf3fcfb Mon Sep 17 00:00:00 2001 From: Geir Morten Larsen Date: Wed, 22 Jul 2015 17:36:49 +0200 Subject: [PATCH 03/11] Fixing link to installation guide --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 960bb25..1d735b6 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,8 @@ $ git clone https://github.com/cppit/libclangmm.git ## Installation ## -```sh -$ cmake . -$ make install -``` +See [installation guide](https://github.com/cppit/libclangmm/blob/master/docs/install.md) + **Notice:** *make install* needs root privileges # Usage # From 483d9bf9d3765e4ad736ee8417f6bf5f5fef0b5f Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 22 Jul 2015 17:49:26 +0200 Subject: [PATCH 04/11] Simpler Token::get_brief_comments. --- src/Token.cc | 55 ++++++---------------------------------------------- 1 file changed, 6 insertions(+), 49 deletions(-) diff --git a/src/Token.cc b/src/Token.cc index ce3da9b..de9f93d 100644 --- a/src/Token.cc +++ b/src/Token.cc @@ -59,57 +59,14 @@ std::string clang::Token::get_type() { return spelling; } -//TODO: use clang_Cursor_getBriefCommentText std::string clang::Token::get_brief_comments() { std::string comment_string; - auto referenced=clang_getCursorReferenced(cx_cursor); - auto comment=clang_Cursor_getParsedComment(referenced); - if(clang_Comment_getKind(comment)==CXComment_FullComment) { - size_t para_c=0; - for(unsigned c=0;c=2) - break; - for(unsigned c=0;c0) - comment_string.pop_back(); - if(clang_InlineCommandComment_getNumArgs(grandchild_comment)==0) - comment_string+=clang_getCString(cxstr); - clang_disposeString(cxstr); - for(unsigned arg_c=0;arg_c0) - comment_string+=" "; - comment_string+=clang_getCString(cxstr); - clang_disposeString(cxstr); - } - } - } - } - } - /*cout << " " << clang_Comment_getKind(child_comment) << ", children: " << clang_Comment_getNumChildren(child_comment) << endl; - auto cxstr=clang_FullComment_getAsHTML(child_comment); - cout << " " << clang_getCString(cxstr) << endl; - clang_disposeString(cxstr);*/ - } - while(comment_string.size()>0 && (comment_string.back()=='\n' || comment_string.back()==' ')) - comment_string.pop_back(); + auto referenced=get_cursor().get_referenced(); + if(referenced) { + auto cxstr=clang_Cursor_getBriefCommentText(referenced.cx_cursor); + if(cxstr.data!=NULL) + comment_string=clang_getCString(cxstr); + clang_disposeString(cxstr); } - return comment_string; } From 7eaafa5dde03d941fe3668614b7ca3d842c62b54 Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 23 Jul 2015 11:53:30 +0200 Subject: [PATCH 05/11] Added clang::to_string in Utility.* to and used this to clean up all the CXString code. --- src/CMakeLists.txt | 2 ++ src/CompileCommand.cc | 5 +++-- src/CompletionString.cc | 19 ++++++------------- src/CompletionString.h | 4 ++-- src/Cursor.cc | 6 ++---- src/Diagnostic.cc | 5 ++--- src/SourceLocation.cc | 5 ++--- src/Token.cc | 21 ++++++--------------- src/Tokens.cc | 14 ++++---------- src/TranslationUnit.cc | 9 +++------ src/Utility.cc | 10 ++++++++++ src/Utility.h | 10 ++++++++++ src/clangmm.h | 1 + 13 files changed, 53 insertions(+), 58 deletions(-) create mode 100644 src/Utility.cc create mode 100644 src/Utility.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 478c921..22cab39 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,6 +26,7 @@ set(header_files Tokens.h TranslationUnit.h Diagnostic.h + Utility.h ) set(cc_files CodeCompleteResults.cc @@ -41,6 +42,7 @@ set(cc_files Tokens.cc TranslationUnit.cc Diagnostic.cc + Utility.cc ) add_library(${project_name} SHARED ${header_files} ${cc_files}) diff --git a/src/CompileCommand.cc b/src/CompileCommand.cc index 0cb8971..5c4ec93 100644 --- a/src/CompileCommand.cc +++ b/src/CompileCommand.cc @@ -1,12 +1,13 @@ #include "CompileCommand.h" #include "CompileCommands.h" +#include "Utility.h" std::string clang::CompileCommand:: get_command() { std::string res; unsigned N = clang_CompileCommand_getNumArgs(cx_command); for (unsigned i = 0; i < N; i++) { - res += clang_getCString(clang_CompileCommand_getArg(cx_command, i)); + res += clang::to_string(clang_CompileCommand_getArg(cx_command, i)); } return res; } @@ -16,7 +17,7 @@ get_command_as_args() { unsigned N = clang_CompileCommand_getNumArgs(cx_command); std::vector res(N); for (unsigned i = 0; i < N; i++) { - res[i] = clang_getCString(clang_CompileCommand_getArg(cx_command, i)); + res[i] = clang::to_string(clang_CompileCommand_getArg(cx_command, i)); } return res; } diff --git a/src/CompletionString.cc b/src/CompletionString.cc index 2d291c1..9833466 100644 --- a/src/CompletionString.cc +++ b/src/CompletionString.cc @@ -1,34 +1,27 @@ #include "CompletionString.h" +#include "Utility.h" clang::CompletionString:: -CompletionString(const CXCompletionString &cx_str) : cx_str(cx_str) {} +CompletionString(const CXCompletionString &cx_completion_sting) : cx_completion_sting(cx_completion_sting) {} bool clang::CompletionString::available() { - return clang_getCompletionAvailability(cx_str) == CXAvailability_Available; + return clang_getCompletionAvailability(cx_completion_sting) == CXAvailability_Available; } unsigned clang::CompletionString::get_num_chunks() { - return clang_getNumCompletionChunks(cx_str); + return clang_getNumCompletionChunks(cx_completion_sting); } std::vector clang::CompletionString::get_chunks() { std::vector res; for (unsigned i = 0; i < get_num_chunks(); i++) { - auto cxstr=clang_getCompletionChunkText(cx_str, i); - res.emplace_back(clang_getCString(cxstr), static_cast (clang_getCompletionChunkKind(cx_str, i))); - clang_disposeString(cxstr); + res.emplace_back(clang::to_string(clang_getCompletionChunkText(cx_completion_sting, i)), static_cast (clang_getCompletionChunkKind(cx_completion_sting, i))); } return res; } std::string clang::CompletionString::get_brief_comments() { - std::string brief_comments; - auto cxstr=clang_getCompletionBriefComment(cx_str); - if(cxstr.data!=NULL) { - brief_comments=clang_getCString(cxstr); - clang_disposeString(cxstr); - } - return brief_comments; + return clang::to_string(clang_getCompletionBriefComment(cx_completion_sting)); } clang::CompletionChunk:: diff --git a/src/CompletionString.h b/src/CompletionString.h index a9d9830..8c3b16c 100644 --- a/src/CompletionString.h +++ b/src/CompletionString.h @@ -28,13 +28,13 @@ namespace clang { class CompletionString { public: - explicit CompletionString(const CXCompletionString &cx_str); + explicit CompletionString(const CXCompletionString &cx_completion_sting); bool available(); std::vector get_chunks(); std::string get_brief_comments(); unsigned get_num_chunks(); - CXCompletionString cx_str; + CXCompletionString cx_completion_sting; }; } // namespace clang #endif // COMPLETIONSTRING_H_ diff --git a/src/Cursor.cc b/src/Cursor.cc index d5be2a2..6cd3271 100644 --- a/src/Cursor.cc +++ b/src/Cursor.cc @@ -1,4 +1,5 @@ #include "Cursor.h" +#include "Utility.h" const clang::CursorKind clang::Cursor::get_kind() { return (CursorKind) clang_getCursorKind(this->cx_cursor); @@ -13,10 +14,7 @@ clang::SourceRange clang::Cursor::get_source_range() const { } std::string clang::Cursor::get_usr() const { - auto cxstr=clang_getCursorUSR(cx_cursor); - std::string USR=clang_getCString(cxstr); - clang_disposeString(cxstr); - return USR; + return clang::to_string(clang_getCursorUSR(cx_cursor)); } clang::Cursor clang::Cursor::get_referenced() const { diff --git a/src/Diagnostic.cc b/src/Diagnostic.cc index 1ff3cfe..0fdc199 100644 --- a/src/Diagnostic.cc +++ b/src/Diagnostic.cc @@ -1,13 +1,12 @@ #include "Diagnostic.h" #include "SourceLocation.h" #include "Tokens.h" +#include "Utility.h" clang::Diagnostic::Diagnostic(CXTranslationUnit& cx_tu, CXDiagnostic& cx_diagnostic) { severity=clang_getDiagnosticSeverity(cx_diagnostic); severity_spelling=get_severity_spelling(severity); - auto cxstr=clang_getDiagnosticSpelling(cx_diagnostic); - spelling=clang_getCString(cxstr); - clang_disposeString(cxstr); + spelling=clang::to_string(clang_getDiagnosticSpelling(cx_diagnostic)); clang::SourceLocation start_location(clang_getDiagnosticLocation(cx_diagnostic)); path=start_location.get_path(); diff --git a/src/SourceLocation.cc b/src/SourceLocation.cc index 62a2d6c..8227938 100644 --- a/src/SourceLocation.cc +++ b/src/SourceLocation.cc @@ -1,4 +1,5 @@ #include "SourceLocation.h" +#include "Utility.h" // // // // // // // // // SourceLocation // @@ -26,9 +27,7 @@ void clang::SourceLocation::get_data(std::string* path, unsigned *line, unsigned CXFile file; clang_getExpansionLocation(cx_location, &file, line, column, offset); if (file!=NULL) { - auto cxstr=clang_getFileName(file); - *path=clang_getCString(cxstr); - clang_disposeString(cxstr); + *path=clang::to_string(clang_getFileName(file)); } } } diff --git a/src/Token.cc b/src/Token.cc index de9f93d..e3a9b9c 100644 --- a/src/Token.cc +++ b/src/Token.cc @@ -1,4 +1,5 @@ #include "Token.h" +#include "Utility.h" // // // // // // Token // @@ -16,8 +17,7 @@ clang::SourceRange clang::Token::get_source_range() { } // returns a string description of this tokens kind std::string clang::Token::get_spelling() { - CXString s = clang_getTokenSpelling(cx_tu, cx_token); - return std::string(clang_getCString(s)); + return clang::to_string(clang_getTokenSpelling(cx_tu, cx_token)); } const clang::TokenKind clang::Token::get_kind() { @@ -30,9 +30,7 @@ bool clang::Token::has_type() { if(clang_Cursor_isNull(referenced)) return false; auto type=clang_getCursorType(referenced); - auto cxstr=clang_getTypeSpelling(type); - std::string spelling=clang_getCString(cxstr); - clang_disposeString(cxstr); + auto spelling=clang::to_string(clang_getTypeSpelling(type)); return spelling!=""; } @@ -41,17 +39,13 @@ std::string clang::Token::get_type() { auto referenced=clang_getCursorReferenced(cx_cursor); if(!clang_Cursor_isNull(referenced)) { auto type=clang_getCursorType(referenced); - auto cxstr=clang_getTypeSpelling(type); - spelling=clang_getCString(cxstr); - clang_disposeString(cxstr); + spelling=clang::to_string(clang_getTypeSpelling(type)); std::string auto_end=""; //TODO fix const auto if((spelling.size()>=4 && spelling.substr(0, 4)=="auto")) { auto_end=spelling.substr(4); auto type=clang_getCanonicalType(clang_getCursorType(cx_cursor)); - auto cxstr=clang_getTypeSpelling(type); - spelling=clang_getCString(cxstr); - clang_disposeString(cxstr); + spelling=clang::to_string(clang_getTypeSpelling(type)); if(spelling.find(" ")==std::string::npos) spelling+=auto_end; } @@ -63,10 +57,7 @@ std::string clang::Token::get_brief_comments() { std::string comment_string; auto referenced=get_cursor().get_referenced(); if(referenced) { - auto cxstr=clang_Cursor_getBriefCommentText(referenced.cx_cursor); - if(cxstr.data!=NULL) - comment_string=clang_getCString(cxstr); - clang_disposeString(cxstr); + comment_string=clang::to_string(clang_Cursor_getBriefCommentText(referenced.cx_cursor)); } return comment_string; } diff --git a/src/Tokens.cc b/src/Tokens.cc index b62b982..5b79198 100644 --- a/src/Tokens.cc +++ b/src/Tokens.cc @@ -1,4 +1,5 @@ #include "Tokens.h" +#include "Utility.h" #include using namespace std; @@ -45,12 +46,9 @@ std::vector > clang::Tokens::get_cxx_methods() auto offset=cursor.get_source_location().get_offset(); if(offset!=last_offset) { std::string method; - CXString cxstr; if(kind==clang::CursorKind::CXXMethod) { auto type=clang_getResultType(clang_getCursorType(cursor.cx_cursor)); - auto cxstr=clang_getTypeSpelling(type); - method+=clang_getCString(cxstr); - clang_disposeString(cxstr); + method+=clang::to_string(clang_getTypeSpelling(type)); auto pos=method.find(" "); if(pos!=std::string::npos) method.erase(pos, 1); @@ -58,15 +56,11 @@ std::vector > clang::Tokens::get_cxx_methods() } clang::Cursor parent(clang_getCursorSemanticParent(cursor.cx_cursor)); - cxstr=clang_getCursorDisplayName(parent.cx_cursor); - method+=clang_getCString(cxstr); - clang_disposeString(cxstr); + method+=clang::to_string(clang_getCursorDisplayName(parent.cx_cursor)); method+="::"; - cxstr=clang_getCursorDisplayName(cursor.cx_cursor); - method+=clang_getCString(cxstr); - clang_disposeString(cxstr); + method+=clang::to_string(clang_getCursorDisplayName(cursor.cx_cursor)); methods.emplace_back(method, offset); } last_offset=offset; diff --git a/src/TranslationUnit.cc b/src/TranslationUnit.cc index edd2bde..1118f37 100644 --- a/src/TranslationUnit.cc +++ b/src/TranslationUnit.cc @@ -1,6 +1,7 @@ #include "TranslationUnit.h" #include "SourceLocation.h" #include "Tokens.h" +#include "Utility.h" #include #include @@ -91,9 +92,7 @@ unsigned clang::TranslationUnit::DefaultFlags() { } clang::CodeCompleteResults clang::TranslationUnit::get_code_completions(const std::map &buffers, unsigned line_number, unsigned column) { - auto cxstr=clang_getTranslationUnitSpelling(cx_tu); - std::string path=clang_getCString(cxstr); - clang_disposeString(cxstr); + auto path=clang::to_string(clang_getTranslationUnitSpelling(cx_tu)); clang::CodeCompleteResults results(cx_tu, path, buffers, line_number, column); return results; @@ -110,9 +109,7 @@ std::vector clang::TranslationUnit::get_diagnostics() { } std::unique_ptr clang::TranslationUnit::get_tokens(unsigned start_offset, unsigned end_offset) { - auto cxstr=clang_getTranslationUnitSpelling(cx_tu); - std::string path=clang_getCString(cxstr); - clang_disposeString(cxstr); + auto path=clang::to_string(clang_getTranslationUnitSpelling(cx_tu)); clang::SourceLocation start_location(cx_tu, path, start_offset); clang::SourceLocation end_location(cx_tu, path, end_offset); clang::SourceRange range(start_location, end_location); diff --git a/src/Utility.cc b/src/Utility.cc new file mode 100644 index 0000000..7f1c266 --- /dev/null +++ b/src/Utility.cc @@ -0,0 +1,10 @@ +#include "Utility.h" + +std::string clang::to_string(CXString cx_string) { + std::string string; + if(cx_string.data!=NULL) { + string=clang_getCString(cx_string); + clang_disposeString(cx_string); + } + return string; +} \ No newline at end of file diff --git a/src/Utility.h b/src/Utility.h new file mode 100644 index 0000000..6f7e319 --- /dev/null +++ b/src/Utility.h @@ -0,0 +1,10 @@ +#ifndef UTILITY_H_ +#define UTILITY_H_ +#include +#include + +namespace clang { + std::string to_string(CXString cx_string); +} + +#endif // UTILITY_H_ \ No newline at end of file diff --git a/src/clangmm.h b/src/clangmm.h index 3ffe3ae..b1abb81 100644 --- a/src/clangmm.h +++ b/src/clangmm.h @@ -13,4 +13,5 @@ #include "Index.h" #include "Cursor.h" #include "Diagnostic.h" +#include "Utility.h" #endif // CLANGMM_H_ From a17de316ed5caef3a0317cda2f1ff0b00cd3a4c6 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sun, 26 Jul 2015 13:21:01 +0200 Subject: [PATCH 06/11] Minor fix. --- src/Diagnostic.cc | 2 +- src/Tokens.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Diagnostic.cc b/src/Diagnostic.cc index 0fdc199..177dabb 100644 --- a/src/Diagnostic.cc +++ b/src/Diagnostic.cc @@ -13,7 +13,7 @@ clang::Diagnostic::Diagnostic(CXTranslationUnit& cx_tu, CXDiagnostic& cx_diagnos unsigned start_offset=start_location.get_offset(); clang::Tokens tokens(cx_tu, SourceRange(start_location, start_location)); if(tokens.size()==1) { - offsets=std::pair(start_offset, tokens[0].offsets.second); + offsets=std::pair(start_offset, tokens.begin()->offsets.second); } } diff --git a/src/Tokens.cc b/src/Tokens.cc index 5b79198..7600cc8 100644 --- a/src/Tokens.cc +++ b/src/Tokens.cc @@ -6,7 +6,7 @@ using namespace std; clang::Tokens::Tokens(CXTranslationUnit &cx_tu, const SourceRange &range): cx_tu(cx_tu) { clang_tokenize(cx_tu, range.cx_range, &cx_tokens, &num_tokens); cx_cursors.clear(); - cx_cursors.reserve(num_tokens); + cx_cursors.resize(num_tokens); clang_annotateTokens(cx_tu, cx_tokens, num_tokens, cx_cursors.data()); for (unsigned i = 0; i < num_tokens; i++) { emplace_back(Token(cx_tu, cx_tokens[i], cx_cursors[i])); From 573a759b33b3636fdb86a0006789d8ec4c1843b9 Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 27 Jul 2015 10:46:19 +0200 Subject: [PATCH 07/11] Slight change to Tokens::get_similar_token_offsets. --- src/Tokens.cc | 14 ++++++-------- src/Tokens.h | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Tokens.cc b/src/Tokens.cc index 7600cc8..f2fd316 100644 --- a/src/Tokens.cc +++ b/src/Tokens.cc @@ -20,15 +20,13 @@ clang::Tokens::~Tokens() { //This works across TranslationUnits! However, to get rename refactoring to work, //one have to open all the files that might include a similar token //Similar tokens defined as tokens with equal referenced cursors. -std::vector > clang::Tokens::get_similar_token_offsets(clang::Token& token) { +std::vector > clang::Tokens::get_similar_token_offsets(const std::string &usr) { std::vector > offsets; - auto referenced=token.get_cursor().get_referenced(); - if(referenced) { - auto referenced_usr=referenced.get_usr(); - for(auto &a_token: *this) { - auto a_referenced=a_token.get_cursor().get_referenced(); - if(a_referenced && referenced_usr==a_referenced.get_usr() && token.get_spelling()==a_token.get_spelling()) { - offsets.emplace_back(a_token.offsets); + for(auto &token: *this) { + if(token.get_kind()==clang::Token_Identifier) { + auto referenced=token.get_cursor().get_referenced(); + if(referenced && usr==referenced.get_usr()) { + offsets.emplace_back(token.offsets); } } } diff --git a/src/Tokens.h b/src/Tokens.h index 96366cd..7f1ea1b 100644 --- a/src/Tokens.h +++ b/src/Tokens.h @@ -13,7 +13,7 @@ namespace clang { Tokens(CXTranslationUnit &cx_tu, const SourceRange &range); public: ~Tokens(); - std::vector > get_similar_token_offsets(clang::Token& token); + std::vector > get_similar_token_offsets(const std::string &usr); std::vector > get_cxx_methods(); private: CXToken *cx_tokens; From 79d71fa2c314f30d68ea6066a27053116c5d2a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Thu, 30 Jul 2015 14:22:36 +0200 Subject: [PATCH 08/11] Move docs to correct folder --- {src/docs => docs}/windows-install.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {src/docs => docs}/windows-install.md (100%) diff --git a/src/docs/windows-install.md b/docs/windows-install.md similarity index 100% rename from src/docs/windows-install.md rename to docs/windows-install.md From b88a21ff54f93b193c178fd29af03109118eb220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Thu, 30 Jul 2015 14:25:14 +0200 Subject: [PATCH 09/11] Delete windows install guide --- docs/windows-install.md | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 docs/windows-install.md diff --git a/docs/windows-install.md b/docs/windows-install.md deleted file mode 100644 index 156f22e..0000000 --- a/docs/windows-install.md +++ /dev/null @@ -1,13 +0,0 @@ -# Windows Install Guide # -## Requirements ## - -```bash -* chocolatey [website](http://chocolatey.org) -``` - -##Preperation ## -First you install some dependencies - -```bash -PS: choco install cmake make nmake -``` From 14a107dd4e04b3d5df28ae36e7a9b9c151db1b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Thu, 30 Jul 2015 15:23:27 +0200 Subject: [PATCH 10/11] Update readmes and compilation --- CMakeLists.txt | 5 +-- README.md | 94 ++++++++----------------------------------------- docs/install.md | 26 ++++---------- 3 files changed, 25 insertions(+), 100 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ad95fd..dab3e5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ if(APPLE) set(CMAKE_MACOSX_RPATH 1) endif() -enable_testing() add_subdirectory(src) -add_subdirectory(tests) + +# enable_testing() +# add_subdirectory(tests) diff --git a/README.md b/README.md index 1d735b6..9851154 100644 --- a/README.md +++ b/README.md @@ -1,94 +1,30 @@ # libclangmm - An easy to use C++-wrapper for libclang # ## About ## -This project is written by *cppit* as part of an bachelor thesis +This is a highlevel wrapper for [libclang](http://www.llvm.com). It +provides highlevel C++11 access to complicated C code. -# Install # -This section describes how to install this library on your system. The section below is tested in on unix based systems and in windows. If there are any problems please create an issue and we will look into it. ## Dependencies ## -Please install these dependencies on your system. - * libclang -* cmake -* make -* clang or gcc (compiler) - -## Download the source ## -There are two ways of downloading the source - -### Download the zip ### -You can download the zip [here](https://github.com/cppit/libclangmm/archive/master.zip). - -### Cloning the repository ### - -```sh -$ git clone https://github.com/cppit/libclangmm.git - -``` - ## Installation ## - See [installation guide](https://github.com/cppit/libclangmm/blob/master/docs/install.md) -**Notice:** *make install* needs root privileges - -# Usage # -One quick start: - -```cpp - // lets say it is empty - std::string path("your file here"); - - clang::Index index(0, 0); - clang::TranslationUnit tu(&index, path); - - // ReparseTranslationUnit takes a map with filepath as key - // and buffer as value - std::map buffers; - - // create buffer (this would normally be a gtk/qt-buffer or something) - std::string file; - file.append("#include "); - file.append("int main(int argc, char *argv[]) {\n"); - file.append("std::cout << \"Hello World!\" << std::endl;\n"); - file.append("return 0\n"); - file.append("}"); - - buffers[path] = file; - - // after you can use various methods to get locations - // for tokens for syntax highlighting of refactoring - - // the buffer map should contain all open files. I.e in an text editor - // you could have more than one file open at the same time. Putting the - // files in this std::map will make the translationunit be reparsed - // from memory instead of from file. - tu.ReparseTranslationUnit(path, buffers); - - // zero is the start of the buffer - clang::SourceLocation start(&tu, path, 0); - - // the 129 value is arbitrary, you must set it to the size of your - // buffer (the number of chars in the buffer) - clang::SourceLocation end(&tu, path, 129); - - clang::SourceRange range(&start, &end); - clang::Tokens tokens(&tu, &range); - - // now tokens are stored in "tokens" we can extract ranges that are - // comments for instance - std::vector ranges; - for (auto &t : tokens.tokens()) { - if (t.kind() == clang::Token_Comment) { - ranges.emplace_back(&tu, &t); - } - } +### Quickstart ### +```sh +$ git clone https://github.com/cppit/libclangmm.git clangmm +$ cd clangmm +$ make +$ sudo make install ``` -For more examples see tests/ - # Tests # -To run tests simply do the following: +The compilation of the tests are disabled due to ease of installation. Simply enter CMakeList.txt and uncomment the last two lines in the file to enable testing. + +```sh +# enable_testing() +# add_subdirectory(tests) +``` +Then simply: ```sh $ cmake . $ make diff --git a/docs/install.md b/docs/install.md index 37e529e..d88931f 100644 --- a/docs/install.md +++ b/docs/install.md @@ -1,25 +1,13 @@ -# juCi++ -## Installation guide ## -## Linux -```sh -# Libraries -$ sudo apt-get install libboost-log-dev libclang-dev -# Programs -$sudo apt-get install make cmake gcc +# Installation guide # -``` -Compile +## Debian/Ubuntu ```sh -# When git clone -$ cd path-to-cloned-from-folder/jucipp/juci -# When download zipped file, extraxt it to a folder of your choice -$ cd path-to-folder-extraxted-into/jucipp-master/juci -# In both cases above you can choose remove the jucipp folder, but remeber to apply changes to cd command as well. -$ cmake . -$ make +$ sudo apt-get install libclang-dev make cmake gcc ``` -## Run ```sh -$ ./bin/juci +$ git clone https://github.com/cppit/libclangmm.git clangmm +$ cd clangmm +$ make +$ sudo make install ``` From c03d5fad198255d41eeb0a8b5e10c0ab815f014a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Thu, 30 Jul 2015 15:27:21 +0200 Subject: [PATCH 11/11] Update broken link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9851154..538864e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # libclangmm - An easy to use C++-wrapper for libclang # ## About ## -This is a highlevel wrapper for [libclang](http://www.llvm.com). It +This is a highlevel wrapper for [libclang](http://www.llvm.org). It provides highlevel C++11 access to complicated C code. ## Dependencies ##