|
Hello there,
I recall lua scripts from C++. I run version 5.0.2 of lua.
I'm using the require function from a C++ program to load lua functions
and everything seems to work fine.
As I read,
<<require keeps="" a="" table="" with="" the="" names="" of="" all="" loaded="" files.="" if=""
required="" file="" is="" already="" in="" table,="" require="" simply="" returns.="" so="" i=""
overwrite="" lua="" containing="" function,="" to="" get="" new="" version=""
must="" restart="" program.=""
as="" read="" manual,="" after="" successful="" require"foo",=""
_loaded["foo"]="" will="" not="" be="" nil.="" you="" then="" assign="" nil=""
_loaded["foo"],="" subsequent="" require"foo"="" run="" again.="">>
With this in mind, my aim was to do something like
_LOADED[funcname] = nil everytime I overwrite the file.
My problem is that I'm not able to access this table from my C
program, i.e. I do something like
lua_getglobal(L, "_LOADED");
if (!lua_istable(L, -1))
{printf"_LOADED is not a valid table"); exit(0);}
n = lua_getn(L, -1); n IS ALWAYS ZERO !!!!!!
I try to read my element in the following way:
lua_getglobal(L, "_LOADED");
if (!lua_istable(L, -1))
{printf"_LOADED is not a valid table"); exit(0);}
lua_pushstring(L, funcname);
lua_gettable(L, -2);
if (!lua_isstring(L, -1))
printf("invalid component in _LOADED");
else
myname = lua_tostring(L, -1);
lua_pop(L, 1);
But I always get the message invalid component.
I run the require function before so I expected to find something in
the _LOADED table.
Can anybody please help me to change the _LOADED[] table values from
my C program.
Thank you in advance
marcof
|
|
|
|
|
Hello everybody
How can I test an auto_ptr/shared_ptr to NULL or zero ? If it makes sense.
My situation is the following:
std::auto_ptr<abstractevent> pevent(DequeEvent());
if (pevent == NULL) return;
....
where AbstractEvent is an Abstract class for various I/O event types.
and AbstractEvent *DequeEvent() dequeues events.
Coming from C, I would do
AbstractEvent *pevent;
pevent = DequeEvent();
if (pevent == NULL) return;
Thank you
Marco
marcof
|
|
|
|