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

commit:     c3e341ad6dbb9efbed40cf29a0013defe938c5c6
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 22 14:03:36 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Jun 22 15:03:31 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=c3e341ad

Core: add more exceptions

We don't want to use only one exception everywhere. Now more exceptions
are added to improve the exception hierarchy.

---
 Makefile.am                                        |    7 ++++
 src/builtins/builtin_exceptions.h                  |    2 +-
 src/builtins/continue_builtin.cpp                  |    2 +-
 src/builtins/shopt_builtin.cpp                     |    2 +-
 src/builtins/source_builtin.cpp                    |    2 +-
 src/core/bash_ast.cpp                              |    2 +-
 src/core/bash_condition.cpp                        |    2 +-
 src/core/{function.h => divide_by_zero_error.h}    |   37 +++++++++++---------
 src/core/{function.h => exceptions.h}              |   33 ++++++-----------
 src/core/function.h                                |    2 +-
 .../{function.h => illegal_argument_exception.h}   |   37 +++++++++++---------
 src/core/{function.h => parse_exception.h}         |   37 +++++++++++---------
 src/core/{function.h => readonly_exception.h}      |   37 +++++++++++---------
 src/core/{function.h => runtime_exception.h}       |   37 +++++++++++---------
 src/core/symbols.hpp                               |    2 +-
 src/core/tests/bash_condition_test.cpp             |    2 +-
 src/core/{function.h => unsupported_exception.h}   |   37 +++++++++++---------
 src/libbash.h                                      |    2 +-
 utils/ast_printer.cpp                              |    2 +-
 19 files changed, 150 insertions(+), 134 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index a706c43..85f7761 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -205,7 +205,14 @@ libcppbash_la_SOURCES = src/common.h \
 						src/builtins/builtin_exceptions.h \
 						$(GENERATED_PARSER_C) \
 						$(GENERATED_PARSER_H) \
+						src/core/divide_by_zero_error.h \
+						src/core/exceptions.h \
+						src/core/illegal_argument_exception.h \
 						src/core/interpreter_exception.h \
+						src/core/parse_exception.h \
+						src/core/readonly_exception.h \
+						src/core/runtime_exception.h \
+						src/core/unsupported_exception.h \
 						src/core/unset_exception.h \
 						src/core/interpreter.cpp \
 						src/core/interpreter.h \

diff --git a/src/builtins/builtin_exceptions.h b/src/builtins/builtin_exceptions.h
index c20ce4c..1e2f140 100644
--- a/src/builtins/builtin_exceptions.h
+++ b/src/builtins/builtin_exceptions.h
@@ -26,7 +26,7 @@
 
 #include <stdexcept>
 
-#include "core/interpreter_exception.h"
+#include "core/exceptions.h"
 
 ///
 /// \class return_exception

diff --git a/src/builtins/continue_builtin.cpp b/src/builtins/continue_builtin.cpp
index 6390e96..97ac0cd 100644
--- a/src/builtins/continue_builtin.cpp
+++ b/src/builtins/continue_builtin.cpp
@@ -25,7 +25,7 @@
 #include <boost/lexical_cast.hpp>
 
 #include "builtins/builtin_exceptions.h"
-#include "core/interpreter_exception.h"
+#include "core/exceptions.h"
 
 int continue_builtin::exec(const std::vector<std::string>& bash_args)
 {

diff --git a/src/builtins/shopt_builtin.cpp b/src/builtins/shopt_builtin.cpp
index f7354b4..e60ddac 100644
--- a/src/builtins/shopt_builtin.cpp
+++ b/src/builtins/shopt_builtin.cpp
@@ -23,8 +23,8 @@
 
 #include "builtins/shopt_builtin.h"
 
+#include "core/exceptions.h"
 #include "core/interpreter.h"
-#include "core/interpreter_exception.h"
 #include "cppbash_builtin.h"
 
 void shopt_builtin::set_opt(const std::vector<std::string>& bash_args, bool value)

diff --git a/src/builtins/source_builtin.cpp b/src/builtins/source_builtin.cpp
index b2bf2db..9dc81ca 100644
--- a/src/builtins/source_builtin.cpp
+++ b/src/builtins/source_builtin.cpp
@@ -30,8 +30,8 @@
 
 #include "builtins/builtin_exceptions.h"
 #include "cppbash_builtin.h"
+#include "core/exceptions.h"
 #include "core/interpreter.h"
-#include "core/interpreter_exception.h"
 #include "core/bash_ast.h"
 
 int source_builtin::exec(const std::vector<std::string>& bash_args)

diff --git a/src/core/bash_ast.cpp b/src/core/bash_ast.cpp
index 281f076..e0c4df1 100644
--- a/src/core/bash_ast.cpp
+++ b/src/core/bash_ast.cpp
@@ -26,7 +26,7 @@
 
 #include <boost/numeric/conversion/cast.hpp>
 
-#include "core/interpreter_exception.h"
+#include "core/exceptions.h"
 #include "core/interpreter.h"
 #include "libbashLexer.h"
 #include "libbashParser.h"

diff --git a/src/core/bash_condition.cpp b/src/core/bash_condition.cpp
index 09f1e07..59a21e9 100644
--- a/src/core/bash_condition.cpp
+++ b/src/core/bash_condition.cpp
@@ -29,8 +29,8 @@
 #include <unistd.h>
 
 #include "core/bash_ast.h"
+#include "core/exceptions.h"
 #include "core/interpreter.h"
-#include "core/interpreter_exception.h"
 
 namespace
 {

diff --git a/src/core/function.h b/src/core/divide_by_zero_error.h
similarity index 55%
copy from src/core/function.h
copy to src/core/divide_by_zero_error.h
index ceb6e67..10603cc 100644
--- a/src/core/function.h
+++ b/src/core/divide_by_zero_error.h
@@ -17,28 +17,31 @@
    along with libbash.  If not, see <http://www.gnu.org/licenses/>.
 */
 ///
-/// \file function.hpp
-/// \brief implementation for function
+/// \file divide_by_zero_error.h
+/// \brief implementation for divide_by_zero_error
 ///
 
-#ifndef LIBBASH_CORE_FUNCTION_H_
-#define LIBBASH_CORE_FUNCTION_H_
+#ifndef LIBBASH_CORE_DIVIDE_BY_ZERO_ERROR_H_
+#define LIBBASH_CORE_DIVIDE_BY_ZERO_ERROR_H_
 
-#include "core/interpreter_exception.h"
+#include <stdexcept>
+#include <string>
 
-#include <antlr3.h>
+#include "common.h"
+#include "interpreter_exception.h"
 
-class bash_ast;
-class interpreter;
-
-class function
+namespace libbash
 {
-  bash_ast& ast;
-  ANTLR3_MARKER index;
-public:
-  function(bash_ast& ast_, ANTLR3_MARKER i): ast(ast_), index(i){}
-
-  void call(interpreter& walker);
-};
+  ///
+  /// \class divide_by_zero_error
+  /// \brief exception for dividing by zero error
+  ///
+  class LIBBASH_API divide_by_zero_error: public libbash::interpreter_exception
+  {
+  public:
+    explicit divide_by_zero_error(const std::string& err_msg):
+      libbash::interpreter_exception(err_msg){}
+  };
+}
 
 #endif

diff --git a/src/core/function.h b/src/core/exceptions.h
similarity index 66%
copy from src/core/function.h
copy to src/core/exceptions.h
index ceb6e67..519d16a 100644
--- a/src/core/function.h
+++ b/src/core/exceptions.h
@@ -15,30 +15,21 @@
 
    You should have received a copy of the GNU General Public License
    along with libbash.  If not, see <http://www.gnu.org/licenses/>.
-*/
+   */
 ///
-/// \file function.hpp
-/// \brief implementation for function
+/// \file exceptions.h
+/// \author Mu Qiao
+/// \brief headers for all exceptions
 ///
+#ifndef LIBBASH_CORE_EXCEPTIOND_H_
+#define LIBBASH_CORE_EXCEPTIOND_H_
 
-#ifndef LIBBASH_CORE_FUNCTION_H_
-#define LIBBASH_CORE_FUNCTION_H_
-
+#include "core/divide_by_zero_error.h"
+#include "core/illegal_argument_exception.h"
 #include "core/interpreter_exception.h"
-
-#include <antlr3.h>
-
-class bash_ast;
-class interpreter;
-
-class function
-{
-  bash_ast& ast;
-  ANTLR3_MARKER index;
-public:
-  function(bash_ast& ast_, ANTLR3_MARKER i): ast(ast_), index(i){}
-
-  void call(interpreter& walker);
-};
+#include "core/parse_exception.h"
+#include "core/readonly_exception.h"
+#include "core/runtime_exception.h"
+#include "core/unsupported_exception.h"
 
 #endif

diff --git a/src/core/function.h b/src/core/function.h
index ceb6e67..fcd0e91 100644
--- a/src/core/function.h
+++ b/src/core/function.h
@@ -24,7 +24,7 @@
 #ifndef LIBBASH_CORE_FUNCTION_H_
 #define LIBBASH_CORE_FUNCTION_H_
 
-#include "core/interpreter_exception.h"
+#include "core/exceptions.h"
 
 #include <antlr3.h>
 

diff --git a/src/core/function.h b/src/core/illegal_argument_exception.h
similarity index 54%
copy from src/core/function.h
copy to src/core/illegal_argument_exception.h
index ceb6e67..f67a9f6 100644
--- a/src/core/function.h
+++ b/src/core/illegal_argument_exception.h
@@ -17,28 +17,31 @@
    along with libbash.  If not, see <http://www.gnu.org/licenses/>.
 */
 ///
-/// \file function.hpp
-/// \brief implementation for function
+/// \file illegal_argument_exception.h
+/// \brief implementation for illegal_argument_exception
 ///
 
-#ifndef LIBBASH_CORE_FUNCTION_H_
-#define LIBBASH_CORE_FUNCTION_H_
+#ifndef LIBBASH_CORE_ILLEGAL_ARGUMENT_EXCEPTION_H_
+#define LIBBASH_CORE_ILLEGAL_ARGUMENT_EXCEPTION_H_
 
-#include "core/interpreter_exception.h"
+#include <stdexcept>
+#include <string>
 
-#include <antlr3.h>
+#include "common.h"
+#include "interpreter_exception.h"
 
-class bash_ast;
-class interpreter;
-
-class function
+namespace libbash
 {
-  bash_ast& ast;
-  ANTLR3_MARKER index;
-public:
-  function(bash_ast& ast_, ANTLR3_MARKER i): ast(ast_), index(i){}
-
-  void call(interpreter& walker);
-};
+  ///
+  /// \class illegal_argument_exception
+  /// \brief exception for parsing errors
+  ///
+  class LIBBASH_API illegal_argument_exception: public libbash::interpreter_exception
+  {
+  public:
+    explicit illegal_argument_exception(const std::string& err_msg):
+      libbash::interpreter_exception(err_msg){}
+  };
+}
 
 #endif

diff --git a/src/core/function.h b/src/core/parse_exception.h
similarity index 57%
copy from src/core/function.h
copy to src/core/parse_exception.h
index ceb6e67..20860b4 100644
--- a/src/core/function.h
+++ b/src/core/parse_exception.h
@@ -17,28 +17,31 @@
    along with libbash.  If not, see <http://www.gnu.org/licenses/>.
 */
 ///
-/// \file function.hpp
-/// \brief implementation for function
+/// \file parse_exception.h
+/// \brief implementation for parse_exception
 ///
 
-#ifndef LIBBASH_CORE_FUNCTION_H_
-#define LIBBASH_CORE_FUNCTION_H_
+#ifndef LIBBASH_CORE_PARSE_EXCEPTION_H_
+#define LIBBASH_CORE_PARSE_EXCEPTION_H_
 
-#include "core/interpreter_exception.h"
+#include <stdexcept>
+#include <string>
 
-#include <antlr3.h>
+#include "common.h"
+#include "interpreter_exception.h"
 
-class bash_ast;
-class interpreter;
-
-class function
+namespace libbash
 {
-  bash_ast& ast;
-  ANTLR3_MARKER index;
-public:
-  function(bash_ast& ast_, ANTLR3_MARKER i): ast(ast_), index(i){}
-
-  void call(interpreter& walker);
-};
+  ///
+  /// \class parse_exception
+  /// \brief exception for parsing errors
+  ///
+  class LIBBASH_API parse_exception: public libbash::interpreter_exception
+  {
+  public:
+    explicit parse_exception(const std::string& err_msg):
+      libbash::interpreter_exception(err_msg){}
+  };
+}
 
 #endif

diff --git a/src/core/function.h b/src/core/readonly_exception.h
similarity index 56%
copy from src/core/function.h
copy to src/core/readonly_exception.h
index ceb6e67..97964de 100644
--- a/src/core/function.h
+++ b/src/core/readonly_exception.h
@@ -17,28 +17,31 @@
    along with libbash.  If not, see <http://www.gnu.org/licenses/>.
 */
 ///
-/// \file function.hpp
-/// \brief implementation for function
+/// \file readonly_exception.h
+/// \brief implementation for readonly_exception
 ///
 
-#ifndef LIBBASH_CORE_FUNCTION_H_
-#define LIBBASH_CORE_FUNCTION_H_
+#ifndef LIBBASH_CORE_READONLY_EXCEPTION_H_
+#define LIBBASH_CORE_READONLY_EXCEPTION_H_
 
-#include "core/interpreter_exception.h"
+#include <stdexcept>
+#include <string>
 
-#include <antlr3.h>
+#include "common.h"
+#include "interpreter_exception.h"
 
-class bash_ast;
-class interpreter;
-
-class function
+namespace libbash
 {
-  bash_ast& ast;
-  ANTLR3_MARKER index;
-public:
-  function(bash_ast& ast_, ANTLR3_MARKER i): ast(ast_), index(i){}
-
-  void call(interpreter& walker);
-};
+  ///
+  /// \class readonly_exception
+  /// \brief exception for modifying readonly symbols
+  ///
+  class LIBBASH_API readonly_exception: public libbash::interpreter_exception
+  {
+  public:
+    explicit readonly_exception(const std::string& err_msg):
+      libbash::interpreter_exception(err_msg){}
+  };
+}
 
 #endif

diff --git a/src/core/function.h b/src/core/runtime_exception.h
similarity index 57%
copy from src/core/function.h
copy to src/core/runtime_exception.h
index ceb6e67..da6fffa 100644
--- a/src/core/function.h
+++ b/src/core/runtime_exception.h
@@ -17,28 +17,31 @@
    along with libbash.  If not, see <http://www.gnu.org/licenses/>.
 */
 ///
-/// \file function.hpp
-/// \brief implementation for function
+/// \file runtime_exception.h
+/// \brief implementation for runtime_exception
 ///
 
-#ifndef LIBBASH_CORE_FUNCTION_H_
-#define LIBBASH_CORE_FUNCTION_H_
+#ifndef LIBBASH_CORE_RUNTIME_EXCEPTION_H_
+#define LIBBASH_CORE_RUNTIME_EXCEPTION_H_
 
-#include "core/interpreter_exception.h"
+#include <stdexcept>
+#include <string>
 
-#include <antlr3.h>
+#include "common.h"
+#include "interpreter_exception.h"
 
-class bash_ast;
-class interpreter;
-
-class function
+namespace libbash
 {
-  bash_ast& ast;
-  ANTLR3_MARKER index;
-public:
-  function(bash_ast& ast_, ANTLR3_MARKER i): ast(ast_), index(i){}
-
-  void call(interpreter& walker);
-};
+  ///
+  /// \class runtime_exception
+  /// \brief exception for runtime errors
+  ///
+  class LIBBASH_API runtime_exception: public libbash::interpreter_exception
+  {
+  public:
+    explicit runtime_exception(const std::string& err_msg):
+      libbash::interpreter_exception(err_msg){}
+  };
+}
 
 #endif

diff --git a/src/core/symbols.hpp b/src/core/symbols.hpp
index 8563469..1c5627a 100644
--- a/src/core/symbols.hpp
+++ b/src/core/symbols.hpp
@@ -34,7 +34,7 @@
 #include <boost/variant.hpp>
 #include <boost/lexical_cast.hpp>
 
-#include "core/interpreter_exception.h"
+#include "core/exceptions.h"
 
 ///
 /// \class converter

diff --git a/src/core/tests/bash_condition_test.cpp b/src/core/tests/bash_condition_test.cpp
index 1979893..d3c704f 100644
--- a/src/core/tests/bash_condition_test.cpp
+++ b/src/core/tests/bash_condition_test.cpp
@@ -30,8 +30,8 @@
 #include <gtest/gtest.h>
 
 #include "core/bash_condition.h"
+#include "core/exceptions.h"
 #include "core/interpreter.h"
-#include "core/interpreter_exception.h"
 
 namespace
 {

diff --git a/src/core/function.h b/src/core/unsupported_exception.h
similarity index 55%
copy from src/core/function.h
copy to src/core/unsupported_exception.h
index ceb6e67..338b087 100644
--- a/src/core/function.h
+++ b/src/core/unsupported_exception.h
@@ -17,28 +17,31 @@
    along with libbash.  If not, see <http://www.gnu.org/licenses/>.
 */
 ///
-/// \file function.hpp
-/// \brief implementation for function
+/// \file unsupported_exception.h
+/// \brief implementation for unsupported_exception
 ///
 
-#ifndef LIBBASH_CORE_FUNCTION_H_
-#define LIBBASH_CORE_FUNCTION_H_
+#ifndef LIBBASH_CORE_UNSUPPORTED_EXCEPTION_H_
+#define LIBBASH_CORE_UNSUPPORTED_EXCEPTION_H_
 
-#include "core/interpreter_exception.h"
+#include <stdexcept>
+#include <string>
 
-#include <antlr3.h>
+#include "common.h"
+#include "interpreter_exception.h"
 
-class bash_ast;
-class interpreter;
-
-class function
+namespace libbash
 {
-  bash_ast& ast;
-  ANTLR3_MARKER index;
-public:
-  function(bash_ast& ast_, ANTLR3_MARKER i): ast(ast_), index(i){}
-
-  void call(interpreter& walker);
-};
+  ///
+  /// \class unsupported_exception
+  /// \brief exception for unsupported features
+  ///
+  class LIBBASH_API unsupported_exception: public libbash::interpreter_exception
+  {
+  public:
+    explicit unsupported_exception(const std::string& err_msg):
+      libbash::interpreter_exception(err_msg){}
+  };
+}
 
 #endif

diff --git a/src/libbash.h b/src/libbash.h
index ab3a630..f42d278 100644
--- a/src/libbash.h
+++ b/src/libbash.h
@@ -30,7 +30,7 @@
 #include <vector>
 
 #include "common.h"
-#include "core/interpreter_exception.h"
+#include "core/exceptions.h"
 
 namespace libbash
 {

diff --git a/utils/ast_printer.cpp b/utils/ast_printer.cpp
index 6fa7c38..9c4bc3d 100644
--- a/utils/ast_printer.cpp
+++ b/utils/ast_printer.cpp
@@ -34,7 +34,7 @@
 #include <boost/fusion/include/adapt_struct.hpp>
 
 #include "core/bash_ast.h"
-#include "core/interpreter_exception.h"
+#include "core/exceptions.h"
 #include "libbashParser.h"
 
 namespace po = boost::program_options;



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

only message in thread, other threads:[~2011-06-25 10:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-25 10:05 [gentoo-commits] proj/libbash:master commit in: src/, /, src/core/, src/core/tests/, utils/, src/builtins/ 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