Skip to content

Commit 27a85fd

Browse files
committed
repo: update from holylib
1 parent 20f4d81 commit 27a85fd

File tree

12 files changed

+1511
-516
lines changed

12 files changed

+1511
-516
lines changed

premake5.lua

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,50 @@
33
PROJECT_GENERATOR_VERSION = 3
44

55
newoption({
6-
trigger = "gmcommon",
7-
description = "Sets the path to the garrysmod_common (https://github.com/danielga/garrysmod_common) directory",
8-
default = "../garrysmod_common"
6+
trigger = "gmcommon",
7+
description = "Sets the path to the garrysmod_common (https://github.com/danielga/garrysmod_common) directory",
8+
default = "../garrysmod_common"
99
})
1010

1111
local gmcommon = assert(_OPTIONS.gmcommon or os.getenv("GARRYSMOD_COMMON"),
12-
"you didn't provide a path to your garrysmod_common (https://github.com/danielga/garrysmod_common) directory")
12+
"you didn't provide a path to your garrysmod_common (https://github.com/danielga/garrysmod_common) directory")
1313
include(gmcommon)
1414

1515
CreateWorkspace({name = "httpserver", abi_compatible = false})
16-
-- Serverside module (gmsv prefix)
17-
-- Can define "source_path", where the source files are located
18-
-- Can define "manual_files", which allows you to manually add files to the project,
19-
-- instead of automatically including them from the "source_path"
20-
-- Can also define "abi_compatible", for project specific compatibility
21-
CreateProject({serverside = true, manual_files = false})
22-
-- Remove some or all of these includes if they're not needed
23-
IncludeHelpersExtended()
24-
--IncludeLuaShared()
25-
IncludeSDKCommon()
26-
IncludeSDKTier0()
27-
IncludeSDKTier1()
28-
--IncludeSDKTier3()
29-
--IncludeSDKMathlib()
30-
--IncludeSDKRaytrace()
31-
--IncludeSDKBitmap()
32-
--IncludeSDKVTF()
33-
--IncludeSteamAPI()
34-
--IncludeDetouring()
35-
--IncludeScanning()
36-
37-
filter("system:windows")
38-
files({"source/win32/*.cpp", "source/win32/*.hpp"})
39-
40-
filter("system:linux or macosx")
41-
files({"source/posix/*.cpp", "source/posix/*.hpp"})
42-
filter "system:linux"
43-
44-
links({"dl", "pthread"})
16+
-- Serverside module (gmsv prefix)
17+
-- Can define "source_path", where the source files are located
18+
-- Can define "manual_files", which allows you to manually add files to the project,
19+
-- instead of automatically including them from the "source_path"
20+
-- Can also define "abi_compatible", for project specific compatibility
21+
CreateProject({serverside = true, manual_files = false})
22+
-- Remove some or all of these includes if they're not needed
23+
IncludeHelpersExtended()
24+
--IncludeLuaShared()
25+
IncludeSDKCommon()
26+
IncludeSDKTier0()
27+
IncludeSDKTier1()
28+
--IncludeSDKTier3()
29+
--IncludeSDKMathlib()
30+
--IncludeSDKRaytrace()
31+
--IncludeSDKBitmap()
32+
--IncludeSDKVTF()
33+
--IncludeSteamAPI()
34+
--IncludeDetouring()
35+
--IncludeScanning()
36+
37+
files({
38+
[[source/sourcesdk/*.h]],
39+
})
40+
41+
includedirs({
42+
[[source/sourcesdk/]]
43+
})
44+
45+
filter("system:windows")
46+
files({"source/win32/*.cpp", "source/win32/*.hpp"})
47+
48+
filter("system:linux or macosx")
49+
files({"source/posix/*.cpp", "source/posix/*.hpp"})
50+
filter "system:linux"
51+
52+
links({"dl", "pthread"})

source/LuaInterface.h

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
//
2+
// Unlike normal Garry's Mod Common, his will give us the ILuaInterface instead of the ILuaBase.
3+
//
4+
5+
#ifndef GARRYSMOD_LUA_INTERFACE_H
6+
#define GARRYSMOD_LUA_INTERFACE_H
7+
8+
#include "sourcesdk/ILuaInterface.h"
9+
10+
struct lua_State
11+
{
12+
#if ( defined( _WIN32 ) || defined( __linux__ ) || defined( __APPLE__ ) ) && \
13+
!defined( __x86_64__ ) && !defined( _M_X64 )
14+
// Win32, Linux32 and macOS32
15+
unsigned char _ignore_this_common_lua_header_[48 + 22];
16+
#elif ( defined( _WIN32 ) || defined( __linux__ ) || defined( __APPLE__ ) ) && \
17+
( defined( __x86_64__ ) || defined( _M_X64 ) )
18+
// Win64, Linux64 and macOS64 (not tested)
19+
unsigned char _ignore_this_common_lua_header_[92 + 22];
20+
#else
21+
#error Unsupported platform
22+
#endif
23+
24+
GarrysMod::Lua::ILuaInterface* luabase;
25+
};
26+
27+
#ifndef GMOD
28+
#ifdef _WIN32
29+
#define GMOD_DLL_EXPORT extern "C" __declspec( dllexport )
30+
#else
31+
#define GMOD_DLL_EXPORT extern "C" __attribute__((visibility("default")))
32+
#endif
33+
34+
#ifdef GMOD_ALLOW_DEPRECATED
35+
// Stop using this and use LUA_FUNCTION!
36+
#define LUA ( state->luabase )
37+
38+
#define GMOD_MODULE_OPEN() GMOD_DLL_EXPORT int gmod13_open( [[maybe_unused]] lua_State* state )
39+
#define GMOD_MODULE_CLOSE() GMOD_DLL_EXPORT int gmod13_close( [[maybe_unused]] lua_State* state )
40+
41+
#define LUA_FUNCTION( name ) int name( [[maybe_unused]] lua_State *state )
42+
#define LUA_FUNCTION_STATIC( name ) static LUA_FUNCTION( name )
43+
#else
44+
#define GMOD_MODULE_OPEN() \
45+
int gmod13_open__Imp( GarrysMod::Lua::ILuaInterface* LUA ); \
46+
GMOD_DLL_EXPORT int gmod13_open( lua_State* L ) \
47+
{ \
48+
return gmod13_open__Imp( L->luabase ); \
49+
} \
50+
int gmod13_open__Imp( [[maybe_unused]] GarrysMod::Lua::ILuaInterface* LUA )
51+
52+
#define GMOD_MODULE_CLOSE() \
53+
int gmod13_close__Imp( GarrysMod::Lua::ILuaInterface* LUA ); \
54+
GMOD_DLL_EXPORT int gmod13_close( lua_State* L ) \
55+
{ \
56+
return gmod13_close__Imp( L->luabase ); \
57+
} \
58+
int gmod13_close__Imp( [[maybe_unused]] GarrysMod::Lua::ILuaInterface* LUA )
59+
60+
#define LUA_FUNCTION( FUNC ) \
61+
int FUNC##__Imp( GarrysMod::Lua::ILuaInterface* LUA ); \
62+
int FUNC( lua_State* L ) \
63+
{ \
64+
GarrysMod::Lua::ILuaInterface* LUA = L->luabase; \
65+
LUA->SetState(L); \
66+
return FUNC##__Imp( LUA ); \
67+
} \
68+
int FUNC##__Imp( [[maybe_unused]] GarrysMod::Lua::ILuaInterface* LUA )
69+
70+
#define LUA_FUNCTION_STATIC( FUNC ) \
71+
static int FUNC##__Imp( GarrysMod::Lua::ILuaInterface* LUA ); \
72+
static int FUNC( lua_State* L ) \
73+
{ \
74+
GarrysMod::Lua::ILuaInterface* LUA = L->luabase; \
75+
LUA->SetState(L); \
76+
return FUNC##__Imp( LUA ); \
77+
} \
78+
static int FUNC##__Imp( [[maybe_unused]] GarrysMod::Lua::ILuaInterface* LUA )
79+
80+
#define LUA_FUNCTION_DECLARE( FUNC ) \
81+
int FUNC( lua_State *L )
82+
83+
#define LUA_FUNCTION_STATIC_DECLARE( FUNC ) \
84+
static int FUNC( lua_State *L )
85+
86+
#define LUA_FUNCTION_IMPLEMENT( FUNC ) \
87+
[[deprecated("Use LUA_FUNCTION_STATIC_MEMBER instead of LUA_FUNCTION_IMPLEMENT.")]] \
88+
static int FUNC##__Imp( [[maybe_unused]] GarrysMod::Lua::ILuaInterface* LUA )
89+
90+
#define LUA_FUNCTION_WRAP( FUNC ) \
91+
[[deprecated("Use LUA_FUNCTION_STATIC_MEMBER instead of LUA_FUNCTION_WRAP.")]] \
92+
static int FUNC( lua_State *L ) \
93+
{ \
94+
GarrysMod::Lua::ILuaInterface* LUA = L->luabase; \
95+
LUA->SetState(L); \
96+
return FUNC##__Imp( LUA ); \
97+
}
98+
99+
#define LUA_FUNCTION_STATIC_MEMBER( FUNC ) \
100+
static int FUNC( lua_State* L ) \
101+
{ \
102+
GarrysMod::Lua::ILuaInterface* LUA = L->luabase; \
103+
LUA->SetState(L); \
104+
return FUNC##__Imp( LUA ); \
105+
} \
106+
static int FUNC##__Imp( GarrysMod::Lua::ILuaInterface* LUA )
107+
#endif
108+
#endif
109+
110+
#endif

0 commit comments

Comments
 (0)