aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Luamm.hh
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-07-25 13:42:39 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-11-01 09:57:23 (GMT)
commit145d388c1be2d6f2cd0c68c51448c339ed96371b (patch)
tree466cd7c3d42f57de2faab219f341bf50c0de0428 /src/FbTk/Luamm.hh
parentd91899b389c42e6ce422dcdb3b45963e68be8bc5 (diff)
downloadfluxbox_paul-145d388c1be2d6f2cd0c68c51448c339ed96371b.zip
fluxbox_paul-145d388c1be2d6f2cd0c68c51448c339ed96371b.tar.bz2
Add checkudata and checkargno functions to lua::state
These can be used by functions to check the saneness of arguments. They throw an exception on error. In the future, I might add more informative error messages.
Diffstat (limited to 'src/FbTk/Luamm.hh')
-rw-r--r--src/FbTk/Luamm.hh12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/FbTk/Luamm.hh b/src/FbTk/Luamm.hh
index 110ac97..b75fb12 100644
--- a/src/FbTk/Luamm.hh
+++ b/src/FbTk/Luamm.hh
@@ -131,6 +131,14 @@ namespace lua {
131 {} 131 {}
132 }; 132 };
133 133
134 // thrown by check* functions when they detect an invalid argument
135 class check_error: public std::runtime_error {
136 public:
137 check_error(const std::string &msg)
138 : std::runtime_error(msg)
139 {}
140 };
141
134 // a fancy wrapper around lua_State 142 // a fancy wrapper around lua_State
135 class state { 143 class state {
136 lua_State *cobj; 144 lua_State *cobj;
@@ -264,6 +272,10 @@ namespace lua {
264 // type c, throw everything but the kitchen sink 272 // type c, throw everything but the kitchen sink
265 // call() is a protected mode call, we don't allow unprotected calls 273 // call() is a protected mode call, we don't allow unprotected calls
266 void call(int nargs, int nresults, int errfunc = 0); 274 void call(int nargs, int nresults, int errfunc = 0);
275 void checkargno(int argno) throw(lua::check_error);
276 void *checkudata(int narg, const char *tname) throw(lua::check_error, std::bad_alloc);
277 template<typename T>
278 T *checkudata(int narg, const char *tname) throw(lua::check_error, std::bad_alloc) { return static_cast<T *>(checkudata(narg, tname)); }
267 void concat(int n); 279 void concat(int n);
268 bool equal(int index1, int index2); 280 bool equal(int index1, int index2);
269 int gc(int what, int data); 281 int gc(int what, int data);