lua-users home
lua-l archive

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

I'm trying to make a small change to the Lua
functionality and I'm having trouble figure out how to
do it, hoping someone here has tried something

I'd like to use Lua as a "component description
language", that is I'd like to write files like this:

    param1="some value",
    param2="another value"

"ComponentType" is a C function that creates a new
instance of the component and initializes it from the
table data, then returns the C++ component wrapped in
Lua table (something like Luna).

I load the component by calling a
loadComponent(filename) function, which basically does
a lua_dofile() to run the chunk. The problem is, after
the chunk has run, I want to retrieve the newly
created table from Lua so I can extract the C++
pointer to return from the loadComponent() function.
If I do this:

  return ComponentType{ ... }

The table is pushed on the stack and everything works
great, but it would be nicer if I didn't need the
return. Has anyone modified Lua to implicitly pick up
the function return value and return it from the
chunk? Or any pointers on how I might go about doing

Thanks for the help,

Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices