Skip to content
Snippets Groups Projects
Commit 602c73b2 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

improve lua bindings of std::vector

parent 41a43918
No related branches found
No related tags found
No related merge requests found
......@@ -142,13 +142,19 @@ class luaStack<std::vector<type > >{
size_t size=lua_objlen(L,ia);
v.resize(size);
for(size_t i=0;i<size;i++){
lua_pushinteger(L,i+1);
lua_gettable(L,ia);
lua_rawgeti(L, ia, i+1);
v[i]=luaStack<type>::get(L,-1);
lua_pop(L,1);
}
return v;
}
static void push(lua_State *L, const std::vector<type>& v){
lua_createtable(L, v.size(), 0);
for(size_t i=0;i<v.size;i++){
luaStack<type>::push(L,v[i]);
lua_rawseti(L, 2, i+1);
}
}
static std::string getName(){
std::string name="vector of ";
return name+luaStack<type>::getName();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment