lua-users home
lua-l archive

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


Please

Can you remove my name of list or tell how I do

Reynald Lobo - reynaldlobo@hotmail.com




Reinaldo Lobo
>From: Quinn Tyler Jackson <quinn-j@shaw.ca> >Reply-To: Lua list <lua@bazar2.conectiva.com.br> >To: Lua list <lua@bazar2.conectiva.com.br> >Subject: Is this access to Table members "safe"? >Date: Wed, 05 May 2004 20:32:36 -0700 > >In attempting to grok how to access a Lua table's members from within a C++ >callback (via a modified Luna), I came up with this: > > Lua code: > > local a_table = {"apple", "orange"}; > obj:METHOD("blah", a_table); > > C++ code: > >extern "C" >{ > #include "ltable.h" >#include "lstate.h" >} > >// code omitted > > else if(lua_istable(L, -1)) > { > const Table* pTable = (Table*)lua_topointer(L, -1); > const TObject* pString1 = >(TObject*)luaH_getnum((Table*)pTable, 1); > const TObject* pString2 = >(TObject*)luaH_getnum((Table*)pTable, 2); > const TObject* pString3 = >(TObject*)luaH_getn um((Table*)pTable, 3); > > const char* psz1 = svalue(pString1); > const char* psz2 = svalue(pString2); > } > >Now -- is the above code guaranteed to be safe from within a called back >closure for the duration of the callback (i.e., until I return to the Lua >that invoked it)? > >-- >Quinn >


MSN Hotmail, o maior webmail do Brasil. Faça o seu agora.