MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / GetLocalVariables

Method GetLocalVariables

CryScriptSystem/ScriptSystem.cpp:95–131  ·  view source on GitHub ↗

LUA_API void alberto_pushfunc(lua_State *L, HSCRIPTFUNCTION func) { L->top->value.cl =(struct Closure *) func; ttype(L->top) = LUA_TFUNCTION; incr_top;//(L); }*/

Source from the content-addressed store, hash-verified

93incr_top;//(L);
94}*/
95IScriptObject *CScriptSystem::GetLocalVariables(int nLevel)
96{
97 Validate();
98 IScriptObject *pObj;
99 lua_Debug ar;
100 nLevel=0;
101 const char *name;
102 lua_newtable(m_pLS);
103 int nTable=lua_ref(m_pLS,1);
104 lua_getref(m_pLS,nTable);
105 pObj=CreateEmptyObject();
106 pObj->Attach();
107 while(lua_getstack(m_pLS, nLevel, &ar) != 0)
108 {
109 //return 0; /* failure: no such level in the stack */
110
111 //create a table and fill it with the local variables (name,value)
112
113 int i = 1;
114 while ((name = lua_getlocal(m_pLS, &ar, i)) != NULL)
115 {
116 lua_getref(m_pLS,nTable);
117 lua_pushstring(m_pLS,name);
118 //::OutputDebugString(name);
119 //::OutputDebugString("\n");
120 lua_pushvalue(m_pLS,-3);
121 lua_rawset(m_pLS,-3);
122 //pop table and value
123 lua_pop(m_pLS,2);
124 i++;
125 }
126 nLevel++;
127 }
128
129 Validate();
130 return pObj;
131}
132
133#define LEVELS1 12 /* size of the first part of the stack */
134#define LEVELS2 10 /* size of the second part of the stack */

Callers 1

GetStackAndLocalsMethod · 0.80

Calls 9

lua_newtableFunction · 0.85
lua_refFunction · 0.85
lua_getrefFunction · 0.85
lua_getstackFunction · 0.85
lua_getlocalFunction · 0.85
lua_pushstringFunction · 0.85
lua_pushvalueFunction · 0.85
lua_rawsetFunction · 0.85
AttachMethod · 0.45

Tested by

no test coverage detected