author | Francesco Abbate <francesco.bbt@gmail.com> | 2012年10月15日 13:11:54 +0200 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2012年10月15日 13:11:54 +0200 |
commit | 137e4d264c73b3087a5d0968362c5b9ca3108f2d (patch) | |
tree | a80691d187615ec2e63f25182be7895b9a8a313f /agg-plot/lua-cpp-utils.h | |
parent | 7d157c5bd8ddf920094907a35c9329ce0688e3d4 (diff) | |
download | gsl-shell-137e4d264c73b3087a5d0968362c5b9ca3108f2d.tar.gz |
-rw-r--r-- | agg-plot/lua-cpp-utils.h | 42 |
diff --git a/agg-plot/lua-cpp-utils.h b/agg-plot/lua-cpp-utils.h index 5b7f754f..8f18d5a9 100644 --- a/agg-plot/lua-cpp-utils.h +++ b/agg-plot/lua-cpp-utils.h @@ -13,58 +13,64 @@ __END_DECLS namespace gslshell { - class ret_status { +class ret_status { bool m_success; const char *m_error_msg; const char *m_context; - public: +public: ret_status() : m_success(true) {}; - void success() { m_success = true; } + void success() { + m_success = true; + } void error(const char *msg, const char *ctx) { - m_success = false; - m_error_msg = msg; - m_context = ctx; + m_success = false; + m_error_msg = msg; + m_context = ctx; }; - const char *error_msg() const { return (m_success ? 0 : m_error_msg); }; - const char *context() const { return (m_success ? 0 : m_context); }; - }; + const char *error_msg() const { + return (m_success ? 0 : m_error_msg); + }; + const char *context() const { + return (m_success ? 0 : m_context); + }; +}; } inline void* operator new(size_t nbytes, lua_State *L, enum gs_type_e tp) { - void* p = lua_newuserdata(L, nbytes); - gs_set_metatable (L, tp); - return p; + void* p = lua_newuserdata(L, nbytes); + gs_set_metatable (L, tp); + return p; } template <class T> T* push_new_object (lua_State *L, enum gs_type_e tp) { - return new(L, tp) T(); + return new(L, tp) T(); } template <class T, class init_type> T* push_new_object (lua_State *L, enum gs_type_e tp, init_type& init) { - return new(L, tp) T(init); + return new(L, tp) T(init); } template <class T> int object_free (lua_State *L, int index, enum gs_type_e tp) { - T *obj = (T *) gs_check_userdata (L, index, tp); - obj->~T(); - return 0; + T *obj = (T *) gs_check_userdata (L, index, tp); + obj->~T(); + return 0; } template <class T> T* object_check (lua_State *L, int index, enum gs_type_e tp) { - return (T *) gs_check_userdata (L, index, tp); + return (T *) gs_check_userdata (L, index, tp); } #endif |