lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Tim,

nice answer :-P
My first try is that I copy value-by-value into LUA and update my object after LUA has been finished. This very slow, so I have seen the user-defined type, if i understand it correct, it is a "native" pointer in LUA.
For arrays (continous memory block) I can use the pointer directly ( http://www.lua.org/pil/28.1.html ).
My question is, in which way would you create access to a std::map ?
I should be nice, that I can use a std::map in LUA like luamap[key] = value and I would like to create a C++ template for create a translation structure for any typ of map into LUA.
Would you create for each typo a structure like shown in the chapter 28.1?

Thanks

Phil

Am 09.06.2013 um 14:56 schrieb Tim Hill:

Qualified yes, depending on what you mean by "directly".

Lua cannot access userdata items directly (that is by design, its not supposed to!). However, you can write your own C/C++ functions and wire them into Lua, then call these functions from Lua, passing the userdata.

--Tim

On Jun 9, 2013, at 4:27 AM, Philipp Kraus <philipp.kraus@flashpixx.de> wrote:

Hello,

I have got multidimensional cubes in C++ and would like to push them into LUA. I would like to create a structure in LUA like
data[i][j][n] = 123

The data can be any type (most numerical types). Also I have got std::maps with strings and cubes eg std::map <std::string, cube<doube,3> >
Is there a solution to get access to the data in LUA without copying? I would like to modify the data from the LUA script direct in the memory,
because the datablocks are very large.

I have found the user-defined type (pointer to my memory), but I have tested it with array (std::vector) only, so in my case I have complex data
structures, eg I would like to modify my std::map direct from LUA.

Hope for some ideas :-)
Thanks

Phil