Skip to content

Commit

Permalink
Rework exporting and importing APIs for different modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamyCecil committed Jun 12, 2024
1 parent 2b035bd commit b859216
Show file tree
Hide file tree
Showing 23 changed files with 46 additions and 122 deletions.
5 changes: 0 additions & 5 deletions Sources/DedicatedServer/DedicatedServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#include "StdAfx.h"
#include <GameMP/Game.h>
#define DECL_DLL

#if 0 /* rcg10042001 Doesn't seem to exist. */
#include <Entities/Global.h>
#endif

// application state variables
extern BOOL _bRunning = TRUE;
Expand Down
16 changes: 0 additions & 16 deletions Sources/DedicatedServer/StdAfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,4 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */

#include <Engine/Engine.h>
#include <Engine/Templates/Stock_CTextureData.h>
#include <Engine/Templates/Stock_CModelData.h>
#include <GameMP/Game.h>

/* rcg10042001 protect against Visual C-isms. */
#if SE1_WIN
#define DECL_DLL __declspec(dllimport)
#elif SE1_UNIX
#define DECL_DLL
#endif

#include <EntitiesMP/Global.h>
#include <EntitiesMP/Common/Common.h>
#include <EntitiesMP/Common/GameInterface.h>
#include <EntitiesMP/Player.h>

#undef DECL_DLL
2 changes: 1 addition & 1 deletion Sources/Engine/Base/Assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#else /* ndef _NTSDK */
/* current definition */
#ifdef _DLL
#define _CRTIMP __declspec(dllimport)
#define _CRTIMP SE1_API_IMPORT
#else /* ndef _DLL */
#define _CRTIMP
#endif /* _DLL */
Expand Down
36 changes: 18 additions & 18 deletions Sources/Engine/Base/Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */

// [Cecil] Declaration specifiers for exporting and importing symbols from modules
#if SE1_WIN
#define SE1_API_EXPORT __declspec(dllexport)
#define SE1_API_IMPORT __declspec(dllimport)
#else
#define SE1_API_EXPORT __attribute__((visibility("default")))
#define SE1_API_IMPORT
#endif

/*
* rcg10042001 In case these don't get defined in the project file, try to
* catch them here...
*/
#if SE1_WIN
#ifndef PRAGMA_ONCE
#define PRAGMA_ONCE
#endif

// disable problematic warnings

#pragma warning(disable: 4251) // dll interfacing problems
#pragma warning(disable: 4275) // dll interfacing problems
#pragma warning(disable: 4018) // signed/unsigned mismatch
Expand All @@ -33,20 +36,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma warning(disable: 4355) // 'this' : used in base member initializer list
#pragma warning(disable: 4660) // template-class specialization is already instantiated
#pragma warning(disable: 4723) // potential divide by 0
#endif

// define engine api exporting declaration specifiers
#ifdef ENGINE_EXPORTS
#define ENGINE_API __declspec(dllexport)
#else
#define ENGINE_API __declspec(dllimport)
// Define engine API
#ifdef ENGINE_EXPORTS
#define ENGINE_API SE1_API_EXPORT
#else
#define ENGINE_API SE1_API_IMPORT

#ifdef NDEBUG
#pragma comment(lib, "Engine.lib")
#else
#pragma comment(lib, "EngineD.lib")
#endif
#ifdef NDEBUG
#pragma comment(lib, "Engine.lib")
#else
#pragma comment(lib, "EngineD.lib")
#endif

#elif SE1_UNIX
#define ENGINE_API
#endif
4 changes: 2 additions & 2 deletions Sources/Engine/Base/Profiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once
#endif

#if ENGINE_INTERNAL
#ifdef ENGINE_INTERNAL

#include <Engine/Base/CTString.h>
#include <Engine/Base/Timer.h>
Expand Down Expand Up @@ -68,7 +68,7 @@ friend class CProfileForm;
class CProfileForm {
public:

#if ENGINE_INTERNAL
#ifdef ENGINE_INTERNAL
// implementation:
CTString pf_strTitle; // main title of the profiling form
CTString pf_strAveragingUnits; // name for averaging units
Expand Down
2 changes: 1 addition & 1 deletion Sources/Engine/Base/Statistics_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once
#endif

#if !ENGINE_EXPORTS
#ifndef ENGINE_EXPORTS
#error engine-internal file included out of engine!
#endif

Expand Down
11 changes: 2 additions & 9 deletions Sources/Engine/Entities/EntityProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,9 @@ class ENGINE_API CDLLEntityClass {
void ReleaseComponents(void);
};

/* rcg10062001 */
#if SE1_WIN
#define DECLSPEC_DLLEXPORT __declspec(dllexport)
#else
#define DECLSPEC_DLLEXPORT
#endif

// macro for defining entity class DLL structures
#define ENTITY_CLASSDEFINITION(classname, basename, descriptivename, iconfilename, id)\
extern "C" DECLSPEC_DLLEXPORT CDLLEntityClass classname##_DLLClass; \
extern "C" SE1_API_EXPORT CDLLEntityClass classname##_DLLClass; \
CDLLEntityClass classname##_DLLClass = { \
classname##_properties, \
classname##_propertiesct, \
Expand All @@ -270,7 +263,7 @@ class ENGINE_API CDLLEntityClass {
DynamicModuleClass classname##_AddToRegistry(#classname, &classname##_DLLClass)

#define ENTITY_CLASSDEFINITION_BASE(classname, id) \
extern "C" DECLSPEC_DLLEXPORT CDLLEntityClass classname##_DLLClass; \
extern "C" SE1_API_EXPORT CDLLEntityClass classname##_DLLClass; \
CDLLEntityClass classname##_DLLClass = { \
NULL,0, NULL,0, NULL,0, "", "", id, \
NULL, NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL \
Expand Down
14 changes: 4 additions & 10 deletions Sources/Engine/Graphics/Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,21 +236,15 @@ ENGINE_API void shaSetHazeColorArray(GFXColor *paHazeColors);
// Is overbrightning enabled
ENGINE_API BOOL shaOverBrightningEnabled(void);

#if SE1_WIN
#define DECLSPEC_DLLEXPORT __declspec(dllexport)
#else
#define DECLSPEC_DLLEXPORT
#endif

#define SHADER_MAIN(name) \
extern "C" void DECLSPEC_DLLEXPORT Shader_##name (void);\
extern "C" void SE1_API_EXPORT Shader_##name(void); \
DynamicModuleClass Shader_##name##_AddToRegistry("Shader_" #name, &Shader_##name); \
extern "C" void DECLSPEC_DLLEXPORT Shader_##name (void)
void Shader_##name(void)

#define SHADER_DESC(name,x) \
extern "C" void DECLSPEC_DLLEXPORT Shader_Desc_##name (x);\
extern "C" void SE1_API_EXPORT Shader_Desc_##name(x); \
DynamicModuleClass Shader_Desc_##name##_AddToRegistry("Shader_Desc_" #name, &Shader_Desc_##name); \
extern "C" void DECLSPEC_DLLEXPORT Shader_Desc_##name (x)
void SE1_API_EXPORT Shader_Desc_##name(x)

#endif /* include-once check. */

2 changes: 1 addition & 1 deletion Sources/Engine/Sound/eax.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ DEFINE_GUID(CLSID_EAXDirectSound,
0x11d3,
0xaa, 0xb8, 0x0, 0xa0, 0xc9, 0x59, 0x49, 0xd5);

__declspec(dllimport) HRESULT WINAPI EAXDirectSoundCreate(GUID*, LPDIRECTSOUND*, IUnknown FAR *);
SE1_API_IMPORT HRESULT WINAPI EAXDirectSoundCreate(GUID*, LPDIRECTSOUND*, IUnknown FAR *);

typedef HRESULT (FAR PASCAL *LPEAXDIRECTSOUNDCREATE)(GUID*, LPDIRECTSOUND*, IUnknown FAR*);

Expand Down
4 changes: 2 additions & 2 deletions Sources/Engine/StdH.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */

#define ENGINE_INTERNAL 1
#define ENGINE_EXPORTS 1
#define ENGINE_INTERNAL
#define ENGINE_EXPORTS

// [Cecil] Use engine as a whole
#include <Engine/Engine.h>
8 changes: 2 additions & 6 deletions Sources/EngineGui/EngineGUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <Engine/Engine.h>

#ifdef ENGINEGUI_EXPORTS

#define ENGINEGUI_API __declspec(dllexport)

#define ENGINEGUI_API SE1_API_EXPORT
#else

#define ENGINEGUI_API __declspec(dllimport)
#define ENGINEGUI_API SE1_API_IMPORT

#ifdef NDEBUG
#pragma comment(lib, "EngineGUI.lib")
#else
#pragma comment(lib, "EngineGUID.lib")
#endif

#endif

class CEngineGUI
Expand Down
4 changes: 2 additions & 2 deletions Sources/EngineGui/StdH.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <afxcmn.h> // MFC support for Windows Common Controls
#include <commdlg.h>

#define ENGINE_INTERNAL 1
#define ENGINEGUI_EXPORTS 1
#define ENGINE_INTERNAL
#define ENGINEGUI_EXPORTS
#include <EngineGUI/EngineGUI.h>

#include "Resource.h"
Expand Down
7 changes: 1 addition & 6 deletions Sources/EntitiesMP/StdH/StdH.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <GameMP/SessionProperties.h>
#include <GameMP/PlayerSettings.h>

/* rcg10042001 protect against Visual C-isms. */
#if SE1_WIN
#define DECL_DLL __declspec(dllexport)
#elif SE1_UNIX
#define DECL_DLL
#endif
#define DECL_DLL SE1_API_EXPORT

#include "../Global.h"
#include "../Common/Flags.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/GameGUIMP/GameGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void OnSelectPlayerAndControls(void)
_GameGUI.OnSelectPlayerAndControls();
}

extern "C" __declspec(dllexport) struct GameGUI_interface *GAMEGUI_Create(void)
extern "C" SE1_API_EXPORT struct GameGUI_interface *GAMEGUI_Create(void)
{
_Interface.Initialize = ::Initialize ;
_Interface.End = ::End ;
Expand Down
10 changes: 5 additions & 5 deletions Sources/GameGUIMP/GameGUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class CGameGUI {
public:
// functions called from World Editor
__declspec(dllexport) static void OnInvokeConsole(void);
__declspec(dllexport) static void OnPlayerSettings(void);
__declspec(dllexport) static void OnAudioQuality(void);
__declspec(dllexport) static void OnVideoQuality(void);
__declspec(dllexport) static void OnSelectPlayerAndControls(void);
static void OnInvokeConsole(void);
static void OnPlayerSettings(void);
static void OnAudioQuality(void);
static void OnVideoQuality(void);
static void OnSelectPlayerAndControls(void);
};

// global game gui object
Expand Down
1 change: 0 additions & 1 deletion Sources/GameMP/CompModels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#include "StdAfx.h"
#include "LCDDrawing.h"
#define DECL_DLL
#include "EntitiesMP/Common/Particles.h"

#include "Models/Enemies/Headman/Headman.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/GameMP/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static CStaticStackArray<INDEX> _actTriangles; // world, model, particle, total
// one and only Game object
extern CGame *_pGame = NULL;

extern "C" __declspec (dllexport) CGame *GAME_Create(void)
extern "C" SE1_API_EXPORT CGame *GAME_Create(void)
{
_pGame = new CGame;

Expand Down
9 changes: 1 addition & 8 deletions Sources/GameMP/StdAfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <GameMP/Game.h>
#include <GameMP/SEColors.h>

/* rcg10042001 protect against Visual C-isms. */
#if SE1_WIN
#define DECL_DLL __declspec(dllimport)
#elif SE1_UNIX
#define DECL_DLL
#endif
#define DECL_DLL SE1_API_IMPORT

#include <EntitiesMP/Global.h>
#include <EntitiesMP/Common/Common.h>
Expand All @@ -35,5 +30,3 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#else
#pragma comment(lib, "EntitiesMPD.lib")
#endif

#undef DECL_DLL
2 changes: 1 addition & 1 deletion Sources/Modeler/StdAfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#include <htmlhelp.h>

#define ENGINE_INTERNAL 1
#define ENGINE_INTERNAL
#include <EngineGUI/EngineGUI.h>
#include "Modeler.h"

Expand Down
2 changes: 0 additions & 2 deletions Sources/SeriousSam/SeriousSam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <process.h>
#include <Engine/CurrentVersion.h>
#include <GameMP/Game.h>
#define DECL_DLL
#include <EntitiesMP/Global.h>
#include "resource.h"
#include "SplashScreen.h"
#include "MainWindow.h"
Expand Down
16 changes: 0 additions & 16 deletions Sources/SeriousSam/StdH.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */

#include <Engine/Engine.h>
#include <Engine/Templates/Stock_CTextureData.h>
#include <Engine/Templates/Stock_CModelData.h>
#include <GameMP/Game.h>

/* rcg10042001 protect against Visual C-isms. */
#if SE1_WIN
#define DECL_DLL __declspec(dllimport)
#elif SE1_UNIX
#define DECL_DLL
#endif

#include <EntitiesMP/Global.h>
#include <EntitiesMP/Common/Common.h>
#include <EntitiesMP/Common/GameInterface.h>
#include <EntitiesMP/Player.h>

#undef DECL_DLL

#include "SeriousSam.h"
#include "GUI/Menus/Menu.h"
7 changes: 0 additions & 7 deletions Sources/Shaders/StdH.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,3 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#include <Engine/Engine.h>
#include <Engine/Graphics/Shader.h>

/* rcg10042001 protect against Visual C-isms. */
#if SE1_WIN
#define DECL_DLL __declspec(dllexport)
#elif SE1_UNIX
#define DECL_DLL
#endif
2 changes: 1 addition & 1 deletion Sources/WorldEditor/StdAfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <htmlhelp.h>

#define ENGINE_INTERNAL 1
#define ENGINE_INTERNAL
#include <EngineGUI/EngineGUI.h>
#include <Engine/GameShell.h>
#include <Engine/Base/ChangeableRT.h>
Expand Down

0 comments on commit b859216

Please sign in to comment.