From 83eb47e6880c4ddea14c6712d804113a61da3057 Mon Sep 17 00:00:00 2001 From: q66 Date: Sat, 8 Aug 2015 16:13:46 +0100 Subject: [PATCH] namespace --- command.cc | 8 +++----- command.hh | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/command.cc b/command.cc index 2f594b3..c88295d 100644 --- a/command.cc +++ b/command.cc @@ -1,5 +1,7 @@ #include "command.hh" +namespace cscript { + static inline bool check_num(const char *s) { if (isdigit(s[0])) return true; @@ -4551,8 +4553,4 @@ void init_lib_string(CsState &cs) { }); } -void init_lib_shell(CsState &cs) { - cs.add_command("shell", "C", [](CsState &cs, char *s) { - cs.result->set_int(system(s)); - }); -} \ No newline at end of file +} /* namespace cscript */ \ No newline at end of file diff --git a/command.hh b/command.hh index 225d584..12c1b93 100644 --- a/command.hh +++ b/command.hh @@ -18,6 +18,8 @@ #include #include +namespace cscript { + inline char *dup_ostr(ostd::ConstCharRange s) { char *r = new char[s.size() + 1]; memcpy(r, s.data(), s.size()); @@ -491,10 +493,10 @@ static inline const char *get_str(const IdentValue &v, int type) { } } inline const char *TaggedValue::get_str() const { - return ::get_str(*this, type); + return cscript::get_str(*this, type); } inline const char *Ident::get_str() const { - return ::get_str(val, valtype); + return cscript::get_str(val, valtype); } #define GETNUMBER(name, ret) \ @@ -508,8 +510,8 @@ inline const char *Ident::get_str() const { default: return ret(0); \ } \ } \ - inline ret TaggedValue::get_##name() const { return ::get_##name(*this, type); } \ - inline ret Ident::get_##name() const { return ::get_##name(val, valtype); } + inline ret TaggedValue::get_##name() const { return cscript::get_##name(*this, type); } \ + inline ret Ident::get_##name() const { return cscript::get_##name(val, valtype); } GETNUMBER(int, int) GETNUMBER(float, float) @@ -533,10 +535,10 @@ static inline void get_val(const IdentValue &v, int type, TaggedValue &r) { } inline void TaggedValue::get_val(TaggedValue &r) const { - ::get_val(*this, type, r); + cscript::get_val(*this, type, r); } inline void Ident::get_val(TaggedValue &r) const { - ::get_val(val, valtype, r); + cscript::get_val(val, valtype, r); } inline void Ident::getcstr(TaggedValue &v) const { @@ -595,7 +597,6 @@ void init_lib_io(CsState &cs); void init_lib_math(CsState &cs); void init_lib_string(CsState &cs); void init_lib_list(CsState &cs); -void init_lib_shell(CsState &cs); namespace util { template @@ -625,4 +626,6 @@ namespace util { writer.put('"'); return ret; } -} \ No newline at end of file +} + +} /* namespace cscript */ \ No newline at end of file