From 39d817469ce60d2d21a98fd9b9c31eaaac154b83 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 25 Jun 2012 08:05:58 -0600 Subject: [PATCH] Optionally allow the user to specify the file name to report to end users when calling "eval" --- include/chaiscript/language/chaiscript_engine.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index b970d12..4f61f31 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -652,6 +652,8 @@ namespace chaiscript /// \tparam T Type to extract from the result value of the script execution /// \param[in] t_input Script to execute /// \param[in] t_handler Optional Exception_Handler used for automatic unboxing of script thrown exceptions + /// \param[in] t_filename Optional filename to report to the user for where the error occured. Useful + /// in special cases where you are loading a file internally instead of using eval_file /// /// \return result of the script execution /// @@ -659,10 +661,10 @@ namespace chaiscript /// \throw exception::bad_boxed_cast In the case that evaluation succeeds but the result value cannot be converted /// to the requested type. template - T eval(const std::string &t_input, const Exception_Handler &t_handler = Exception_Handler()) + T eval(const std::string &t_input, const Exception_Handler &t_handler = Exception_Handler(), const std::string &t_filename="__EVAL__") { try { - return boxed_cast(do_eval(t_input)); + return boxed_cast(do_eval(t_input, t_filename)); } catch (Boxed_Value &bv) { if (t_handler) { t_handler->handle(bv); @@ -675,14 +677,16 @@ namespace chaiscript /// /// \param[in] t_input Script to execute /// \param[in] t_handler Optional Exception_Handler used for automatic unboxing of script thrown exceptions + /// \param[in] t_filename Optional filename to report to the user for where the error occured. Useful + /// in special cases where you are loading a file internally instead of using eval_file /// /// \return result of the script execution /// /// \throw exception::eval_error In the case that evaluation fails. - Boxed_Value eval(const std::string &t_input, const Exception_Handler &t_handler = Exception_Handler()) + Boxed_Value eval(const std::string &t_input, const Exception_Handler &t_handler = Exception_Handler(), const std::string &t_filename="__EVAL__") { try { - return do_eval(t_input); + return do_eval(t_input, t_filename); } catch (Boxed_Value &bv) { if (t_handler) { t_handler->handle(bv);