|
11 | 11 |
|
12 | 12 | struct lua_State; |
13 | 13 |
|
14 | | -extern "C" |
15 | | -{ |
16 | | - void lua_getfenv( lua_State *L, int idx ); |
17 | | - int lua_setfenv( lua_State *L, int idx ); |
18 | | - const char *lua_pushvfstring( lua_State *L, const char *fmt, va_list argp ); |
19 | | - int lua_error( lua_State *L ); |
20 | | - int luaL_typerror( lua_State *L, int narg, const char *tname ); |
21 | | - const void *lua_topointer( lua_State *L, int idx ); |
22 | | - int luaL_callmeta( lua_State *L, int idx, const char *e ); |
23 | | -} |
24 | | - |
25 | 14 | namespace GarrysMod |
26 | 15 | { |
27 | 16 | namespace Lua |
28 | 17 | { |
| 18 | + extern "C" |
| 19 | + { |
| 20 | + void lua_getfenv( lua_State *L, int idx ); |
| 21 | + int lua_setfenv( lua_State *L, int idx ); |
| 22 | + const char *lua_pushvfstring( lua_State *L, const char *fmt, va_list argp ); |
| 23 | + int lua_error( lua_State *L ); |
| 24 | + int luaL_typerror( lua_State *L, int narg, const char *tname ); |
| 25 | + const void *lua_topointer( lua_State *L, int idx ); |
| 26 | + int luaL_callmeta( lua_State *L, int idx, const char *e ); |
| 27 | + } |
| 28 | + |
29 | 29 | typedef int ( *CFunc )( lua_State* L ); |
30 | 30 |
|
| 31 | + // For use with ILuaBase::PushSpecial |
| 32 | + enum |
| 33 | + { |
| 34 | + SPECIAL_GLOB, // Global table |
| 35 | + SPECIAL_ENV, // Environment table |
| 36 | + SPECIAL_REG, // Registry table |
| 37 | + }; |
| 38 | + |
| 39 | + // Use these when calling ILuaBase::GetField or ILuaBase::SetField for example, |
| 40 | + // instead of pushing the specified table |
| 41 | + enum |
| 42 | + { |
| 43 | + INDEX_GLOBAL = -10002, // Global table |
| 44 | + INDEX_ENVIRONMENT, // Environment table |
| 45 | + INDEX_REGISTRY, // Registry table |
| 46 | + }; |
| 47 | + |
31 | 48 | // |
32 | 49 | // Use this to communicate between C and Lua |
33 | 50 | // |
@@ -407,26 +424,15 @@ namespace GarrysMod |
407 | 424 | return luaL_callmeta( state, iStackPos, e ); |
408 | 425 | } |
409 | 426 |
|
| 427 | + // Produces the pseudo-index of an upvalue at iPos |
| 428 | + static inline int GetUpvalueIndex( int iPos ) |
| 429 | + { |
| 430 | + return static_cast<int>( INDEX_GLOBAL ) - iPos; |
| 431 | + } |
| 432 | + |
410 | 433 | private: |
411 | 434 | lua_State *state; |
412 | 435 | }; |
413 | | - |
414 | | - // For use with ILuaBase::PushSpecial |
415 | | - enum |
416 | | - { |
417 | | - SPECIAL_GLOB, // Global table |
418 | | - SPECIAL_ENV, // Environment table |
419 | | - SPECIAL_REG, // Registry table |
420 | | - }; |
421 | | - |
422 | | - // Use these when calling ILuaBase::GetField or ILuaBase::SetField for example, |
423 | | - // instead of pushing the specified table |
424 | | - enum |
425 | | - { |
426 | | - INDEX_GLOBAL = -10002, // Global table |
427 | | - INDEX_ENVIRONMENT, // Environment table |
428 | | - INDEX_REGISTRY, // Registry table |
429 | | - }; |
430 | 436 | } |
431 | 437 | } |
432 | 438 |
|
|
0 commit comments