Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added/Updated some things #115

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions include/GarrysMod/Lua/Interface.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#ifndef GARRYSMOD_LUA_INTERFACE_H
#define GARRYSMOD_LUA_INTERFACE_H

#ifdef GMOD_USE_ILUAINTERFACE
#include "LuaInterface.h"
#define GMOD_LUACLASS GarrysMod::Lua::ILuaInterface*
#else
#include "LuaBase.h"
#define GMOD_LUACLASS GarrysMod::Lua::ILuaBase*
#endif

struct lua_State
{
Expand All @@ -17,7 +23,7 @@ struct lua_State
#error Unsupported platform
#endif

GarrysMod::Lua::ILuaBase* luabase;
GMOD_LUACLASS luabase;
};

#ifndef GMOD
Expand All @@ -38,40 +44,40 @@ struct lua_State
#define LUA_FUNCTION_STATIC( name ) static LUA_FUNCTION( name )
#else
#define GMOD_MODULE_OPEN() \
int gmod13_open__Imp( GarrysMod::Lua::ILuaBase* LUA ); \
int gmod13_open__Imp( GMOD_LUACLASS LUA ); \
GMOD_DLL_EXPORT int gmod13_open( lua_State* L ) \
{ \
return gmod13_open__Imp( L->luabase ); \
} \
int gmod13_open__Imp( [[maybe_unused]] GarrysMod::Lua::ILuaBase* LUA )
int gmod13_open__Imp( [[maybe_unused]] GMOD_LUACLASS LUA )

#define GMOD_MODULE_CLOSE() \
int gmod13_close__Imp( GarrysMod::Lua::ILuaBase* LUA ); \
int gmod13_close__Imp( GMOD_LUACLASS LUA ); \
GMOD_DLL_EXPORT int gmod13_close( lua_State* L ) \
{ \
return gmod13_close__Imp( L->luabase ); \
} \
int gmod13_close__Imp( [[maybe_unused]] GarrysMod::Lua::ILuaBase* LUA )
int gmod13_close__Imp( [[maybe_unused]] GMOD_LUACLASS LUA )

#define LUA_FUNCTION( FUNC ) \
int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA ); \
int FUNC##__Imp( GMOD_LUACLASS LUA ); \
int FUNC( lua_State* L ) \
{ \
GarrysMod::Lua::ILuaBase* LUA = L->luabase; \
GMOD_LUACLASS LUA = L->luabase; \
LUA->SetState(L); \
return FUNC##__Imp( LUA ); \
} \
int FUNC##__Imp( [[maybe_unused]] GarrysMod::Lua::ILuaBase* LUA )
int FUNC##__Imp( [[maybe_unused]] GMOD_LUACLASS LUA )

#define LUA_FUNCTION_STATIC( FUNC ) \
static int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA ); \
static int FUNC##__Imp( GMOD_LUACLASS LUA ); \
static int FUNC( lua_State* L ) \
{ \
GarrysMod::Lua::ILuaBase* LUA = L->luabase; \
GMOD_LUACLASS LUA = L->luabase; \
LUA->SetState(L); \
return FUNC##__Imp( LUA ); \
} \
static int FUNC##__Imp( [[maybe_unused]] GarrysMod::Lua::ILuaBase* LUA )
static int FUNC##__Imp( [[maybe_unused]] GMOD_LUACLASS LUA )

#define LUA_FUNCTION_DECLARE( FUNC ) \
int FUNC( lua_State *L )
Expand All @@ -81,25 +87,25 @@ struct lua_State

#define LUA_FUNCTION_IMPLEMENT( FUNC ) \
[[deprecated("Use LUA_FUNCTION_STATIC_MEMBER instead of LUA_FUNCTION_IMPLEMENT.")]] \
static int FUNC##__Imp( [[maybe_unused]] GarrysMod::Lua::ILuaBase* LUA )
static int FUNC##__Imp( [[maybe_unused]] GMOD_LUACLASS 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; \
GMOD_LUACLASS 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; \
GMOD_LUACLASS LUA = L->luabase; \
LUA->SetState(L); \
return FUNC##__Imp( LUA ); \
} \
static int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA )
static int FUNC##__Imp( GMOD_LUACLASS LUA )
#endif
#endif

Expand Down
Loading