I am looking at embedding Lua in a C++ application I am developing. My intention is to use Lua to script what ordered operation(s) to perform for some given input, ie. receive a new work item in c++ program, pass details to Lua backend, Lua calls back into c++ to carry out necessary work, returns finished results.
The primary data structure involved is a large (approx 80+ members) struct
. I am (very) new to Lua and am unsure of how I can pass it to and from my host application and the embedded Lua state.
Thus far I see my options as:
a) Pushing/Popping all the individual data members onto the stack when crossing to/from C++ and Lua (sounds messy).
b) Constructing a table and populating with the values, then putting that on/off the stack (a little cleaner).
c) Pass it as userdata
(light/heavy?) (I'm sketchy on this, and not sure if/how I can then access it from the Lua side to query what operations are necessary).
Any guidance would be greatly appreciated.