From 57a1a7e20db84f34a762c644033bd14290bbf60a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 26 Jun 2016 13:24:19 +0100 Subject: Optionally allow Ice prefix --- slicer/slicer/parser.cpp | 12 ++++++------ slicer/slicer/parser.h | 4 ++-- slicer/test/preprocessor.cpp | 6 +++--- slicer/tool/slicer.cpp | 4 +++- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/slicer/slicer/parser.cpp b/slicer/slicer/parser.cpp index 787f9e7..15c6afd 100644 --- a/slicer/slicer/parser.cpp +++ b/slicer/slicer/parser.cpp @@ -559,28 +559,28 @@ namespace Slicer { unsigned int Slicer::Apply(const boost::filesystem::path & ice, const boost::filesystem::path & cpp) { - return Apply(ice, cpp, {}); + return Apply(ice, cpp, {}, false); } unsigned int - Slicer::Apply(const boost::filesystem::path & ice, const boost::filesystem::path & cpp, const Args & args) + Slicer::Apply(const boost::filesystem::path & ice, const boost::filesystem::path & cpp, const Args & args, bool allowIcePrefix) { FilePtr cppfile(fopen(cpp.string(), "a"), fclose); if (!cppfile) { throw std::runtime_error("failed to open code file"); } - return Apply(ice, cppfile.get(), args); + return Apply(ice, cppfile.get(), args, allowIcePrefix); } unsigned int Slicer::Apply(const boost::filesystem::path & ice, FILE * cpp) { - return Apply(ice, cpp, {}); + return Apply(ice, cpp, {}, false); } unsigned int - Slicer::Apply(const boost::filesystem::path & ice, FILE * cpp, const Args & args) + Slicer::Apply(const boost::filesystem::path & ice, FILE * cpp, const Args & args, bool allowIcePrefix) { std::lock_guard lock(slicePreprocessor); Slice::PreprocessorPtr icecpp = Slice::Preprocessor::create("slicer", ice.string(), args); @@ -590,7 +590,7 @@ namespace Slicer { throw std::runtime_error("preprocess failed"); } - Slice::UnitPtr u = Slice::Unit::createUnit(false, false, false, false); + Slice::UnitPtr u = Slice::Unit::createUnit(false, false, allowIcePrefix, false); int parseStatus = u->parse(ice.string(), cppHandle, false); diff --git a/slicer/slicer/parser.h b/slicer/slicer/parser.h index f6a7809..1193664 100644 --- a/slicer/slicer/parser.h +++ b/slicer/slicer/parser.h @@ -27,8 +27,8 @@ namespace Slicer { static unsigned int Apply(const boost::filesystem::path & ice, const boost::filesystem::path & cpp); static unsigned int Apply(const boost::filesystem::path & ice, FILE *); - static unsigned int Apply(const boost::filesystem::path & ice, const boost::filesystem::path & cpp, const Args &); - static unsigned int Apply(const boost::filesystem::path & ice, FILE *, const Args &); + static unsigned int Apply(const boost::filesystem::path & ice, const boost::filesystem::path & cpp, const Args &, bool); + static unsigned int Apply(const boost::filesystem::path & ice, FILE *, const Args &, bool); unsigned int Components() const; diff --git a/slicer/test/preprocessor.cpp b/slicer/test/preprocessor.cpp index 99d1ab4..43a04fd 100644 --- a/slicer/test/preprocessor.cpp +++ b/slicer/test/preprocessor.cpp @@ -19,7 +19,7 @@ BOOST_FIXTURE_TEST_SUITE ( preprocessor, FileStructure ); BOOST_AUTO_TEST_CASE( slicer_test_counts_path ) { - auto count = Slicer::Slicer::Apply(slice, boost::filesystem::path("/dev/null"), {"-I" + included.string()}); + auto count = Slicer::Slicer::Apply(slice, boost::filesystem::path("/dev/null"), {"-I" + included.string()}, false); BOOST_REQUIRE_EQUAL(COMPONENTS_IN_TEST_ICE, count); } @@ -28,7 +28,7 @@ BOOST_AUTO_TEST_CASE( slicer_test_counts_filestar ) FILE * file = fopen("/dev/null", "a"); BOOST_REQUIRE(file); - auto count = Slicer::Slicer::Apply(slice, file, {"-I" + included.string()}); + auto count = Slicer::Slicer::Apply(slice, file, {"-I" + included.string()}, false); BOOST_REQUIRE_EQUAL(COMPONENTS_IN_TEST_ICE, count); fclose(file); @@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE( slicer_test_counts_filestar ) BOOST_AUTO_TEST_CASE( slicer_test_counts_nullfilestar ) { - auto count = Slicer::Slicer::Apply(slice, NULL, {"-I" + included.string()}); + auto count = Slicer::Slicer::Apply(slice, NULL, {"-I" + included.string()}, false); BOOST_REQUIRE_EQUAL(COMPONENTS_IN_TEST_ICE, count); } diff --git a/slicer/tool/slicer.cpp b/slicer/tool/slicer.cpp index b202642..632ae03 100644 --- a/slicer/tool/slicer.cpp +++ b/slicer/tool/slicer.cpp @@ -9,11 +9,13 @@ main(int argc, char ** argv) boost::filesystem::path slice; boost::filesystem::path cpp; std::vector includes; + bool allowIcePrefix; po::options_description opts("Slicer options"); opts.add_options() ("help,h", "Show this help message") ("include,I", po::value(&includes), "Add include directory to search path") + ("ice", po::value(&allowIcePrefix)->default_value(false)->zero_tokens(), "Allow reserved Ice prefix in Slice identifiers") ("slice,i", po::value(&slice), "Input ICE Slice file") ("cpp,o", po::value(&cpp), "Output C++ file"); @@ -35,7 +37,7 @@ main(int argc, char ** argv) for(const auto & include : includes) { args.push_back("-I" + include.string()); } - Slicer::Slicer::Apply(slice, cpp, args); + Slicer::Slicer::Apply(slice, cpp, args, allowIcePrefix); return 0; } -- cgit v1.2.3