aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-08-24 20:05:03 +0800
committerchai <chaifix@163.com>2018-08-24 20:05:03 +0800
commit731a1b930c4ca5c6494539877d56e01f90fce885 (patch)
treec84a7f0523d225dffd4f2dc835730507b7973051 /src
parente6e3c76c1f2829537d368501a74af0646f5559d4 (diff)
*remove nonsense macros
Diffstat (limited to 'src')
-rw-r--r--src/libjin/Audio/SDL/SDLAudio.cpp4
-rw-r--r--src/libjin/Audio/SDL/SDLSource.cpp10
-rw-r--r--src/libjin/Common/Subsystem.hpp3
-rw-r--r--src/libjin/Core/Game.cpp10
-rw-r--r--src/libjin/Graphics/Canvas.cpp6
-rw-r--r--src/libjin/Graphics/Window.h4
-rw-r--r--src/libjin/Utils/macros.h22
-rw-r--r--src/libjin/core/game.cpp10
-rw-r--r--src/libjin/utils/macros.h22
9 files changed, 48 insertions, 43 deletions
diff --git a/src/libjin/Audio/SDL/SDLAudio.cpp b/src/libjin/Audio/SDL/SDLAudio.cpp
index f7ca70d..040ca96 100644
--- a/src/libjin/Audio/SDL/SDLAudio.cpp
+++ b/src/libjin/Audio/SDL/SDLAudio.cpp
@@ -27,7 +27,7 @@ namespace audio
audio->unlock();
}
- onlyonce bool SDLAudio::initSystem(const SettingBase* s)
+ /*call only once*/ bool SDLAudio::initSystem(const SettingBase* s)
{
#if JIN_DEBUG
Loghelper::log(Loglevel::LV_INFO, "Init Audio System");
@@ -58,7 +58,7 @@ namespace audio
return true;
}
- onlyonce void SDLAudio::quitSystem()
+ /*call only once*/ void SDLAudio::quitSystem()
{
SDL_CloseAudio();
}
diff --git a/src/libjin/Audio/SDL/SDLSource.cpp b/src/libjin/Audio/SDL/SDLSource.cpp
index c868df5..5c6abb8 100644
--- a/src/libjin/Audio/SDL/SDLSource.cpp
+++ b/src/libjin/Audio/SDL/SDLSource.cpp
@@ -52,7 +52,7 @@ namespace audio
STEREO = 2, //
};
- typedef MASK enum STATUS
+ typedef /*mask*/ enum STATUS
{
PLAYING = 1,
PAUSED = 2,
@@ -63,10 +63,10 @@ namespace audio
#define Action Command::Action
#define Manager SDLSourceManager
- //shared std::queue<Command*> Manager::commands;
- //shared std::stack<Command*> Manager::commandsPool;
- //shared std::vector<SDLSource*> Manager::sources;
- shared Manager* Manager::manager = nullptr;
+ ///*class member*/ std::queue<Command*> Manager::commands;
+ ///*class member*/ std::stack<Command*> Manager::commandsPool;
+ ///*class member*/ std::vector<SDLSource*> Manager::sources;
+ /*class member*/ Manager* Manager::manager = nullptr;
SDLSource* SDLSource::createSource(const char* file)
{
diff --git a/src/libjin/Common/Subsystem.hpp b/src/libjin/Common/Subsystem.hpp
index 1374ad1..59013c6 100644
--- a/src/libjin/Common/Subsystem.hpp
+++ b/src/libjin/Common/Subsystem.hpp
@@ -22,7 +22,8 @@ namespace jin
void quit()
{
- CALLONCE(quitSystem());
+ /*call only once*/
+ static char __dummy__ = (quitSystem(), 1);
Singleton<System>::destroy();
}
diff --git a/src/libjin/Core/Game.cpp b/src/libjin/Core/Game.cpp
index b480b12..3f905f2 100644
--- a/src/libjin/Core/Game.cpp
+++ b/src/libjin/Core/Game.cpp
@@ -19,7 +19,8 @@ namespace core
void Game::run()
{
- SAFECALL(_onLoad);
+ if (_onLoad != nullptr)
+ _onLoad();
Window* wnd = Window::get();
const int FPS = wnd ? wnd->getFPS() : 60;
const int MS_PER_UPDATE = 1000.0f / FPS;
@@ -31,11 +32,12 @@ namespace core
{
while (jin::input::pollEvent(&e))
{
- SAFECALL(_onEvent, &e);
+ if (_onEvent != nullptr)
+ _onEvent(&e);
if (!_running) goto quitloop;
}
- SAFECALL(_onUpdate, dt);
- SAFECALL(_onDraw);
+ if (_onUpdate != nullptr) _onUpdate(dt);
+ if (_onDraw != nullptr) _onDraw();
wnd->swapBuffers();
const int current = getMilliSecond();
dt = current - previous;
diff --git a/src/libjin/Graphics/Canvas.cpp b/src/libjin/Graphics/Canvas.cpp
index f5bd09f..99f022d 100644
--- a/src/libjin/Graphics/Canvas.cpp
+++ b/src/libjin/Graphics/Canvas.cpp
@@ -10,7 +10,7 @@ namespace jin
namespace graphics
{
- shared Canvas* Canvas::createCanvas(int w, int h)
+ /*class member*/ Canvas* Canvas::createCanvas(int w, int h)
{
return new Canvas(w, h);
}
@@ -25,7 +25,7 @@ namespace graphics
{
}
- shared GLint Canvas::cur = -1;
+ /*class member*/ GLint Canvas::cur = -1;
bool Canvas::init()
{
@@ -102,7 +102,7 @@ namespace graphics
/**
* bind to default screen render buffer.
*/
- shared void Canvas::unbind()
+ /*class member*/ void Canvas::unbind()
{
if (hasbind(0)) return;
diff --git a/src/libjin/Graphics/Window.h b/src/libjin/Graphics/Window.h
index e09e9f9..e4939f6 100644
--- a/src/libjin/Graphics/Window.h
+++ b/src/libjin/Graphics/Window.h
@@ -44,8 +44,8 @@ namespace graphics
int width, height;
int fps;
- onlyonce bool initSystem(const SettingBase* setting) override;
- onlyonce void quitSystem() override;
+ /*call only once*/ bool initSystem(const SettingBase* setting) override;
+ /*call only once*/ void quitSystem() override;
};
} // render
diff --git a/src/libjin/Utils/macros.h b/src/libjin/Utils/macros.h
index a57cb7c..290bcf7 100644
--- a/src/libjin/Utils/macros.h
+++ b/src/libjin/Utils/macros.h
@@ -2,16 +2,16 @@
#define __JIN_MACROS_H
#include <cstring>
-#define implement // ʵֽӿ
-
-#define shared // ķ
-
-#define MASK // enum
-
-#define onlyonce // ֻһ
-#define CALLONCE(call) static char __dummy__=(call, 1) // ֻһ
-#define SAFECALL(func, params) if(func) func(params)
-
-#define zero(mem) memset(&mem, 0, sizeof(mem))
+//#define implement // ʵֽӿ
+//
+//#define shared // ķ
+//
+//#define MASK // enum
+//
+//#define onlyonce // ֻһ
+//#define CALLONCE(call) static char __dummy__=(call, 1) // ֻһ
+//#define SAFECALL(func, params) if(func) func(params)
+//
+//#define zero(mem) memset(&mem, 0, sizeof(mem))
#endif \ No newline at end of file
diff --git a/src/libjin/core/game.cpp b/src/libjin/core/game.cpp
index b480b12..3f905f2 100644
--- a/src/libjin/core/game.cpp
+++ b/src/libjin/core/game.cpp
@@ -19,7 +19,8 @@ namespace core
void Game::run()
{
- SAFECALL(_onLoad);
+ if (_onLoad != nullptr)
+ _onLoad();
Window* wnd = Window::get();
const int FPS = wnd ? wnd->getFPS() : 60;
const int MS_PER_UPDATE = 1000.0f / FPS;
@@ -31,11 +32,12 @@ namespace core
{
while (jin::input::pollEvent(&e))
{
- SAFECALL(_onEvent, &e);
+ if (_onEvent != nullptr)
+ _onEvent(&e);
if (!_running) goto quitloop;
}
- SAFECALL(_onUpdate, dt);
- SAFECALL(_onDraw);
+ if (_onUpdate != nullptr) _onUpdate(dt);
+ if (_onDraw != nullptr) _onDraw();
wnd->swapBuffers();
const int current = getMilliSecond();
dt = current - previous;
diff --git a/src/libjin/utils/macros.h b/src/libjin/utils/macros.h
index a57cb7c..290bcf7 100644
--- a/src/libjin/utils/macros.h
+++ b/src/libjin/utils/macros.h
@@ -2,16 +2,16 @@
#define __JIN_MACROS_H
#include <cstring>
-#define implement // ʵֽӿ
-
-#define shared // ķ
-
-#define MASK // enum
-
-#define onlyonce // ֻһ
-#define CALLONCE(call) static char __dummy__=(call, 1) // ֻһ
-#define SAFECALL(func, params) if(func) func(params)
-
-#define zero(mem) memset(&mem, 0, sizeof(mem))
+//#define implement // ʵֽӿ
+//
+//#define shared // ķ
+//
+//#define MASK // enum
+//
+//#define onlyonce // ֻһ
+//#define CALLONCE(call) static char __dummy__=(call, 1) // ֻһ
+//#define SAFECALL(func, params) if(func) func(params)
+//
+//#define zero(mem) memset(&mem, 0, sizeof(mem))
#endif \ No newline at end of file