Skip to content

Commit

Permalink
Merge pull request #224 from sabel83/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
sabel83 committed Nov 16, 2018
2 parents da6aab1 + a7cb84f commit 67e36ed
Show file tree
Hide file tree
Showing 309 changed files with 10,085 additions and 8,651 deletions.
2 changes: 2 additions & 0 deletions 3rd/boost/range/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ target_link_libraries(
${PROJECT_NAME}

INTERFACE
boost::array
boost::concept_check
boost::fusion
boost::iterator
boost::numeric_conversion
boost::regex
boost::utility
)
Expand Down
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,31 @@ add_subdirectory(test/system/pdb)
add_subdirectory(test/system/pp)
add_subdirectory(test/unit/core)
add_subdirectory(test/unit/data)
add_subdirectory(test/unit/engine/clang)
add_subdirectory(test/unit/engine/templight)
add_subdirectory(test/unit/engine/vc)
add_subdirectory(test/unit/main_shell)
add_subdirectory(test/unit/mdb)
add_subdirectory(test/unit/pragma)
add_subdirectory(test/unit/replace_part)
add_subdirectory(test/unit/system_test)

add_subdirectory(lib/boost)
add_subdirectory(lib/core)
add_subdirectory(lib/data)
add_subdirectory(lib/defaults)
add_subdirectory(lib/engine/clang)
add_subdirectory(lib/engine/constant)
add_subdirectory(lib/engine/gcc)
add_subdirectory(lib/engine/null)
add_subdirectory(lib/engine/templight)
add_subdirectory(lib/engine/vc)
add_subdirectory(lib/engine/wave)
add_subdirectory(lib/iface)
add_subdirectory(lib/main_shell)
add_subdirectory(lib/mdb)
add_subdirectory(lib/mock)
add_subdirectory(lib/pattern)
add_subdirectory(lib/pragma)
add_subdirectory(lib/process)
add_subdirectory(lib/readline)
add_subdirectory(lib/replace_part)
Expand Down
2 changes: 2 additions & 0 deletions app/metashell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ target_link_libraries(

metashell::core
metashell::data
metashell::defaults
metashell::iface
metashell::main_shell
metashell::readline
)

Expand Down
20 changes: 9 additions & 11 deletions app/metashell/console_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <metashell/core/console_displayer.hpp>
#include <metashell/core/json_displayer.hpp>
#include <metashell/core/json_line_reader.hpp>
#include <metashell/core/make_unique.hpp>
#include <metashell/core/null_history.hpp>
#include <metashell/core/rapid_json_writer.hpp>
#include <metashell/core/stdout_console.hpp>
Expand Down Expand Up @@ -57,9 +56,9 @@ namespace
switch (type_)
{
case data::console_type::plain:
return metashell::core::make_unique<core::stream_console>(std::cout);
return std::make_unique<core::stream_console>(std::cout);
case data::console_type::readline:
return core::make_unique<core::stdout_console>();
return std::make_unique<core::stdout_console>();
case data::console_type::json:
return nullptr;
}
Expand All @@ -76,7 +75,7 @@ namespace
case data::console_type::readline:
return nullptr;
case data::console_type::json:
return metashell::core::make_unique<core::rapid_json_writer>(std::cout);
return std::make_unique<core::rapid_json_writer>(std::cout);
}
return nullptr;
}
Expand All @@ -91,13 +90,12 @@ namespace
switch (type_)
{
case data::console_type::plain:
return core::make_unique<core::console_displayer>(
*console_, false, false);
return std::make_unique<core::console_displayer>(*console_, false, false);
case data::console_type::readline:
return core::make_unique<core::console_displayer>(
return std::make_unique<core::console_displayer>(
*console_, indent_, syntax_highlight_);
case data::console_type::json:
return core::make_unique<core::json_displayer>(*json_writer_);
return std::make_unique<core::json_displayer>(*json_writer_);
}
return nullptr;
}
Expand All @@ -107,11 +105,11 @@ namespace
switch (type_)
{
case data::console_type::plain:
return core::make_unique<core::null_history>();
return std::make_unique<core::null_history>();
case data::console_type::readline:
return core::make_unique<readline::history>();
return std::make_unique<readline::history>();
case data::console_type::json:
return core::make_unique<core::null_history>();
return std::make_unique<core::null_history>();
}
return nullptr;
}
Expand Down
16 changes: 10 additions & 6 deletions app/metashell/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@

#include "console_config.hpp"

#include <metashell/core/available_engines.hpp>
#include <metashell/defaults/available_engines.hpp>
#include <metashell/defaults/pragma_map.hpp>

#include <metashell/main_shell/shell.hpp>

#include <metashell/core/default_environment_detector.hpp>
#include <metashell/core/fstream_file_writer.hpp>
#include <metashell/core/input_loop.hpp>
#include <metashell/core/logger.hpp>
#include <metashell/core/make_unique.hpp>
#include <metashell/core/parse_config.hpp>
#include <metashell/core/shell.hpp>
#include <metashell/core/version.hpp>
#include <metashell/core/wave_tokeniser.hpp>

Expand Down Expand Up @@ -71,7 +73,7 @@ int main(int argc_, const char* argv_[])
using metashell::core::parse_config_result;

const std::map<std::string, metashell::core::engine_entry> engines =
metashell::core::available_engines();
metashell::defaults::available_engines();

metashell::core::default_environment_detector det(argv_[0]);

Expand Down Expand Up @@ -114,8 +116,8 @@ int main(int argc_, const char* argv_[])
create_directories(temp_dir);
create_directories(mdb_dir);

auto shell = metashell::core::make_unique<metashell::core::shell>(
r.cfg, ccfg.processor_queue(), shell_dir, env_filename, mdb_dir,
auto shell = std::make_unique<metashell::main_shell::shell>(
r.cfg, shell_dir, env_filename,
// The shell should be destroyed when this scope is left, capturing
// locals by reference should be safe.
[&engines, &shell_dir, &temp_dir, &env_filename, &det, &ccfg,
Expand All @@ -137,6 +139,8 @@ int main(int argc_, const char* argv_[])
&logger);
}
},
metashell::defaults::pragma_map(
&ccfg.processor_queue(), mdb_dir, &logger),
&logger);

if (r.cfg.splash_enabled)
Expand Down
2 changes: 2 additions & 0 deletions app/reference_gen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ target_link_libraries(

metashell::core
metashell::data
metashell::defaults
metashell::mdb
metashell::replace_part
)

Expand Down
37 changes: 17 additions & 20 deletions app/reference_gen/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@

#include <metashell/data/markdown_string.hpp>

#include <metashell/core/available_engines.hpp>
#include <metashell/core/engine_constant.hpp>
#include <metashell/core/mdb_command_handler_map.hpp>
#include <metashell/core/mdb_shell.hpp>
#include <metashell/core/pragma_handler_map.hpp>
#include <metashell/core/shell.hpp>
#include <metashell/defaults/available_engines.hpp>
#include <metashell/defaults/pragma_map.hpp>

#include <metashell/mdb/command_handler_map.hpp>
#include <metashell/mdb/shell.hpp>

#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>

#include <cassert>
#include <iostream>

namespace
{
void show_markdown(const std::vector<std::string>& name_,
const metashell::core::pragma_handler& h_,
const metashell::iface::pragma_handler& h_,
std::ostream& out_)
{
using boost::algorithm::join;
Expand All @@ -53,15 +53,12 @@ namespace
metashell::core::command_processor_queue cpq;
const std::string internal_dir;
const boost::filesystem::path mdb_temp_dir;
metashell::core::shell sh(cfg, cpq, internal_dir, "", mdb_temp_dir,
metashell::core::create_failing_engine());
const metashell::core::pragma_handler_map m =
metashell::core::pragma_handler_map::build_default(
sh, &cpq, mdb_temp_dir, nullptr);

for (const auto& p : m)
for (const auto& p :
metashell::defaults::pragma_map(&cpq, mdb_temp_dir, nullptr))
{
show_markdown(p.first, p.second, out_);
assert(p.second);

show_markdown(p.first, *p.second, out_);
}
}

Expand All @@ -71,11 +68,11 @@ namespace
using boost::algorithm::join;
using boost::algorithm::replace_all_copy;

metashell::core::mdb_command_handler_map::commands_t commands =
metashell::core::mdb_shell::build_command_handler(Preprocessor)
metashell::mdb::command_handler_map::commands_t commands =
metashell::mdb::shell::build_command_handler(Preprocessor)
.get_commands();

for (const metashell::core::mdb_command& cmd : commands)
for (const metashell::mdb::command& cmd : commands)
{
out_ << "* __`" << join(cmd.get_keys(), "|") << " " << cmd.get_usage()
<< "`__ <br />\n"
Expand All @@ -91,7 +88,7 @@ namespace

void show_engine_help(std::ostream& out_)
{
const auto engines = metashell::core::available_engines();
const auto engines = metashell::defaults::available_engines();

for (const auto& engine : engines)
{
Expand All @@ -110,7 +107,7 @@ namespace

void show_engine_features(std::ostream& out_)
{
const auto engines = metashell::core::available_engines();
const auto engines = metashell::defaults::available_engines();
const auto features = metashell::data::feature::all();

std::vector<metashell::data::markdown_string> header{
Expand Down

0 comments on commit 67e36ed

Please sign in to comment.