lua-users home
lua-l archive

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


Hi,

okay I think I need to explain a little bit more:

I run on different machines a Lua script, the script has got a function like

function iterate( data )
     // doing something with data
      return data
end

The script runs on a cluster system (MPI), so I need to transfer the data of the Lua
script to all other hosts. The user, that has written the Lua script, can return
every Lua type, so I need not to know which data are returned of the script. 
I need only the "data memory block" and send the block to the other hosts, which
are pushed the data into the lua pcall function for iterating the Lua script

On the C/C++ side I don't need any knowledge about the returned data, I must
store the data, and send them via MPI to the other hosts and the data is pushed
into the lua_pcall function

Thanks

Phil




Am 14.12.2012 um 11:22 schrieb Mak Nazečić-Andrlon:

Why do you wish to do this? Perhaps there is a better way of accomplishing what you really want to do.

Also, in the case case your two states are really threads of a single global state, you can use lua_xmove() to move stack values between them.


On Fri, Dec 14, 2012 at 10:50 AM, Philipp Kraus <philipp.kraus@flashpixx.de> wrote:
Hello,

I'm using two different Lua states and I would like to copy a return argument of a Lua script function via C API into the other state eg:

--Lua script 1--

function test()
    return {1,2,3}
end

--Lua script 2--
   function test2( ... )
   end

On the first function the return argument can be changed, like return "test".
I would like to read the stack in C without any converting into C types:

lua_pcall( state1, ....)

std::vector<lua_types> l_data;
l_data.push_back( <put stack values from stat1>   );

push_to_stack( state2, l_data.last() );
lua_pcall( state2, ...)


I would get all return arguments in one structure independed of their types and push
them into another state

Can I read the return arguments into one memory block eg?

Thanks

Phil