From 192ce615d8609b14b97dd45e2b062baedb9c7dd6 Mon Sep 17 00:00:00 2001 From: q66 Date: Thu, 15 Sep 2016 21:27:14 +0200 Subject: [PATCH] remove get_err/set_err --- include/cubescript/cubescript.hh | 6 +----- src/cubescript.cc | 14 +------------- tools/repl.cc | 11 ++++------- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/include/cubescript/cubescript.hh b/include/cubescript/cubescript.hh index 58b1cdd4..54877943 100644 --- a/include/cubescript/cubescript.hh +++ b/include/cubescript/cubescript.hh @@ -370,10 +370,6 @@ struct OSTD_EXPORT CsState { CsStream &get_out(); void set_out(CsStream &s); - CsStream const &get_err() const; - CsStream &get_err(); - void set_err(CsStream &s); - CsHookCb set_call_hook(CsHookCb func); CsHookCb const &get_call_hook() const; CsHookCb &get_call_hook(); @@ -571,7 +567,7 @@ private: CsHookCb p_callhook; - CsStream *p_out, *p_err; + CsStream *p_out; }; struct CsStackStateNode { diff --git a/src/cubescript.cc b/src/cubescript.cc index 58d52405..9ffcd9fc 100644 --- a/src/cubescript.cc +++ b/src/cubescript.cc @@ -255,7 +255,7 @@ void cs_init_lib_base(CsState &cs); CsState::CsState(CsAllocCb func, void *data): p_state(nullptr), p_allocf(func), p_aptr(data), p_callhook(), - p_out(&ostd::out), p_err(&ostd::err) + p_out(&ostd::out) { p_state = create(); for (int i = 0; i < MaxArguments; ++i) { @@ -379,18 +379,6 @@ void CsState::set_out(CsStream &s) { p_out = &s; } -CsStream const &CsState::get_err() const { - return *p_err; -} - -CsStream &CsState::get_err() { - return *p_err; -} - -void CsState::set_err(CsStream &s) { - p_err = &s; -} - CsHookCb CsState::set_call_hook(CsHookCb func) { auto hk = ostd::move(p_callhook); p_callhook = ostd::move(func); diff --git a/tools/repl.cc b/tools/repl.cc index edccd27d..0346d69a 100644 --- a/tools/repl.cc +++ b/tools/repl.cc @@ -276,16 +276,13 @@ int main(int argc, char **argv) { CsState gcs; gcs.init_libs(); - gcs.new_command("exec", "sb", [](auto &cs, auto args, auto &res) { + gcs.new_command("exec", "s", [](auto &cs, auto args, auto &) { auto file = args[0].get_strr(); bool ret = cs.run_file(file); if (!ret) { - if (args[1].get_int()) { - cs.get_err().writefln("could not run file \"%s\"", file); - } - res.set_int(0); - } else { - res.set_int(1); + throw cscript::CsErrorException( + cs, "could not run file \"%s\"", file + ); } });