From: Mikko Rasa Date: Sat, 7 Jan 2023 13:19:47 +0000 (+0200) Subject: Decorate things which constitute the public API of the library X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=12c863fc1bc5456a4b3aceacc88904d76bd1d8bb;p=libs%2Fgame.git Decorate things which constitute the public API of the library --- diff --git a/source/game/accessguard.h b/source/game/accessguard.h index 0f7bac7..2d9a305 100644 --- a/source/game/accessguard.h +++ b/source/game/accessguard.h @@ -7,17 +7,18 @@ #include #include #include +#include "mspgame_api.h" namespace Msp::Game { -class invalid_access: public std::logic_error +class MSPGAME_API invalid_access: public std::logic_error { public: invalid_access(const std::string &w): logic_error(w) { } }; -class AccessGuard +class MSPGAME_API AccessGuard { public: struct Create { static std::string describe() { return "create"; } }; diff --git a/source/game/camera.h b/source/game/camera.h index f6df873..57f7395 100644 --- a/source/game/camera.h +++ b/source/game/camera.h @@ -4,6 +4,7 @@ #include #include #include "component.h" +#include "mspgame_api.h" namespace Msp::Game { @@ -38,7 +39,7 @@ struct CameraData float get_aspect() const { return size.x/size.y; } }; -class Camera: public BufferedComponent +class MSPGAME_API Camera: public BufferedComponent { public: using Setup = CameraSetup; diff --git a/source/game/component.h b/source/game/component.h index 6406cb5..e97b511 100644 --- a/source/game/component.h +++ b/source/game/component.h @@ -4,12 +4,13 @@ #include #include "accessguard.h" #include "handle.h" +#include "mspgame_api.h" namespace Msp::Game { class Entity; -class Component +class MSPGAME_API Component { protected: Handle entity; diff --git a/source/game/director.h b/source/game/director.h index 775d7d2..5aeddea 100644 --- a/source/game/director.h +++ b/source/game/director.h @@ -11,13 +11,14 @@ #include "eventbus.h" #include "events.h" #include "eventsource.h" +#include "mspgame_api.h" #include "reflection.h" namespace Msp::Game { class Stage; -class Director +class MSPGAME_API Director { public: using EventSource = Game::EventSource; diff --git a/source/game/entity.h b/source/game/entity.h index 8dc5139..e6d1cf9 100644 --- a/source/game/entity.h +++ b/source/game/entity.h @@ -2,6 +2,7 @@ #define MSP_GAME_ENTITY_H_ #include "handle.h" +#include "mspgame_api.h" #include "owned.h" namespace Msp::Game { @@ -11,13 +12,13 @@ class Stage; class Transform; struct TransformValues; -class hierarchy_error: public std::logic_error +class MSPGAME_API hierarchy_error: public std::logic_error { public: hierarchy_error(): std::logic_error("hierarchy error") { } }; -class Entity +class MSPGAME_API Entity { public: enum TransformTag { NO_TRANSFORM }; diff --git a/source/game/eventbus.h b/source/game/eventbus.h index b9e6c78..95fc068 100644 --- a/source/game/eventbus.h +++ b/source/game/eventbus.h @@ -4,6 +4,7 @@ #include #include #include +#include "mspgame_api.h" namespace Msp::Game { @@ -31,7 +32,7 @@ struct EventDispatcher }; -class EventBus: public NonCopyable +class MSPGAME_API EventBus: public NonCopyable { private: using DeleteFunc = void(void *); diff --git a/source/game/eventobserver.h b/source/game/eventobserver.h index 31735a6..1c65514 100644 --- a/source/game/eventobserver.h +++ b/source/game/eventobserver.h @@ -4,12 +4,13 @@ #include #include #include "eventbus.h" +#include "mspgame_api.h" namespace Msp::Game { class EventSourceBase; -class EventObserver: public NonCopyable +class MSPGAME_API EventObserver: public NonCopyable { private: EventBus &bus; diff --git a/source/game/meshsource.h b/source/game/meshsource.h index 74ec781..dfc6509 100644 --- a/source/game/meshsource.h +++ b/source/game/meshsource.h @@ -3,6 +3,7 @@ #include #include "component.h" +#include "mspgame_api.h" namespace Msp::Game { @@ -23,7 +24,7 @@ struct MeshSourceSetup std::string object_name; }; -class MeshSource: public Component +class MSPGAME_API MeshSource: public Component { public: using Setup = MeshSourceSetup; diff --git a/source/game/mspgame_api.h b/source/game/mspgame_api.h new file mode 100644 index 0000000..1f9cdf0 --- /dev/null +++ b/source/game/mspgame_api.h @@ -0,0 +1,18 @@ +#ifndef MSP_GAME_API_H_ +#define MSP_GAME_API_H_ + +#if defined(_WIN32) +#if defined(MSPGAME_BUILD) +#define MSPGAME_API __declspec(dllexport) +#elif defined(MSPGAME_IMPORT) +#define MSPGAME_API __declspec(dllimport) +#else +#define MSPGAME_API +#endif +#elif defined(__GNUC__) +#define MSPGAME_API __attribute__((visibility("default"))) +#else +#define MSPGAME_API +#endif + +#endif diff --git a/source/game/pool.h b/source/game/pool.h index 2b8e799..e4fe704 100644 --- a/source/game/pool.h +++ b/source/game/pool.h @@ -5,6 +5,7 @@ #include #include #include +#include "mspgame_api.h" namespace Msp::Game { @@ -13,7 +14,7 @@ class PoolBase; template class Pool; -class PoolPool: public NonCopyable +class MSPGAME_API PoolPool: public NonCopyable { private: std::vector> pools; @@ -35,7 +36,7 @@ public: }; -class PoolBase: public NonCopyable +class MSPGAME_API PoolBase: public NonCopyable { private: using DeleteFunc = void(void *); diff --git a/source/game/reflection.h b/source/game/reflection.h index 6d8535d..7b75541 100644 --- a/source/game/reflection.h +++ b/source/game/reflection.h @@ -6,6 +6,7 @@ #include #include #include +#include "mspgame_api.h" namespace Msp::Game { namespace Reflection { @@ -40,7 +41,7 @@ public: }; -class ClassBase +class MSPGAME_API ClassBase { protected: Reflector &reflector; @@ -85,7 +86,7 @@ private: }; -class Reflector +class MSPGAME_API Reflector { private: std::vector> classes; diff --git a/source/game/resources.h b/source/game/resources.h index c5b8372..6208433 100644 --- a/source/game/resources.h +++ b/source/game/resources.h @@ -5,15 +5,16 @@ #include #include #include +#include "mspgame_api.h" namespace Msp::Game { -class Resources: virtual public DataFile::Collection +class MSPGAME_API Resources: virtual public DataFile::Collection { public: }; -class ApplicationResources: public Resources +class MSPGAME_API ApplicationResources: public Resources { private: DataFile::DirectorySource dir_src; diff --git a/source/game/root.h b/source/game/root.h index 726ca32..57e9c0f 100644 --- a/source/game/root.h +++ b/source/game/root.h @@ -2,12 +2,13 @@ #define MSP_GAME_ROOT_H_ #include "entity.h" +#include "mspgame_api.h" namespace Msp::Game { class Stage; -class Root: public Entity +class MSPGAME_API Root: public Entity { private: Stage &stage; diff --git a/source/game/stage.h b/source/game/stage.h index 0c2219b..03a8ade 100644 --- a/source/game/stage.h +++ b/source/game/stage.h @@ -8,6 +8,7 @@ #include "events.h" #include "eventsource.h" #include "handle.h" +#include "mspgame_api.h" #include "reflection.h" #include "systemscheduler.h" @@ -17,7 +18,7 @@ class Camera; class Root; class System; -class Stage +class MSPGAME_API Stage { public: using EventSource = Game::EventSource #include "accessguard.h" #include "component.h" +#include "mspgame_api.h" #include "reflection.h" #include "stage.h" namespace Msp::Game { -class System +class MSPGAME_API System { public: enum DependencyFlags diff --git a/source/game/systemscheduler.h b/source/game/systemscheduler.h index 2ab4804..66764c8 100644 --- a/source/game/systemscheduler.h +++ b/source/game/systemscheduler.h @@ -2,19 +2,20 @@ #define MSP_GAME_SYSTEMSCHEDULER_H_ #include +#include "mspgame_api.h" #include "reflection.h" namespace Msp::Game { class System; -class scheduling_error: public std::logic_error +class MSPGAME_API scheduling_error: public std::logic_error { public: scheduling_error(const std::string &w): logic_error(w) { } }; -class SystemScheduler +class MSPGAME_API SystemScheduler { public: struct Group diff --git a/source/game/transform.h b/source/game/transform.h index 1239546..fc63f29 100644 --- a/source/game/transform.h +++ b/source/game/transform.h @@ -5,6 +5,7 @@ #include #include #include "component.h" +#include "mspgame_api.h" namespace Msp::Game { @@ -29,7 +30,7 @@ struct TransformData LinAl::Matrix world_matrix = LinAl::Matrix::identity(); }; -class Transform: public BufferedComponent +class MSPGAME_API Transform: public BufferedComponent { public: Transform(Handle); diff --git a/source/game/transformpropagator.h b/source/game/transformpropagator.h index 3ac291b..defaed1 100644 --- a/source/game/transformpropagator.h +++ b/source/game/transformpropagator.h @@ -3,6 +3,7 @@ #include "eventobserver.h" #include "handle.h" +#include "mspgame_api.h" #include "system.h" namespace Msp::Game { @@ -10,7 +11,7 @@ namespace Msp::Game { class Entity; class Transform; -class TransformPropagator: public System +class MSPGAME_API TransformPropagator: public System { private: struct ParentedTransform diff --git a/source/gameview/meshrenderer.h b/source/gameview/meshrenderer.h index 96fe612..f5e9548 100644 --- a/source/gameview/meshrenderer.h +++ b/source/gameview/meshrenderer.h @@ -4,10 +4,11 @@ #include #include #include +#include "mspgameview_api.h" namespace Msp::GameView { -class MeshRenderer: public Game::Component +class MSPGAMEVIEW_API MeshRenderer: public Game::Component { private: Game::Handle source; diff --git a/source/gameview/mspgameview_api.h b/source/gameview/mspgameview_api.h new file mode 100644 index 0000000..b23f2ee --- /dev/null +++ b/source/gameview/mspgameview_api.h @@ -0,0 +1,18 @@ +#ifndef MSP_GAMEVIEW_API_H_ +#define MSP_GAMEVIEW_API_H_ + +#if defined(_WIN32) +#if defined(MSPGAMEVIEW_BUILD) +#define MSPGAMEVIEW_API __declspec(dllexport) +#elif defined(MSPGAMEVIEW_IMPORT) +#define MSPGAMEVIEW_API __declspec(dllimport) +#else +#define MSPGAMEVIEW_API +#endif +#elif defined(__GNUC__) +#define MSPGAMEVIEW_API __attribute__((visibility("default"))) +#else +#define MSPGAMEVIEW_API +#endif + +#endif diff --git a/source/gameview/playerinput.h b/source/gameview/playerinput.h index 16f3c4e..2797aff 100644 --- a/source/gameview/playerinput.h +++ b/source/gameview/playerinput.h @@ -9,10 +9,11 @@ #include #include #include "events.h" +#include "mspgameview_api.h" namespace Msp::GameView { -class PlayerInput: public NonCopyable +class MSPGAMEVIEW_API PlayerInput: public NonCopyable { public: using EventSource = Game::EventSource; diff --git a/source/gameview/presenter.h b/source/gameview/presenter.h index fc89200..62f422c 100644 --- a/source/gameview/presenter.h +++ b/source/gameview/presenter.h @@ -5,12 +5,13 @@ #include #include #include +#include "mspgameview_api.h" namespace Msp::GameView { class Renderer; -class Presenter +class MSPGAMEVIEW_API Presenter { private: Game::Director &director; diff --git a/source/gameview/renderer.h b/source/gameview/renderer.h index ee0b05c..ca45b21 100644 --- a/source/gameview/renderer.h +++ b/source/gameview/renderer.h @@ -10,12 +10,13 @@ #include #include #include +#include "mspgameview_api.h" namespace Msp::GameView { class MeshRenderer; -class Renderer: public Game::System +class MSPGAMEVIEW_API Renderer: public Game::System { private: struct RenderedEntity diff --git a/source/gameview/resources.h b/source/gameview/resources.h index aa20b02..316a550 100644 --- a/source/gameview/resources.h +++ b/source/gameview/resources.h @@ -2,10 +2,11 @@ #define MSP_GAMEVIEW_RESOURCES_H_ #include +#include "mspgameview_api.h" namespace Msp::GameView { -class Resources: public GL::Resources +class MSPGAMEVIEW_API Resources: public GL::Resources { public: Resources();