diff options
author | Mu Qiao <qiaomuf@gentoo.org> | 2011-06-14 16:59:32 +0800 |
---|---|---|
committer | Petteri Räty <petsku@petteriraty.eu> | 2011-06-14 15:58:27 +0300 |
commit | 26c12581f3d21fb2dadd0f6052f204e26305ed23 (patch) | |
tree | 07f352191620eb09b7633bb31f6b822ec1c5ad81 /src/builtins | |
parent | Parser: Support redirection for all kinds of commands (diff) | |
download | libbash-26c12581f3d21fb2dadd0f6052f204e26305ed23.tar.gz libbash-26c12581f3d21fb2dadd0f6052f204e26305ed23.tar.bz2 libbash-26c12581f3d21fb2dadd0f6052f204e26305ed23.zip |
Core: add namespace for interpreter_exception
The interpreter_exception is part of our public API so we put it under
libbash namespace.
Diffstat (limited to 'src/builtins')
-rw-r--r-- | src/builtins/builtin_exceptions.h | 2 | ||||
-rw-r--r-- | src/builtins/continue_builtin.cpp | 4 | ||||
-rw-r--r-- | src/builtins/declare_builtin.cpp | 2 | ||||
-rw-r--r-- | src/builtins/printf_builtin.cpp | 4 | ||||
-rw-r--r-- | src/builtins/return_builtin.cpp | 2 | ||||
-rw-r--r-- | src/builtins/shopt_builtin.cpp | 8 | ||||
-rw-r--r-- | src/builtins/source_builtin.cpp | 2 | ||||
-rw-r--r-- | src/builtins/tests/continue_tests.cpp | 8 | ||||
-rw-r--r-- | src/builtins/tests/printf_tests.cpp | 2 | ||||
-rw-r--r-- | src/builtins/tests/return_tests.cpp | 2 | ||||
-rw-r--r-- | src/builtins/tests/shopt_tests.cpp | 2 | ||||
-rw-r--r-- | src/builtins/tests/source_tests.cpp | 4 |
12 files changed, 21 insertions, 21 deletions
diff --git a/src/builtins/builtin_exceptions.h b/src/builtins/builtin_exceptions.h index 3da6de8..c20ce4c 100644 --- a/src/builtins/builtin_exceptions.h +++ b/src/builtins/builtin_exceptions.h @@ -46,7 +46,7 @@ public: explicit continue_exception(int c): count(c) { if(c < 1) - throw interpreter_exception("continue: argument should be greater than or equal to 1"); + throw libbash::interpreter_exception("continue: argument should be greater than or equal to 1"); } void rethrow_unless_correct_frame() diff --git a/src/builtins/continue_builtin.cpp b/src/builtins/continue_builtin.cpp index 03d79a2..6390e96 100644 --- a/src/builtins/continue_builtin.cpp +++ b/src/builtins/continue_builtin.cpp @@ -33,7 +33,7 @@ int continue_builtin::exec(const std::vector<std::string>& bash_args) if(bash_args.size() > 1) { - throw interpreter_exception("continue: too many arguments"); + throw libbash::interpreter_exception("continue: too many arguments"); } else if(bash_args.size() == 1) { @@ -43,7 +43,7 @@ int continue_builtin::exec(const std::vector<std::string>& bash_args) } catch(boost::bad_lexical_cast& e) { - throw interpreter_exception("continue: argument should be an integer"); + throw libbash::interpreter_exception("continue: argument should be an integer"); } } diff --git a/src/builtins/declare_builtin.cpp b/src/builtins/declare_builtin.cpp index cccbb9d..bc03930 100644 --- a/src/builtins/declare_builtin.cpp +++ b/src/builtins/declare_builtin.cpp @@ -92,7 +92,7 @@ int declare_builtin::exec(const std::vector<std::string>& bash_args) } else { - throw interpreter_exception("We do not support declare -p without arguments for now"); + throw libbash::interpreter_exception("We do not support declare -p without arguments for now"); } return result; case 'a': diff --git a/src/builtins/printf_builtin.cpp b/src/builtins/printf_builtin.cpp index c365863..8b3842c 100644 --- a/src/builtins/printf_builtin.cpp +++ b/src/builtins/printf_builtin.cpp @@ -34,7 +34,7 @@ int printf_builtin::exec(const std::vector<std::string>& bash_args) if(!(bash_args[0] == "-v")) begin = bash_args.begin(); else if(bash_args.size() < 3) - throw interpreter_exception("printf: illegal number of arguments"); + throw libbash::interpreter_exception("printf: illegal number of arguments"); else begin = bash_args.begin() + 2; @@ -56,7 +56,7 @@ int printf_builtin::exec(const std::vector<std::string>& bash_args) } else { - throw interpreter_exception("printf: invalid option: " + bash_args[0]); + throw libbash::interpreter_exception("printf: invalid option: " + bash_args[0]); } return 0; diff --git a/src/builtins/return_builtin.cpp b/src/builtins/return_builtin.cpp index 161e530..8c0bb32 100644 --- a/src/builtins/return_builtin.cpp +++ b/src/builtins/return_builtin.cpp @@ -30,7 +30,7 @@ int return_builtin::exec(const std::vector<std::string>& bash_args) { if(bash_args.size() > 1) - throw interpreter_exception("return: too many arguments"); + throw libbash::interpreter_exception("return: too many arguments"); else if(bash_args.size() == 1) _walker.set_status(boost::lexical_cast<int>(bash_args[0])); diff --git a/src/builtins/shopt_builtin.cpp b/src/builtins/shopt_builtin.cpp index 5c2e23d..1cd087c 100644 --- a/src/builtins/shopt_builtin.cpp +++ b/src/builtins/shopt_builtin.cpp @@ -42,9 +42,9 @@ void shopt_builtin::print_opts() const int shopt_builtin::exec(const std::vector<std::string>& bash_args) { if(bash_args.empty()) - throw interpreter_exception("Arguments required for shopt"); + throw libbash::interpreter_exception("Arguments required for shopt"); else if(bash_args[0].size() != 2) - throw interpreter_exception("Multiple arguments are not supported"); + throw libbash::interpreter_exception("Multiple arguments are not supported"); switch(bash_args[0][1]) { @@ -59,9 +59,9 @@ int shopt_builtin::exec(const std::vector<std::string>& bash_args) break; case 'q': case 'o': - throw interpreter_exception("shopt " + bash_args[0] + " is not supported yet"); + throw libbash::interpreter_exception("shopt " + bash_args[0] + " is not supported yet"); default: - throw interpreter_exception("Unrecognized option for shopt: " + bash_args[0]); + throw libbash::interpreter_exception("Unrecognized option for shopt: " + bash_args[0]); } return 0; diff --git a/src/builtins/source_builtin.cpp b/src/builtins/source_builtin.cpp index 6d43463..8a1838b 100644 --- a/src/builtins/source_builtin.cpp +++ b/src/builtins/source_builtin.cpp @@ -39,7 +39,7 @@ int source_builtin::exec(const std::vector<std::string>& bash_args) static std::unordered_map<std::string, std::shared_ptr<bash_ast>> ast_cache; if(bash_args.size() == 0) - throw interpreter_exception("should provide one argument for source builtin"); + throw libbash::interpreter_exception("should provide one argument for source builtin"); // we need fix this to pass extra arguments as positional parameters const std::string& path = bash_args[0]; diff --git a/src/builtins/tests/continue_tests.cpp b/src/builtins/tests/continue_tests.cpp index 4a8d67c..f6edef6 100644 --- a/src/builtins/tests/continue_tests.cpp +++ b/src/builtins/tests/continue_tests.cpp @@ -30,10 +30,10 @@ TEST(continue_builtin_test, bad_argument) { interpreter walker; - EXPECT_THROW(cppbash_builtin::exec("continue", {"abc"}, std::cout, std::cerr, std::cin, walker), interpreter_exception); - EXPECT_THROW(cppbash_builtin::exec("continue", {"1", "2"}, std::cout, std::cerr, std::cin, walker), interpreter_exception); - EXPECT_THROW(cppbash_builtin::exec("continue", {"0"}, std::cout, std::cerr, std::cin, walker), interpreter_exception); - EXPECT_THROW(cppbash_builtin::exec("continue", {"-1"}, std::cout, std::cerr, std::cin, walker), interpreter_exception); + EXPECT_THROW(cppbash_builtin::exec("continue", {"abc"}, std::cout, std::cerr, std::cin, walker), libbash::interpreter_exception); + EXPECT_THROW(cppbash_builtin::exec("continue", {"1", "2"}, std::cout, std::cerr, std::cin, walker), libbash::interpreter_exception); + EXPECT_THROW(cppbash_builtin::exec("continue", {"0"}, std::cout, std::cerr, std::cin, walker), libbash::interpreter_exception); + EXPECT_THROW(cppbash_builtin::exec("continue", {"-1"}, std::cout, std::cerr, std::cin, walker), libbash::interpreter_exception); } TEST(continue_builtin_test, throw_exception) diff --git a/src/builtins/tests/printf_tests.cpp b/src/builtins/tests/printf_tests.cpp index a0c463c..c4d461d 100644 --- a/src/builtins/tests/printf_tests.cpp +++ b/src/builtins/tests/printf_tests.cpp @@ -36,7 +36,7 @@ namespace cppbash_builtin::exec("printf", arguments, std::cout, std::cerr, std::cin, walker); FAIL(); } - catch(interpreter_exception& e) + catch(libbash::interpreter_exception& e) { EXPECT_STREQ(expected.c_str(), e.what()); } diff --git a/src/builtins/tests/return_tests.cpp b/src/builtins/tests/return_tests.cpp index 736e651..528c70f 100644 --- a/src/builtins/tests/return_tests.cpp +++ b/src/builtins/tests/return_tests.cpp @@ -33,7 +33,7 @@ TEST(return_builtin_test, bad_argument) { interpreter walker; EXPECT_THROW(cppbash_builtin::exec("return", {"abc"}, std::cout, std::cerr, std::cin, walker), boost::bad_lexical_cast); - EXPECT_THROW(cppbash_builtin::exec("return", {"abc", "def"}, std::cout, std::cerr, std::cin, walker), interpreter_exception); + EXPECT_THROW(cppbash_builtin::exec("return", {"abc", "def"}, std::cout, std::cerr, std::cin, walker), libbash::interpreter_exception); } TEST(return_builtin_test, bad_location) diff --git a/src/builtins/tests/shopt_tests.cpp b/src/builtins/tests/shopt_tests.cpp index 8d53434..5ed30fa 100644 --- a/src/builtins/tests/shopt_tests.cpp +++ b/src/builtins/tests/shopt_tests.cpp @@ -35,7 +35,7 @@ static void test_shopt_builtin(const std::string& expected, const std::vector<st cppbash_builtin::exec("shopt", args, std::cout, output, std::cin, walker); FAIL(); } - catch(interpreter_exception& e) + catch(libbash::interpreter_exception& e) { EXPECT_STREQ(expected.c_str(), e.what()); } diff --git a/src/builtins/tests/source_tests.cpp b/src/builtins/tests/source_tests.cpp index 438fbfd..759e456 100644 --- a/src/builtins/tests/source_tests.cpp +++ b/src/builtins/tests/source_tests.cpp @@ -92,12 +92,12 @@ TEST(source_builtin_test, invalid) std::cerr, std::cin, walker), - interpreter_exception); + libbash::interpreter_exception); EXPECT_THROW(cppbash_builtin::exec("source", {get_src_dir() + "/scripts/illegal_script.sh"}, std::cout, std::cerr, std::cin, walker), - interpreter_exception); + libbash::interpreter_exception); } |