Skip to content

Commit

Permalink
Add LUA_FUNCTION_STATIC_MEMBER
Browse files Browse the repository at this point in the history
Acts as replacement for LUA_FUNCTION_IMPLEMENT + LUA_FUNCTION_WRAP
pair
  • Loading branch information
danielga committed Dec 20, 2021
1 parent 1682696 commit 1eb1396
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions include/GarrysMod/Lua/Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,27 @@ struct lua_State
#define LUA_FUNCTION_STATIC_DECLARE( FUNC ) \
static int FUNC( lua_State *L )

#define LUA_FUNCTION_IMPLEMENT( FUNC ) \
#define LUA_FUNCTION_IMPLEMENT( FUNC ) \
[[deprecated("Use LUA_FUNCTION_STATIC_MEMBER instead of LUA_FUNCTION_IMPLEMENT.")]] \
static int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA )

#define LUA_FUNCTION_WRAP( FUNC ) \
LUA_FUNCTION_STATIC_DECLARE( FUNC ) \
{ \
GarrysMod::Lua::ILuaBase* LUA = L->luabase; \
LUA->SetState(L); \
return FUNC##__Imp( LUA ); \
#define LUA_FUNCTION_WRAP( FUNC ) \
[[deprecated("Use LUA_FUNCTION_STATIC_MEMBER instead of LUA_FUNCTION_WRAP.")]] \
static int FUNC( lua_State *L ) \
{ \
GarrysMod::Lua::ILuaBase* LUA = L->luabase; \
LUA->SetState(L); \
return FUNC##__Imp( LUA ); \
}

#define LUA_FUNCTION_STATIC_MEMBER( FUNC ) \
static int FUNC( lua_State* L ) \
{ \
GarrysMod::Lua::ILuaBase* LUA = L->luabase; \
LUA->SetState(L); \
return FUNC##__Imp( LUA ); \
} \
static int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA )
#endif
#endif

Expand Down

0 comments on commit 1eb1396

Please sign in to comment.