public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/libbash:master commit in: src/builtins/tests/, src/core/, bashast/, test/, src/core/tests/, utils/, ...
@ 2011-06-14 13:02 Petteri Räty
  0 siblings, 0 replies; only message in thread
From: Petteri Räty @ 2011-06-14 13:02 UTC (permalink / raw
  To: gentoo-commits

commit:     26c12581f3d21fb2dadd0f6052f204e26305ed23
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 14 08:59:32 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Jun 14 12:58:27 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=26c12581

Core: add namespace for interpreter_exception

The interpreter_exception is part of our public API so we put it under
libbash namespace.

---
 bashast/libbashWalker.g                |    8 ++++----
 src/builtins/builtin_exceptions.h      |    2 +-
 src/builtins/continue_builtin.cpp      |    4 ++--
 src/builtins/declare_builtin.cpp       |    2 +-
 src/builtins/printf_builtin.cpp        |    4 ++--
 src/builtins/return_builtin.cpp        |    2 +-
 src/builtins/shopt_builtin.cpp         |    8 ++++----
 src/builtins/source_builtin.cpp        |    2 +-
 src/builtins/tests/continue_tests.cpp  |    8 ++++----
 src/builtins/tests/printf_tests.cpp    |    2 +-
 src/builtins/tests/return_tests.cpp    |    2 +-
 src/builtins/tests/shopt_tests.cpp     |    2 +-
 src/builtins/tests/source_tests.cpp    |    4 ++--
 src/core/bash_ast.cpp                  |   12 ++++++------
 src/core/bash_condition.cpp            |   10 +++++-----
 src/core/interpreter.cpp               |   10 +++++-----
 src/core/interpreter.h                 |    2 +-
 src/core/interpreter_exception.h       |   21 ++++++++++++---------
 src/core/symbols.hpp                   |    4 ++--
 src/core/tests/bash_ast_test.cpp       |    4 ++--
 src/core/tests/bash_condition_test.cpp |    4 ++--
 src/core/tests/interpreter_test.cpp    |   16 ++++++++--------
 src/core/tests/symbols_test.cpp        |    6 +++---
 src/core/unset_exception.h             |    4 ++--
 test/api_test.cpp                      |    8 ++++----
 test/walker_test.cpp                   |    6 +++---
 utils/ast_printer.cpp                  |    2 +-
 utils/instruo.cpp                      |    2 +-
 utils/variable_printer.cpp             |    2 +-
 29 files changed, 83 insertions(+), 80 deletions(-)

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index 4649f79..5469f84 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -67,7 +67,7 @@ options
 		void set_index(const std::string& name, unsigned& index, int value)
 		{
 			if(value < 0)
-				throw interpreter_exception((boost::format("Array index is less than 0: \%s[\%d]") \% name \% value).str());
+				throw libbash::interpreter_exception((boost::format("Array index is less than 0: \%s[\%d]") \% name \% value).str());
 			index = value;
 		}
 
@@ -248,7 +248,7 @@ bash_pattern[boost::xpressive::sregex& pattern, bool greedy]
 	sregex pattern_list;
 	auto check_extglob = [&]() {
 		if(!walker->get_option("extglob"))
-			throw interpreter_exception("Entered extended pattern matching with extglob disabled");
+			throw libbash::interpreter_exception("Entered extended pattern matching with extglob disabled");
 	};
 }
 	:^(STRING (
@@ -280,7 +280,7 @@ bash_pattern[boost::xpressive::sregex& pattern, bool greedy]
 		}
 		|(EXTENDED_MATCH_NONE) => ^(EXTENDED_MATCH_NONE composite_pattern[pattern_list, $greedy]) {
 			check_extglob();
-			throw interpreter_exception("!(blah) is not supported for now");
+			throw libbash::interpreter_exception("!(blah) is not supported for now");
 		}
 		|basic_pattern[$pattern, $greedy, do_append])+);
 
@@ -532,7 +532,7 @@ execute_command[const std::string& name, std::vector<std::string>& libbash_args]
 		else
 		{
 			walker->set_status(1);
-			throw interpreter_exception(name + " is not supported yet");
+			throw libbash::interpreter_exception(name + " is not supported yet");
 		}
 	}
 	(BANG { walker->set_status(!walker->get_status()); })?;

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);
 }

diff --git a/src/core/bash_ast.cpp b/src/core/bash_ast.cpp
index c029d6f..281f076 100644
--- a/src/core/bash_ast.cpp
+++ b/src/core/bash_ast.cpp
@@ -47,7 +47,7 @@ bash_ast::bash_ast(const std::string& script_path,
   std::stringstream stream;
   std::ifstream file_stream(script_path);
   if(!file_stream)
-    throw interpreter_exception(script_path + " can't be read");
+    throw libbash::interpreter_exception(script_path + " can't be read");
 
   stream << file_stream.rdbuf();
   script = stream.str();
@@ -63,7 +63,7 @@ void bash_ast::init_parser(const std::string& script, const std::string& script_
     NULL));
 
   if(!input)
-    throw interpreter_exception("Unable to open file " + script + " due to malloc() failure");
+    throw libbash::interpreter_exception("Unable to open file " + script + " due to malloc() failure");
 
   input->fileName = input->strFactory->newStr(
       input->strFactory,
@@ -71,20 +71,20 @@ void bash_ast::init_parser(const std::string& script, const std::string& script_
 
   lexer.reset(libbashLexerNew(input.get()));
   if(!lexer)
-    throw interpreter_exception("Unable to create the lexer due to malloc() failure");
+    throw libbash::interpreter_exception("Unable to create the lexer due to malloc() failure");
 
   token_stream.reset(antlr3CommonTokenStreamSourceNew(
       ANTLR3_SIZE_HINT, lexer->pLexer->rec->state->tokSource));
   if(!token_stream)
-    throw interpreter_exception("Out of memory trying to allocate token stream");
+    throw libbash::interpreter_exception("Out of memory trying to allocate token stream");
 
   parser.reset(libbashParserNew(token_stream.get()));
   if(!parser)
-    throw interpreter_exception("Out of memory trying to allocate parser");
+    throw libbash::interpreter_exception("Out of memory trying to allocate parser");
 
   ast = parse(parser.get());
   if(parser->pParser->rec->getNumberOfSyntaxErrors(parser->pParser->rec))
-    throw interpreter_exception("Something wrong happened while parsing");
+    throw libbash::interpreter_exception("Something wrong happened while parsing");
   nodes.reset(antlr3CommonTreeNodeStreamNewTree(ast, ANTLR3_SIZE_HINT));
 }
 

diff --git a/src/core/bash_condition.cpp b/src/core/bash_condition.cpp
index a677961..09f1e07 100644
--- a/src/core/bash_condition.cpp
+++ b/src/core/bash_condition.cpp
@@ -85,7 +85,7 @@ namespace
       case 'N':
         return info.st_mtime >= info.st_atime;
       default:
-        throw interpreter_exception(std::string("Unrecognized test operator -") + op);
+        throw libbash::interpreter_exception(std::string("Unrecognized test operator -") + op);
     }
   }
 }
@@ -99,7 +99,7 @@ bool internal::test_unary(char op, const std::string& target)
     case 'n':
       return !target.empty();
     case 'o':
-      throw interpreter_exception("Shell option test is not supported");
+      throw libbash::interpreter_exception("Shell option test is not supported");
     case 't':
       try
       {
@@ -141,7 +141,7 @@ namespace
         /* -ef */
         return (lst.st_dev == rst.st_dev && lst.st_ino == rst.st_ino);
       default:
-        throw interpreter_exception(std::string("Unrecognized option for file test ") + op);
+        throw libbash::interpreter_exception(std::string("Unrecognized option for file test ") + op);
     }
   }
 }
@@ -152,7 +152,7 @@ bool internal::test_binary(const std::string& op,
                            interpreter& walker)
 {
   if(op.size() != 2)
-    throw interpreter_exception("Unrecognized operator " + op);
+    throw libbash::interpreter_exception("Unrecognized operator " + op);
 
   try
   {
@@ -177,7 +177,7 @@ bool internal::test_binary(const std::string& op,
     else if(op == "ge")
       return walker.eval_arithmetic(lhs) >= walker.eval_arithmetic(rhs);
     else
-      throw interpreter_exception("Unrecognized operator " + op);
+      throw libbash::interpreter_exception("Unrecognized operator " + op);
   }
   catch(boost::bad_lexical_cast& e)
   {

diff --git a/src/core/interpreter.cpp b/src/core/interpreter.cpp
index 78ffd89..c71233d 100644
--- a/src/core/interpreter.cpp
+++ b/src/core/interpreter.cpp
@@ -137,7 +137,7 @@ const std::string interpreter::do_substring_expansion(const std::string& name,
                                                       const unsigned index) const
 {
   if(length < 0)
-    throw interpreter_exception("length of substring expression should be greater or equal to zero");
+    throw libbash::interpreter_exception("length of substring expression should be greater or equal to zero");
 
   return get_substring(name, offset, boost::numeric_cast<unsigned>(length), index);
 }
@@ -185,7 +185,7 @@ const std::string interpreter::do_subarray_expansion(const std::string& name,
                                                      int length) const
 {
   if(length < 0)
-    throw interpreter_exception("length of substring expression should be greater or equal to zero");
+    throw libbash::interpreter_exception("length of substring expression should be greater or equal to zero");
 
   return get_subarray(name, offset, boost::numeric_cast<unsigned>(length));
 }
@@ -277,7 +277,7 @@ void interpreter::call(const std::string& name,
   if(iter != functions.end())
     iter->second.call(*this);
   else
-    throw interpreter_exception(name + " is not defined.");
+    throw libbash::interpreter_exception(name + " is not defined.");
 }
 
 void interpreter::replace_all(std::string& value,
@@ -376,7 +376,7 @@ bool interpreter::get_option(const std::string& name) const
 {
   auto iter = bash_options.find(name);
   if(iter == bash_options.end())
-    throw interpreter_exception("Invalid bash option");
+    throw libbash::interpreter_exception("Invalid bash option");
 
   return iter->second;
 }
@@ -385,7 +385,7 @@ void interpreter::set_option(const std::string& name, bool value)
 {
   auto iter = bash_options.find(name);
   if(iter == bash_options.end())
-    throw interpreter_exception(name + " is not a valid bash option");
+    throw libbash::interpreter_exception(name + " is not a valid bash option");
 
   iter->second = value;
 }

diff --git a/src/core/interpreter.h b/src/core/interpreter.h
index 460a2e3..0884dc0 100644
--- a/src/core/interpreter.h
+++ b/src/core/interpreter.h
@@ -220,7 +220,7 @@ public:
     return members.find(name) == members.end();
   }
 
-  /// \brief update the variable value, raise interpreter_exception if
+  /// \brief update the variable value, raise libbash::interpreter_exception if
   ///        it's readonly, will define the variable if it doesn't exist
   /// \param variable name
   /// \param new value

diff --git a/src/core/interpreter_exception.h b/src/core/interpreter_exception.h
index bc66a96..ea5a9ef 100644
--- a/src/core/interpreter_exception.h
+++ b/src/core/interpreter_exception.h
@@ -29,15 +29,18 @@
 
 #include "common.h"
 
-///
-/// \class interpreter_exception
-/// \brief runtime exception occured during interpreting
-///
-class LIBBASH_API interpreter_exception: public std::runtime_error
+namespace libbash
 {
-public:
-  explicit interpreter_exception(const std::string& err_msg):
-    runtime_error(err_msg){}
-};
+  ///
+  /// \class interpreter_exception
+  /// \brief runtime exception occured during interpreting
+  ///
+  class LIBBASH_API interpreter_exception: public std::runtime_error
+  {
+  public:
+    explicit interpreter_exception(const std::string& err_msg):
+      runtime_error(err_msg){}
+  };
+}
 
 #endif

diff --git a/src/core/symbols.hpp b/src/core/symbols.hpp
index 0ec12b7..8563469 100644
--- a/src/core/symbols.hpp
+++ b/src/core/symbols.hpp
@@ -181,7 +181,7 @@ public:
                  const unsigned index=0)
   {
     if(readonly)
-      throw interpreter_exception(get_name() + " is readonly variable");
+      throw libbash::interpreter_exception(get_name() + " is readonly variable");
 
     value[index] = new_value;
   }
@@ -191,7 +191,7 @@ public:
   void unset_value(const unsigned index)
   {
     if(readonly)
-      throw interpreter_exception(get_name() + " is readonly variable");
+      throw libbash::interpreter_exception(get_name() + " is readonly variable");
 
     value.erase(index);
   }

diff --git a/src/core/tests/bash_ast_test.cpp b/src/core/tests/bash_ast_test.cpp
index 0b94d67..c6036fe 100644
--- a/src/core/tests/bash_ast_test.cpp
+++ b/src/core/tests/bash_ast_test.cpp
@@ -33,7 +33,7 @@
 
 TEST(bash_ast, parse_illegal_script)
 {
-  EXPECT_THROW(bash_ast ast(get_src_dir() + std::string("/scripts/illegal_script.sh")), interpreter_exception);
+  EXPECT_THROW(bash_ast ast(get_src_dir() + std::string("/scripts/illegal_script.sh")), libbash::interpreter_exception);
 }
 
 TEST(bash_ast, parse_legal_script)
@@ -52,5 +52,5 @@ TEST(bash_ast, parse_arithmetics)
 
 TEST(bash_ast, illegal_path)
 {
-  EXPECT_THROW(bash_ast("not_exist"), interpreter_exception);
+  EXPECT_THROW(bash_ast("not_exist"), libbash::interpreter_exception);
 }

diff --git a/src/core/tests/bash_condition_test.cpp b/src/core/tests/bash_condition_test.cpp
index c7bc944..1979893 100644
--- a/src/core/tests/bash_condition_test.cpp
+++ b/src/core/tests/bash_condition_test.cpp
@@ -135,7 +135,7 @@ TEST(bash_condition, string_unary_operator)
   EXPECT_FALSE(internal::test_unary('n', ""));
   EXPECT_TRUE(internal::test_unary('n', "hello"));
 
-  EXPECT_THROW(internal::test_unary('o', "extglob"), interpreter_exception);
+  EXPECT_THROW(internal::test_unary('o', "extglob"), libbash::interpreter_exception);
 }
 
 TEST_F(file_test, binary_operator)
@@ -154,7 +154,7 @@ TEST_F(file_test, binary_operator)
   EXPECT_FALSE(internal::test_binary("ef", positive, negative, walker));
   EXPECT_FALSE(internal::test_binary("ef", "not exist", negative, walker));
 
-  EXPECT_THROW(internal::test_binary("efd", positive, negative, walker), interpreter_exception);
+  EXPECT_THROW(internal::test_binary("efd", positive, negative, walker), libbash::interpreter_exception);
 }
 
 TEST(bash_condition, arithmetic_operator)

diff --git a/src/core/tests/interpreter_test.cpp b/src/core/tests/interpreter_test.cpp
index 9619ad8..678ac00 100644
--- a/src/core/tests/interpreter_test.cpp
+++ b/src/core/tests/interpreter_test.cpp
@@ -98,7 +98,7 @@ TEST(interpreter, set_int_value)
 
   walker.define("aint_ro", 4, true);
   EXPECT_THROW(walker.set_value("aint_ro", 10),
-               interpreter_exception);
+               libbash::interpreter_exception);
   EXPECT_EQ(4, walker.resolve<int>("aint_ro"));
 }
 
@@ -113,7 +113,7 @@ TEST(interpreter, set_string_value)
 
   walker.define("astring_ro", "hi", true);
   EXPECT_THROW(walker.set_value<string>("astring_ro", "hello"),
-               interpreter_exception);
+               libbash::interpreter_exception);
   EXPECT_STREQ("hi", walker.resolve<string>("astring_ro").c_str());
 }
 
@@ -129,7 +129,7 @@ TEST(interpreter, set_array_value)
 
   walker.define("ro_array", values, true);
   EXPECT_THROW(walker.set_value<string>("ro_array", "hello", 1),
-               interpreter_exception);
+               libbash::interpreter_exception);
   EXPECT_STREQ("2", walker.resolve<string>("ro_array", 1).c_str());
 }
 
@@ -181,7 +181,7 @@ TEST(interpreter, unset_arrays)
   EXPECT_THROW(walker.unset("ro_array"), unset_exception);
   EXPECT_THROW(walker.unset("ro_local_array"), unset_exception);
 
-  EXPECT_THROW(walker.unset("1", 1), interpreter_exception);
+  EXPECT_THROW(walker.unset("1", 1), libbash::interpreter_exception);
 }
 
 TEST(interpreter, unset_variables)
@@ -202,7 +202,7 @@ TEST(interpreter, unset_variables)
 
   EXPECT_THROW(walker.unset("ro_var"), unset_exception);
   EXPECT_THROW(walker.unset("ro_local_var"), unset_exception);
-  EXPECT_THROW(walker.unset("1"), interpreter_exception);
+  EXPECT_THROW(walker.unset("1"), libbash::interpreter_exception);
 }
 
 TEST(interpreter, unset_functions)
@@ -219,7 +219,7 @@ TEST(interperter, substring_expansion)
 {
   interpreter walker;
   EXPECT_STREQ("", walker.do_substring_expansion("@", 0, 1, 2).c_str());
-  EXPECT_THROW(walker.do_substring_expansion("", 0, -1, 0), interpreter_exception);
+  EXPECT_THROW(walker.do_substring_expansion("", 0, -1, 0), libbash::interpreter_exception);
 }
 
 TEST(interpreter, word_split)
@@ -240,8 +240,8 @@ TEST(interpreter, bash_option)
 {
   interpreter walker;
 
-  EXPECT_THROW(walker.set_option("not exist", false), interpreter_exception);
-  EXPECT_THROW(walker.get_option("not exist"), interpreter_exception);
+  EXPECT_THROW(walker.set_option("not exist", false), libbash::interpreter_exception);
+  EXPECT_THROW(walker.get_option("not exist"), libbash::interpreter_exception);
 
   EXPECT_FALSE(walker.get_option("extglob"));
   walker.set_option("extglob", true);

diff --git a/src/core/tests/symbols_test.cpp b/src/core/tests/symbols_test.cpp
index f0585f8..1410a05 100644
--- a/src/core/tests/symbols_test.cpp
+++ b/src/core/tests/symbols_test.cpp
@@ -33,7 +33,7 @@ TEST(symbol_test, int_variable)
   variable ro_integer("integer", 10, true);
   EXPECT_STREQ("integer", ro_integer.get_name().c_str());
   EXPECT_EQ(10, ro_integer.get_value<int>());
-  EXPECT_THROW(ro_integer.set_value(100), interpreter_exception);
+  EXPECT_THROW(ro_integer.set_value(100), libbash::interpreter_exception);
   EXPECT_EQ(10, ro_integer.get_value<int>());
 
   // normal only integer
@@ -51,7 +51,7 @@ TEST(symbol_test, string_variable)
   variable ro_string("string", "hello", true);
   EXPECT_STREQ("string", ro_string.get_name().c_str());
   EXPECT_STREQ("hello", ro_string.get_value<string>().c_str());
-  EXPECT_THROW(ro_string.set_value("hello world"), interpreter_exception);
+  EXPECT_THROW(ro_string.set_value("hello world"), libbash::interpreter_exception);
   EXPECT_STREQ("hello", ro_string.get_value<string>().c_str());
 
   // normal string
@@ -76,7 +76,7 @@ TEST(symbol_test, array_variable)
   EXPECT_STREQ("1", ro_array.get_value<string>(0).c_str());
   EXPECT_STREQ("2", ro_array.get_value<string>(1).c_str());
   EXPECT_STREQ("3", ro_array.get_value<string>(2).c_str());
-  EXPECT_THROW(ro_array.set_value("4", 0), interpreter_exception);
+  EXPECT_THROW(ro_array.set_value("4", 0), libbash::interpreter_exception);
   EXPECT_STREQ("1", ro_array.get_value<string>(0).c_str());
 
   // out of bound

diff --git a/src/core/unset_exception.h b/src/core/unset_exception.h
index 7924512..4346ba6 100644
--- a/src/core/unset_exception.h
+++ b/src/core/unset_exception.h
@@ -33,11 +33,11 @@
 /// \class unset_exception
 /// \brief exception for unsetting variables
 ///
-class unset_exception: public interpreter_exception
+class unset_exception: public libbash::interpreter_exception
 {
 public:
   explicit unset_exception(const std::string& err_msg):
-    interpreter_exception(err_msg){}
+    libbash::interpreter_exception(err_msg){}
 };
 
 #endif

diff --git a/test/api_test.cpp b/test/api_test.cpp
index 38972fe..a3b86a8 100644
--- a/test/api_test.cpp
+++ b/test/api_test.cpp
@@ -31,9 +31,9 @@ TEST(libbashapi, bad_path)
   std::unordered_map<std::string, std::vector<std::string>> variables;
   std::vector<std::string> functions;
   EXPECT_THROW(libbash::interpret("not exist", variables, functions),
-               interpreter_exception);
+               libbash::interpreter_exception);
   EXPECT_THROW(libbash::interpret("/scripts/source_true.sh", "not exist", variables, functions),
-               interpreter_exception);
+               libbash::interpreter_exception);
 }
 
 TEST(libbashapi, illegal_script)
@@ -41,7 +41,7 @@ TEST(libbashapi, illegal_script)
   std::unordered_map<std::string, std::vector<std::string>> variables;
   std::vector<std::string> functions;
   EXPECT_THROW(libbash::interpret(get_src_dir() + "/scripts/illegal_script.sh", variables, functions),
-               interpreter_exception);
+               libbash::interpreter_exception);
 }
 
 TEST(libbashapi, legal_script)
@@ -81,5 +81,5 @@ TEST(libbashapi, preload)
                                   get_src_dir() + std::string("/scripts/illegal_script.sh"),
                                   variables,
                                   functions),
-               interpreter_exception);
+               libbash::interpreter_exception);
 }

diff --git a/test/walker_test.cpp b/test/walker_test.cpp
index bfdba83..5a64b04 100644
--- a/test/walker_test.cpp
+++ b/test/walker_test.cpp
@@ -66,12 +66,12 @@ TEST(array_index, out_of_bound)
   std::string script = "a[-1]=\"1\"";
   std::istringstream input(script);
   bash_ast ast(input);
-  EXPECT_THROW(ast.interpret_with(walker), interpreter_exception);
+  EXPECT_THROW(ast.interpret_with(walker), libbash::interpreter_exception);
 
   std::string script2 = "a=(1 2 [-5]=1)";
   std::istringstream input2(script2);
   bash_ast ast2(input2);
-  EXPECT_THROW(ast2.interpret_with(walker), interpreter_exception);
+  EXPECT_THROW(ast2.interpret_with(walker), libbash::interpreter_exception);
 }
 
 TEST(extglob, used_when_disabled)
@@ -85,7 +85,7 @@ TEST(extglob, used_when_disabled)
   {
     ast.interpret_with(walker);
   }
-  catch(interpreter_exception& e)
+  catch(libbash::interpreter_exception& e)
   {
     EXPECT_STREQ(e.what(), "Entered extended pattern matching with extglob disabled");
   }

diff --git a/utils/ast_printer.cpp b/utils/ast_printer.cpp
index e55df78..6fa7c38 100644
--- a/utils/ast_printer.cpp
+++ b/utils/ast_printer.cpp
@@ -181,7 +181,7 @@ int main(int argc, char** argv)
     else
       print_cin(printer);
   }
-  catch(interpreter_exception& e)
+  catch(libbash::interpreter_exception& e)
   {
     if(!vm.count("silent"))
       std::cerr << e.what() << std::endl;

diff --git a/utils/instruo.cpp b/utils/instruo.cpp
index 8206b95..dcd3924 100644
--- a/utils/instruo.cpp
+++ b/utils/instruo.cpp
@@ -105,7 +105,7 @@ void worker(const std::shared_ptr<PackageIDSequence> &ids)
     {
       libbash::interpret(ebuild_path, "utils/isolated-functions.sh", variables, functions);
     }
-    catch(const interpreter_exception& e)
+    catch(const libbash::interpreter_exception& e)
     {
       cerr << "Exception occurred while interpreting " << ebuild_path << ". The error message is:\n"
         << e.what() << endl;

diff --git a/utils/variable_printer.cpp b/utils/variable_printer.cpp
index 9104273..a89de8a 100644
--- a/utils/variable_printer.cpp
+++ b/utils/variable_printer.cpp
@@ -59,7 +59,7 @@ int main(int argc, char** argv)
   {
     libbash::interpret(argv[1], get_src_dir() + "/utils/isolated-functions.sh", variables, functions);
   }
-  catch(interpreter_exception& e)
+  catch(libbash::interpreter_exception& e)
   {
     std::cerr << e.what() << std::endl;
     return EXIT_FAILURE;



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-06-14 13:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-14 13:02 [gentoo-commits] proj/libbash:master commit in: src/builtins/tests/, src/core/, bashast/, test/, src/core/tests/, utils/, Petteri Räty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox