33 #ifndef LUA_PARSING_H_
34 #define LUA_PARSING_H_
39 #include "externals/lua/lua.h"
56 return lua_isboolean(L, index);
59 return lua_toboolean(L, index);
62 lua_pushboolean(L, (data ? 1 : 0));
69 return lua_isnumber(L, index);
72 return (
int)lua_tointeger(L, index);
75 lua_pushnumber(L, data);
82 return lua_isnumber(L, index);
85 return lua_tointeger(L, index);
88 lua_pushnumber(L, (lua_Number)data);
95 return lua_isnumber(L, index);
98 return (
float)lua_tonumber(L, index);
101 lua_pushnumber(L, data);
108 return lua_isnumber(L, index);
111 return lua_tonumber(L, index);
114 lua_pushnumber(L, data);
121 return lua_isstring(L, index);
124 return lua_tostring(L, index);
127 lua_pushstring(L, data);
134 return lua_isstring(L, index);
137 return std::string(lua_tostring(L, index));
140 lua_pushstring(L, data.c_str());
147 return lua_isstring(L, index);
150 lua_pushstring(L, data.c_str());
157 static bool check(
lua_State* L,
int index){
158 return lua_isfunction(L, index);
162 lua_pushvalue(L, index);
163 tmp.
ref = luaL_ref(L, LUA_REGISTRYINDEX);
166 static void push(
lua_State* L, LuaFunctionHandle data){
167 UG_THROW(
"Return value of type LuaFunctionHandle not implemented.");
172 struct LuaParsing<LuaTableHandle>{
173 static bool check(
lua_State* L,
int index){
174 return lua_istable(L, index);
177 LuaTableHandle tmp(L, index);
181 static void push(
lua_State* L, LuaTableHandle data){
182 UG_THROW(
"Return value of type LuaTableHandle not implemented.");
189 static bool checkAndGet(std::pair<void*, const ClassNameNode*>& res,
190 lua_State* L,
int index,
const char* baseClassName){
191 if(!lua_isuserdata(L, index))
return false;
209 if(lua_getmetatable(L, index) == 0)
return false;
211 lua_pushstring(L,
"class_name_node");
216 if(!classNameNode)
return false;
217 if(classNameNode->
empty())
return false;
221 res.second = classNameNode;
233 static bool checkAndGet(std::pair<const void*, const ClassNameNode*>& res,
234 lua_State* L,
int index,
const char* baseClassName){
235 if(!lua_isuserdata(L, index))
return false;
242 const void* obj = NULL;
257 if(lua_getmetatable(L, index) == 0)
return false;
259 lua_pushstring(L,
"class_name_node");
264 if(!classNameNode)
return false;
265 if(classNameNode->
empty())
return false;
269 res.second = classNameNode;
284 lua_State* L,
int index,
const char* baseClassName){
285 if(!lua_isuserdata(L, index))
return false;
295 if(lua_getmetatable(L, index) == 0)
return false;
296 lua_pushstring(L,
"class_name_node");
301 if(!classNameNode)
return false;
302 if(classNameNode->
empty())
return false;
306 res.second = classNameNode;
319 lua_State* L,
int index,
const char* baseClassName){
320 if(!lua_isuserdata(L, index))
return false;
333 if(lua_getmetatable(L, index) == 0)
return false;
334 lua_pushstring(L,
"class_name_node");
339 if(!classNameNode)
return false;
340 if(classNameNode->
empty())
return false;
344 res.second = classNameNode;
Definition: smart_pointer.h:650
const void * get() const
Definition: smart_pointer.h:789
Definition: smart_pointer.h:296
Definition: smart_pointer.h:525
void * get()
Definition: smart_pointer.h:625
Definition: smart_pointer.h:108
Handle for a lua reference.
Definition: lua_function_handle.h:40
int ref
Definition: lua_function_handle.h:42
node for class names
Definition: class_name_provider.h:65
bool empty() const
returns if a name has been set
Definition: class_name_provider.h:80
bool ClassNameTreeContains(const ClassNameNode &node, const std::string &name)
returns if a name is contained in the name tree at node or in base classes
Definition: class_name_provider.cpp:104
#define UG_THROW(msg)
Definition: error.h:57
#define untested()
Definition: lua_table_handle.cpp:15
struct lua_State lua_State
Definition: lua_table_handle.h:40
SM_edge_weight_map< typename T::value_type, ug::BidirectionalMatrix< T > > get(edge_weight_t, ug::BidirectionalMatrix< T > const &g)
Definition: bidirectional_boost.h:157
Definition: smart_pointer.h:814
const bool IMLPICIT_SMART_PTR_TO_PTR_CONVERSION
Definition: bindings_lua.cpp:129
SmartUserDataWrapper * CreateNewUserData(lua_State *L, const SmartPtr< void > &ptr, const char *metatableName)
creates a new UserDataWrapper and associates it with ptr in luas registry
Definition: bindings_lua.cpp:174
Definition: bindings_lua.h:78
ConstSmartPtr< void > smartPtr
Definition: bindings_lua.h:79
static void push(lua_State *L, ConstSmartPtr< void > data, const char *className)
Definition: lua_parsing.h:349
static bool checkAndGet(std::pair< ConstSmartPtr< void >, const ClassNameNode * > &res, lua_State *L, int index, const char *baseClassName)
Definition: lua_parsing.h:318
static bool checkAndGet(std::pair< SmartPtr< void >, const ClassNameNode * > &res, lua_State *L, int index, const char *baseClassName)
Definition: lua_parsing.h:283
static void push(lua_State *L, SmartPtr< void > data, const char *className)
Definition: lua_parsing.h:311
static bool check(lua_State *L, int index)
Definition: lua_parsing.h:55
static bool get(lua_State *L, int index)
Definition: lua_parsing.h:58
static void push(lua_State *L, bool data)
Definition: lua_parsing.h:61
static const char * get(lua_State *L, int index)
Definition: lua_parsing.h:123
static void push(lua_State *L, const char *data)
Definition: lua_parsing.h:126
static bool check(lua_State *L, int index)
Definition: lua_parsing.h:120
static void push(lua_State *L, const std::string &data)
Definition: lua_parsing.h:149
static bool check(lua_State *L, int index)
Definition: lua_parsing.h:146
static bool checkAndGet(std::pair< const void *, const ClassNameNode * > &res, lua_State *L, int index, const char *baseClassName)
Definition: lua_parsing.h:233
static void push(lua_State *L, const void *data, const char *className)
Definition: lua_parsing.h:274
static bool check(lua_State *L, int index)
Definition: lua_parsing.h:107
static void push(lua_State *L, double data)
Definition: lua_parsing.h:113
static double get(lua_State *L, int index)
Definition: lua_parsing.h:110
static void push(lua_State *L, float data)
Definition: lua_parsing.h:100
static bool check(lua_State *L, int index)
Definition: lua_parsing.h:94
static float get(lua_State *L, int index)
Definition: lua_parsing.h:97
static bool check(lua_State *L, int index)
Definition: lua_parsing.h:68
static int get(lua_State *L, int index)
Definition: lua_parsing.h:71
static void push(lua_State *L, int data)
Definition: lua_parsing.h:74
static void push(lua_State *L, size_t data)
Definition: lua_parsing.h:87
static size_t get(lua_State *L, int index)
Definition: lua_parsing.h:84
static bool check(lua_State *L, int index)
Definition: lua_parsing.h:81
static std::string get(lua_State *L, int index)
Definition: lua_parsing.h:136
static void push(lua_State *L, std::string data)
Definition: lua_parsing.h:139
static bool check(lua_State *L, int index)
Definition: lua_parsing.h:133
static bool checkAndGet(std::pair< void *, const ClassNameNode * > &res, lua_State *L, int index, const char *baseClassName)
Definition: lua_parsing.h:189
static void push(lua_State *L, void *data, const char *className)
Definition: lua_parsing.h:226
Definition: lua_parsing.h:51
Definition: bindings_lua.h:83
void * obj
Definition: bindings_lua.h:84
Definition: bindings_lua.h:73
SmartPtr< void > smartPtr
Definition: bindings_lua.h:74
Definition: bindings_lua.h:64
bool is_const()
Definition: bindings_lua.h:67
bool is_raw_ptr()
Definition: bindings_lua.h:68
bool is_smart_ptr()
Definition: bindings_lua.h:69