[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Implicit return from chunk
- From: "J. Perkins" <jason379com@...>
- Date: Tue, 24 Apr 2001 10:37:12 -0700 (PDT)
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
similar.
I'd like to use Lua as a "component description
language", that is I'd like to write files like this:
ComponentType
{
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
that?
Thanks for the help,
Jason
379
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/