UGDK
src/ugdk/script/languages/lua/auxlib.h
Go to the documentation of this file.
00001 
00002 #ifndef UGDK_SCRIPT_LUA_AUXLIB_H_
00003 #define UGDK_SCRIPT_LUA_AUXLIB_H_
00004 
00005 #include <ugdk/portable/tr1.h>
00006 #include FROM_TR1(functional)
00007 
00008 #include <ugdk/script/languages/lua/header.h>
00009 #include <ugdk/script/languages/lua/primitive.h>
00010 
00011 namespace ugdk {
00012 namespace script {
00013 namespace lua {
00014 
00015 class State;
00016 
00017 class AuxLib {
00018 
00019   public:
00020 
00021     explicit AuxLib(lua_State* L) : L_(L) {}
00022 
00023     static lua_State* newstate() {
00024         return luaL_newstate();
00025     }
00026 
00027     void openlibs() { luaL_openlibs(L_); }
00028 
00029     const Constant loadfile(const char* filename) {
00030         return Constant(
00031             std::tr1::bind(luaL_loadfile, L_, filename)
00032         );
00033     }
00034 
00035     const Constant loadstring(const char* str) {
00036         return Constant(
00037             std::tr1::bind(luaL_loadstring, L_, str)
00038         );
00039     }
00040 
00041     int checkintteger(int index) { return static_cast<int>(luaL_checkinteger(L_, index)); }
00042     const char* checkstring(int index) { return luaL_checkstring(L_, index); }
00043 
00044     DataID ref(int index) { return luaL_ref(L_, index); }
00045 
00046     void unref(int index, int n) { luaL_unref(L_, index, n); }
00047 
00048   private:
00049 
00050     lua_State* L_;
00051 
00052 };
00053 
00054 } /* namespace lua */
00055 } /* namespace script */
00056 } /* namespace ugdk */
00057 
00058 
00059 #endif /* UGDK_SCRIPT_LUA_AUXLIB_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines