From 695048baa7c971a721ff73bcf1c62c48ec3963e8 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Sat, 25 Mar 2017 13:15:00 -0700 Subject: [PATCH] move code into src --- bitfield.h | 184 ------------------ doctest_impl.cc | 2 - src/buffer.cc | 2 +- command_line.cc => src/command_line.cc | 10 +- .../compilation_database_loader.cc | 0 .../compilation_database_loader.h | 0 src/doctest_impl.cc | 2 + indexer.cpp => src/indexer.cpp | 0 indexer.h => src/indexer.h | 1 - .../language_server_api.h | 0 .../libclangmm}/CMakeListfs.txt | 0 .../libclangmm}/CodeCompleteResults.cc | 0 .../libclangmm}/CodeCompleteResults.h | 0 .../libclangmm}/CompletionString.cc | 0 .../libclangmm}/CompletionString.h | 0 {libclangmm => src/libclangmm}/Cursor.cc | 0 {libclangmm => src/libclangmm}/Cursor.h | 0 {libclangmm => src/libclangmm}/Diagnostic.cc | 0 {libclangmm => src/libclangmm}/Diagnostic.h | 0 {libclangmm => src/libclangmm}/Index.cc | 0 {libclangmm => src/libclangmm}/Index.h | 0 {libclangmm => src/libclangmm}/SourceRange.cc | 0 {libclangmm => src/libclangmm}/SourceRange.h | 0 {libclangmm => src/libclangmm}/Token.cc | 0 {libclangmm => src/libclangmm}/Token.h | 0 {libclangmm => src/libclangmm}/Tokens.cc | 0 {libclangmm => src/libclangmm}/Tokens.h | 0 .../libclangmm}/TranslationUnit.cc | 0 .../libclangmm}/TranslationUnit.h | 0 {libclangmm => src/libclangmm}/Utility.cc | 0 {libclangmm => src/libclangmm}/Utility.h | 0 {libclangmm => src/libclangmm}/clangmm.h | 0 src/message_queue.cc | 2 +- optional.h => src/optional.h | 0 src/platform_linux.cc | 2 +- src/platform_win.cc | 2 +- query.cc => src/query.cc | 0 query.h => src/query.h | 0 serializer.cc => src/serializer.cc | 0 serializer.h => src/serializer.h | 0 test.cc => src/test.cc | 2 +- test.h => src/test.h | 0 src/threaded_queue.h | 2 +- src/typed_bidi_message_queue.h | 2 +- utils.cc => src/utils.cc | 2 +- utils.h => src/utils.h | 0 46 files changed, 15 insertions(+), 200 deletions(-) delete mode 100644 bitfield.h delete mode 100644 doctest_impl.cc rename command_line.cc => src/command_line.cc (99%) rename compilation_database_loader.cc => src/compilation_database_loader.cc (100%) rename compilation_database_loader.h => src/compilation_database_loader.h (100%) create mode 100644 src/doctest_impl.cc rename indexer.cpp => src/indexer.cpp (100%) rename indexer.h => src/indexer.h (99%) rename language_server_api.h => src/language_server_api.h (100%) rename {libclangmm => src/libclangmm}/CMakeListfs.txt (100%) rename {libclangmm => src/libclangmm}/CodeCompleteResults.cc (100%) rename {libclangmm => src/libclangmm}/CodeCompleteResults.h (100%) rename {libclangmm => src/libclangmm}/CompletionString.cc (100%) rename {libclangmm => src/libclangmm}/CompletionString.h (100%) rename {libclangmm => src/libclangmm}/Cursor.cc (100%) rename {libclangmm => src/libclangmm}/Cursor.h (100%) rename {libclangmm => src/libclangmm}/Diagnostic.cc (100%) rename {libclangmm => src/libclangmm}/Diagnostic.h (100%) rename {libclangmm => src/libclangmm}/Index.cc (100%) rename {libclangmm => src/libclangmm}/Index.h (100%) rename {libclangmm => src/libclangmm}/SourceRange.cc (100%) rename {libclangmm => src/libclangmm}/SourceRange.h (100%) rename {libclangmm => src/libclangmm}/Token.cc (100%) rename {libclangmm => src/libclangmm}/Token.h (100%) rename {libclangmm => src/libclangmm}/Tokens.cc (100%) rename {libclangmm => src/libclangmm}/Tokens.h (100%) rename {libclangmm => src/libclangmm}/TranslationUnit.cc (100%) rename {libclangmm => src/libclangmm}/TranslationUnit.h (100%) rename {libclangmm => src/libclangmm}/Utility.cc (100%) rename {libclangmm => src/libclangmm}/Utility.h (100%) rename {libclangmm => src/libclangmm}/clangmm.h (100%) rename optional.h => src/optional.h (100%) rename query.cc => src/query.cc (100%) rename query.h => src/query.h (100%) rename serializer.cc => src/serializer.cc (100%) rename serializer.h => src/serializer.h (100%) rename test.cc => src/test.cc (99%) rename test.h => src/test.h (100%) rename utils.cc => src/utils.cc (98%) rename utils.h => src/utils.h (100%) diff --git a/bitfield.h b/bitfield.h deleted file mode 100644 index 86f60132..00000000 --- a/bitfield.h +++ /dev/null @@ -1,184 +0,0 @@ -//--------------------------------------------------------- -// For conditions of distribution and use, see -// https://github.com/preshing/cpp11-on-multicore/blob/master/LICENSE -//--------------------------------------------------------- - -#ifndef __CPP11OM_BITFIELD_H__ -#define __CPP11OM_BITFIELD_H__ - -#include - - -//--------------------------------------------------------- -// BitFieldMember<>: Used internally by ADD_BITFIELD_MEMBER macro. -// All members are public to simplify compliance with sections 9.0.7 and -// 9.5.1 of the C++11 standard, thereby avoiding undefined behavior. -//--------------------------------------------------------- -template -struct BitFieldMember -{ - T value; - - static_assert(Offset + Bits <= (int) sizeof(T) * 8, "Member exceeds bitfield boundaries"); - static_assert(Bits < (int) sizeof(T) * 8, "Can't fill entire bitfield with one member"); - - static const T Maximum = (T(1) << Bits) - 1; - static const T Mask = Maximum << Offset; - T maximum() const { return Maximum; } - T one() const { return T(1) << Offset; } - - operator T() const - { - return (value >> Offset) & Maximum; - } - - BitFieldMember& operator=(T v) - { - assert(v <= Maximum); // v must fit inside the bitfield member - value = (value & ~Mask) | (v << Offset); - return *this; - } - - BitFieldMember& operator+=(T v) - { - assert(T(*this) + v <= Maximum); // result must fit inside the bitfield member - value += v << Offset; - return *this; - } - - BitFieldMember& operator-=(T v) - { - assert(T(*this) >= v); // result must not underflow - value -= v << Offset; - return *this; - } - - BitFieldMember& operator++() { return *this += 1; } - BitFieldMember operator++(int) // postfix form - { - BitFieldMember tmp(*this); - operator++(); - return tmp; - } - BitFieldMember& operator--() { return *this -= 1; } - BitFieldMember operator--(int) // postfix form - { - BitFieldMember tmp(*this); - operator--(); - return tmp; - } -}; - - -//--------------------------------------------------------- -// BitFieldArray<>: Used internally by ADD_BITFIELD_ARRAY macro. -// All members are public to simplify compliance with sections 9.0.7 and -// 9.5.1 of the C++11 standard, thereby avoiding undefined behavior. -//--------------------------------------------------------- -template -struct BitFieldArray -{ - T value; - - static_assert(BaseOffset + BitsPerItem * NumItems <= (int) sizeof(T) * 8, "Array exceeds bitfield boundaries"); - static_assert(BitsPerItem < (int) sizeof(T) * 8, "Can't fill entire bitfield with one array element"); - - static const T Maximum = (T(1) << BitsPerItem) - 1; - T maximum() const { return Maximum; } - int numItems() const { return NumItems; } - - class Element - { - private: - T& value; - int offset; - - public: - Element(T& value, int offset) : value(value), offset(offset) {} - T mask() const { return Maximum << offset; } - - operator T() const - { - return (value >> offset) & Maximum; - } - - Element& operator=(T v) - { - assert(v <= Maximum); // v must fit inside the bitfield member - value = (value & ~mask()) | (v << offset); - return *this; - } - - Element& operator+=(T v) - { - assert(T(*this) + v <= Maximum); // result must fit inside the bitfield member - value += v << offset; - return *this; - } - - Element& operator-=(T v) - { - assert(T(*this) >= v); // result must not underflow - value -= v << offset; - return *this; - } - - Element& operator++() { return *this += 1; } - Element operator++(int) // postfix form - { - Element tmp(*this); - operator++(); - return tmp; - } - Element& operator--() { return *this -= 1; } - Element operator--(int) // postfix form - { - Element tmp(*this); - operator--(); - return tmp; - } - }; - - Element operator[](int i) - { - assert(i >= 0 && i < NumItems); // array index must be in range - return Element(value, BaseOffset + BitsPerItem * i); - } - - const Element operator[](int i) const - { - assert(i >= 0 && i < NumItems); // array index must be in range - return Element(value, BaseOffset + BitsPerItem * i); - } -}; - - -//--------------------------------------------------------- -// Bitfield definition macros. -// For usage examples, see RWLock and LockReducedDiningPhilosophers. -// All members are public to simplify compliance with sections 9.0.7 and -// 9.5.1 of the C++11 standard, thereby avoiding undefined behavior. -//--------------------------------------------------------- -#define BEGIN_BITFIELD_TYPE(typeName, T) \ - union typeName \ - { \ - struct Wrapper { T value; }; \ - Wrapper wrapper; \ - typeName(T v = 0) { wrapper.value = v; } \ - typeName& operator=(T v) { wrapper.value = v; return *this; } \ - operator T&() { return wrapper.value; } \ - operator T() const { return wrapper.value; } \ - typedef T StorageType; - -#define ADD_BITFIELD_MEMBER(memberName, offset, bits) \ - BitFieldMember memberName; - -#define ADD_BITFIELD_ARRAY(memberName, offset, bits, numItems) \ - BitFieldArray memberName; - -#define END_BITFIELD_TYPE() \ - }; - - -#endif // __CPP11OM_BITFIELD_H__ - diff --git a/doctest_impl.cc b/doctest_impl.cc deleted file mode 100644 index 132c1b2e..00000000 --- a/doctest_impl.cc +++ /dev/null @@ -1,2 +0,0 @@ -#define DOCTEST_CONFIG_IMPLEMENT -#include "third_party/doctest/doctest/doctest.h" \ No newline at end of file diff --git a/src/buffer.cc b/src/buffer.cc index 98b01700..a5661688 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -5,7 +5,7 @@ #include #include "platform.h" -#include "../utils.h" +#include "utils.h" #include "../third_party/doctest/doctest/doctest.h" namespace { diff --git a/command_line.cc b/src/command_line.cc similarity index 99% rename from command_line.cc rename to src/command_line.cc index 82c8c9f6..5cd2f4b4 100644 --- a/command_line.cc +++ b/src/command_line.cc @@ -4,17 +4,17 @@ #include #include +// TODO: cleanup includes #include "compilation_database_loader.h" #include "indexer.h" #include "query.h" #include "language_server_api.h" #include "test.h" +#include "timer.h" +#include "threaded_queue.h" +#include "typed_bidi_message_queue.h" -#include "src/timer.h" -#include "src/threaded_queue.h" -#include "src/typed_bidi_message_queue.h" - -#include "third_party/doctest/doctest/doctest.h" +#include "../third_party/doctest/doctest/doctest.h" #include #include diff --git a/compilation_database_loader.cc b/src/compilation_database_loader.cc similarity index 100% rename from compilation_database_loader.cc rename to src/compilation_database_loader.cc diff --git a/compilation_database_loader.h b/src/compilation_database_loader.h similarity index 100% rename from compilation_database_loader.h rename to src/compilation_database_loader.h diff --git a/src/doctest_impl.cc b/src/doctest_impl.cc new file mode 100644 index 00000000..fb4ce8af --- /dev/null +++ b/src/doctest_impl.cc @@ -0,0 +1,2 @@ +#define DOCTEST_CONFIG_IMPLEMENT +#include "../third_party/doctest/doctest/doctest.h" \ No newline at end of file diff --git a/indexer.cpp b/src/indexer.cpp similarity index 100% rename from indexer.cpp rename to src/indexer.cpp diff --git a/indexer.h b/src/indexer.h similarity index 99% rename from indexer.h rename to src/indexer.h index caaac345..0b8dc02c 100644 --- a/indexer.h +++ b/src/indexer.h @@ -10,7 +10,6 @@ #include "libclangmm/clangmm.h" #include "libclangmm/Utility.h" -#include "bitfield.h" #include "utils.h" #include "optional.h" #include "serializer.h" diff --git a/language_server_api.h b/src/language_server_api.h similarity index 100% rename from language_server_api.h rename to src/language_server_api.h diff --git a/libclangmm/CMakeListfs.txt b/src/libclangmm/CMakeListfs.txt similarity index 100% rename from libclangmm/CMakeListfs.txt rename to src/libclangmm/CMakeListfs.txt diff --git a/libclangmm/CodeCompleteResults.cc b/src/libclangmm/CodeCompleteResults.cc similarity index 100% rename from libclangmm/CodeCompleteResults.cc rename to src/libclangmm/CodeCompleteResults.cc diff --git a/libclangmm/CodeCompleteResults.h b/src/libclangmm/CodeCompleteResults.h similarity index 100% rename from libclangmm/CodeCompleteResults.h rename to src/libclangmm/CodeCompleteResults.h diff --git a/libclangmm/CompletionString.cc b/src/libclangmm/CompletionString.cc similarity index 100% rename from libclangmm/CompletionString.cc rename to src/libclangmm/CompletionString.cc diff --git a/libclangmm/CompletionString.h b/src/libclangmm/CompletionString.h similarity index 100% rename from libclangmm/CompletionString.h rename to src/libclangmm/CompletionString.h diff --git a/libclangmm/Cursor.cc b/src/libclangmm/Cursor.cc similarity index 100% rename from libclangmm/Cursor.cc rename to src/libclangmm/Cursor.cc diff --git a/libclangmm/Cursor.h b/src/libclangmm/Cursor.h similarity index 100% rename from libclangmm/Cursor.h rename to src/libclangmm/Cursor.h diff --git a/libclangmm/Diagnostic.cc b/src/libclangmm/Diagnostic.cc similarity index 100% rename from libclangmm/Diagnostic.cc rename to src/libclangmm/Diagnostic.cc diff --git a/libclangmm/Diagnostic.h b/src/libclangmm/Diagnostic.h similarity index 100% rename from libclangmm/Diagnostic.h rename to src/libclangmm/Diagnostic.h diff --git a/libclangmm/Index.cc b/src/libclangmm/Index.cc similarity index 100% rename from libclangmm/Index.cc rename to src/libclangmm/Index.cc diff --git a/libclangmm/Index.h b/src/libclangmm/Index.h similarity index 100% rename from libclangmm/Index.h rename to src/libclangmm/Index.h diff --git a/libclangmm/SourceRange.cc b/src/libclangmm/SourceRange.cc similarity index 100% rename from libclangmm/SourceRange.cc rename to src/libclangmm/SourceRange.cc diff --git a/libclangmm/SourceRange.h b/src/libclangmm/SourceRange.h similarity index 100% rename from libclangmm/SourceRange.h rename to src/libclangmm/SourceRange.h diff --git a/libclangmm/Token.cc b/src/libclangmm/Token.cc similarity index 100% rename from libclangmm/Token.cc rename to src/libclangmm/Token.cc diff --git a/libclangmm/Token.h b/src/libclangmm/Token.h similarity index 100% rename from libclangmm/Token.h rename to src/libclangmm/Token.h diff --git a/libclangmm/Tokens.cc b/src/libclangmm/Tokens.cc similarity index 100% rename from libclangmm/Tokens.cc rename to src/libclangmm/Tokens.cc diff --git a/libclangmm/Tokens.h b/src/libclangmm/Tokens.h similarity index 100% rename from libclangmm/Tokens.h rename to src/libclangmm/Tokens.h diff --git a/libclangmm/TranslationUnit.cc b/src/libclangmm/TranslationUnit.cc similarity index 100% rename from libclangmm/TranslationUnit.cc rename to src/libclangmm/TranslationUnit.cc diff --git a/libclangmm/TranslationUnit.h b/src/libclangmm/TranslationUnit.h similarity index 100% rename from libclangmm/TranslationUnit.h rename to src/libclangmm/TranslationUnit.h diff --git a/libclangmm/Utility.cc b/src/libclangmm/Utility.cc similarity index 100% rename from libclangmm/Utility.cc rename to src/libclangmm/Utility.cc diff --git a/libclangmm/Utility.h b/src/libclangmm/Utility.h similarity index 100% rename from libclangmm/Utility.h rename to src/libclangmm/Utility.h diff --git a/libclangmm/clangmm.h b/src/libclangmm/clangmm.h similarity index 100% rename from libclangmm/clangmm.h rename to src/libclangmm/clangmm.h diff --git a/src/message_queue.cc b/src/message_queue.cc index b6f62a11..29835ba4 100644 --- a/src/message_queue.cc +++ b/src/message_queue.cc @@ -7,7 +7,7 @@ #include "platform.h" #include "resizable_buffer.h" -#include "../utils.h" +#include "utils.h" #include "../third_party/doctest/doctest/doctest.h" // TODO: figure out a logging solution diff --git a/optional.h b/src/optional.h similarity index 100% rename from optional.h rename to src/optional.h diff --git a/src/platform_linux.cc b/src/platform_linux.cc index 8b556c08..3b948741 100644 --- a/src/platform_linux.cc +++ b/src/platform_linux.cc @@ -1,7 +1,7 @@ #if defined(__linux__) || defined(__APPLE__) #include "platform.h" -#include "../utils.h" +#include "utils.h" #include #include diff --git a/src/platform_win.cc b/src/platform_win.cc index db99671d..53b2da3f 100644 --- a/src/platform_win.cc +++ b/src/platform_win.cc @@ -6,7 +6,7 @@ #include #include -#include "../utils.h" +#include "utils.h" namespace { diff --git a/query.cc b/src/query.cc similarity index 100% rename from query.cc rename to src/query.cc diff --git a/query.h b/src/query.h similarity index 100% rename from query.h rename to src/query.h diff --git a/serializer.cc b/src/serializer.cc similarity index 100% rename from serializer.cc rename to src/serializer.cc diff --git a/serializer.h b/src/serializer.h similarity index 100% rename from serializer.h rename to src/serializer.h diff --git a/test.cc b/src/test.cc similarity index 99% rename from test.cc rename to src/test.cc index c19fea7d..1d811ff8 100644 --- a/test.cc +++ b/src/test.cc @@ -1,9 +1,9 @@ #include "test.h" #include "indexer.h" +#include "platform.h" #include "serializer.h" #include "utils.h" -#include "src/platform.h" void Write(const std::vector& strs) { for (const std::string& str : strs) diff --git a/test.h b/src/test.h similarity index 100% rename from test.h rename to src/test.h diff --git a/src/threaded_queue.h b/src/threaded_queue.h index 845df3e1..b5c74fd0 100644 --- a/src/threaded_queue.h +++ b/src/threaded_queue.h @@ -6,7 +6,7 @@ #include #include -#include "../optional.h" +#include "optional.h" // A threadsafe-queue. http://stackoverflow.com/a/16075550 template diff --git a/src/typed_bidi_message_queue.h b/src/typed_bidi_message_queue.h index e6626e01..18f5dd9d 100644 --- a/src/typed_bidi_message_queue.h +++ b/src/typed_bidi_message_queue.h @@ -6,7 +6,7 @@ #include "buffer.h" #include "message_queue.h" -#include "../serializer.h" +#include "serializer.h" // TypedBidiMessageQueue provides a type-safe server/client implementation on // top of a couple MessageQueue instances. diff --git a/utils.cc b/src/utils.cc similarity index 98% rename from utils.cc rename to src/utils.cc index 08369655..7b42946a 100644 --- a/utils.cc +++ b/src/utils.cc @@ -4,7 +4,7 @@ #include #include -#include "tinydir.h" +#include "../third_party/tinydir.h" static std::vector GetFilesInFolderHelper(std::string folder, bool recursive, std::string output_prefix) { std::vector result; diff --git a/utils.h b/src/utils.h similarity index 100% rename from utils.h rename to src/utils.h