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); }*/
| 93 | incr_top;//(L); |
| 94 | }*/ |
| 95 | IScriptObject *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 */ |
no test coverage detected