remove get_err/set_err
parent
f12197bbe5
commit
192ce615d8
|
@ -370,10 +370,6 @@ struct OSTD_EXPORT CsState {
|
||||||
CsStream &get_out();
|
CsStream &get_out();
|
||||||
void set_out(CsStream &s);
|
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 set_call_hook(CsHookCb func);
|
||||||
CsHookCb const &get_call_hook() const;
|
CsHookCb const &get_call_hook() const;
|
||||||
CsHookCb &get_call_hook();
|
CsHookCb &get_call_hook();
|
||||||
|
@ -571,7 +567,7 @@ private:
|
||||||
|
|
||||||
CsHookCb p_callhook;
|
CsHookCb p_callhook;
|
||||||
|
|
||||||
CsStream *p_out, *p_err;
|
CsStream *p_out;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CsStackStateNode {
|
struct CsStackStateNode {
|
||||||
|
|
|
@ -255,7 +255,7 @@ void cs_init_lib_base(CsState &cs);
|
||||||
CsState::CsState(CsAllocCb func, void *data):
|
CsState::CsState(CsAllocCb func, void *data):
|
||||||
p_state(nullptr),
|
p_state(nullptr),
|
||||||
p_allocf(func), p_aptr(data), p_callhook(),
|
p_allocf(func), p_aptr(data), p_callhook(),
|
||||||
p_out(&ostd::out), p_err(&ostd::err)
|
p_out(&ostd::out)
|
||||||
{
|
{
|
||||||
p_state = create<CsSharedState>();
|
p_state = create<CsSharedState>();
|
||||||
for (int i = 0; i < MaxArguments; ++i) {
|
for (int i = 0; i < MaxArguments; ++i) {
|
||||||
|
@ -379,18 +379,6 @@ void CsState::set_out(CsStream &s) {
|
||||||
p_out = &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) {
|
CsHookCb CsState::set_call_hook(CsHookCb func) {
|
||||||
auto hk = ostd::move(p_callhook);
|
auto hk = ostd::move(p_callhook);
|
||||||
p_callhook = ostd::move(func);
|
p_callhook = ostd::move(func);
|
||||||
|
|
|
@ -276,16 +276,13 @@ int main(int argc, char **argv) {
|
||||||
CsState gcs;
|
CsState gcs;
|
||||||
gcs.init_libs();
|
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();
|
auto file = args[0].get_strr();
|
||||||
bool ret = cs.run_file(file);
|
bool ret = cs.run_file(file);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
if (args[1].get_int()) {
|
throw cscript::CsErrorException(
|
||||||
cs.get_err().writefln("could not run file \"%s\"", file);
|
cs, "could not run file \"%s\"", file
|
||||||
}
|
);
|
||||||
res.set_int(0);
|
|
||||||
} else {
|
|
||||||
res.set_int(1);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue