diff options
Diffstat (limited to 'src')
43 files changed, 352 insertions, 344 deletions
diff --git a/src/libjin/Game/je_entity.h b/src/libjin/Game/je_entity.h index cf4eeb0..92976b4 100644 --- a/src/libjin/Game/je_entity.h +++ b/src/libjin/Game/je_entity.h @@ -1,7 +1,7 @@ #ifndef __JE_ENTITY_H #define __JE_ENTITY_H -#include "je_game_object.h" +#include "je_gameobject.h" namespace JinEngine { @@ -14,12 +14,14 @@ namespace JinEngine class Entity : public GameObject { public: + Entity(); private: + }; - } -} + } // namespace Game +} // namespace JinEngine #endif
\ No newline at end of file diff --git a/src/libjin/Game/je_game_object.cpp b/src/libjin/Game/je_gameobject.cpp index 1396518..1396518 100644 --- a/src/libjin/Game/je_game_object.cpp +++ b/src/libjin/Game/je_gameobject.cpp diff --git a/src/libjin/Game/je_game_object.h b/src/libjin/Game/je_gameobject.h index 08a103f..08a103f 100644 --- a/src/libjin/Game/je_game_object.h +++ b/src/libjin/Game/je_gameobject.h diff --git a/src/libjin/Graphics/je_graphic_single.cpp b/src/libjin/Graphics/je_graphic_single.cpp index 0784409..96eb1af 100644 --- a/src/libjin/Graphics/je_graphic_single.cpp +++ b/src/libjin/Graphics/je_graphic_single.cpp @@ -47,30 +47,31 @@ namespace JinEngine void GraphicSingle::render(const Math::Quad& slice, int x, int y, float sx, float sy, float r, float ax, float ay) { - float vertCoords[8] = { - 0, 0, - 0, slice.h, - slice.w, slice.h, - slice.w, 0 - }; + static float vertexCoords[8]; + static float textureCoords[8]; + + // Set vertex coordinates. + vertexCoords[0] = 0; vertexCoords[1] = 0; + vertexCoords[2] = 0; vertexCoords[3] = slice.h; + vertexCoords[4] = slice.w; vertexCoords[5] = slice.h; + vertexCoords[6] = slice.w; vertexCoords[7] = 0; + // Set texture coordinates. float slx = slice.x / mSize.w; float sly = slice.y / mSize.h; float slw = slice.w / mSize.w; float slh = slice.h / mSize.h; - float texCoords[8] = { - slx, sly, - slx, sly + slh, - slx + slw, sly + slh, - slx + slw, sly - }; + textureCoords[0] = slx; textureCoords[1] = sly; + textureCoords[2] = slx; textureCoords[3] = sly + slh; + textureCoords[4] = slx + slw; textureCoords[5] = sly + slh; + textureCoords[6] = slx + slw; textureCoords[7] = sly; gl.ModelMatrix.setTransformation(x, y, r, sx, sy, ax, ay); Shader* shader = Shader::getCurrentShader(); shader->sendMatrix4(SHADER_MODEL_MATRIX, &gl.ModelMatrix); shader->sendMatrix4(SHADER_PROJECTION_MATRIX, &gl.ProjectionMatrix); - shader->bindVertexPointer(2, GL_FLOAT, 0, vertCoords); - shader->bindUVPointer(2, GL_FLOAT, 0, texCoords); + shader->bindVertexPointer(2, GL_FLOAT, 0, vertexCoords); + shader->bindUVPointer(2, GL_FLOAT, 0, textureCoords); gl.bindTexture(getGLTexture()); gl.drawArrays(GL_QUADS, 0, 4); @@ -78,4 +79,4 @@ namespace JinEngine } } // namespace Graphics -} // namespace JinEngine
\ No newline at end of file +} // namespace JinEngine
\ No newline at end of file diff --git a/src/libjin/Graphics/je_graphic_single.h b/src/libjin/Graphics/je_graphic_single.h index ca2864b..f61234b 100644 --- a/src/libjin/Graphics/je_graphic_single.h +++ b/src/libjin/Graphics/je_graphic_single.h @@ -50,4 +50,4 @@ namespace JinEngine } // namespace Graphics } // namespace JinEngine -#endif
\ No newline at end of file +#endif
\ No newline at end of file diff --git a/src/libjin/Graphics/particle/je_particle_system.h b/src/libjin/Graphics/particle/je_particle_system.h index 270d9a8..8526da8 100644 --- a/src/libjin/Graphics/particle/je_particle_system.h +++ b/src/libjin/Graphics/particle/je_particle_system.h @@ -4,7 +4,7 @@ #include <vector> #include "../../common/je_temporary.h" -#include "../../game/je_game_object.h" +#include "../../game/je_gameobject.h" #include "../je_sprite.h" diff --git a/src/lua/common/common.h b/src/lua/common/common.h deleted file mode 100644 index 0ee72cc..0000000 --- a/src/lua/common/common.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __JIN_M_TYPES_H -#define __JIN_M_TYPES_H - -#include "Proxy.h" -#include "Reference.hpp" -#include "error.h" - -#endif
\ No newline at end of file diff --git a/src/lua/common/error.h b/src/lua/common/error.h deleted file mode 100644 index c254486..0000000 --- a/src/lua/common/error.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __JIN_ERROR_H -#define __JIN_ERROR_H -#include "../../luax.h" -#include "../jin.h" -#include <string.h> - -namespace JinEngine -{ -namespace Lua -{ - - static const int FORMAT_MSG_BUFFER_SIZE = 2048; - - inline void error(lua_State* L, const char* fmt, ...) - { - char err[FORMAT_MSG_BUFFER_SIZE + 1] = { 0 }; - va_list args; - va_start(args, fmt); - vsnprintf(err + strlen(err), FORMAT_MSG_BUFFER_SIZE, fmt, args); - va_end(args); - luax_getglobal(L, MODULE_NAME); - luax_setfieldstring(L, "error", err); - } - -} -} - -#endif
\ No newline at end of file diff --git a/src/lua/common/je_lua_common.h b/src/lua/common/je_lua_common.h new file mode 100644 index 0000000..1d772a5 --- /dev/null +++ b/src/lua/common/je_lua_common.h @@ -0,0 +1,9 @@ +#ifndef __JIN_M_TYPES_H +#define __JIN_M_TYPES_H + +#include "je_lua_port.h" +#include "je_lua_proxy.h" +#include "je_lua_reference.hpp" +#include "je_lua_error.h" + +#endif
\ No newline at end of file diff --git a/src/lua/common/constant.h b/src/lua/common/je_lua_constant.h index 6f70f09..6f70f09 100644 --- a/src/lua/common/constant.h +++ b/src/lua/common/je_lua_constant.h diff --git a/src/lua/common/je_lua_error.h b/src/lua/common/je_lua_error.h new file mode 100644 index 0000000..fd21b41 --- /dev/null +++ b/src/lua/common/je_lua_error.h @@ -0,0 +1,27 @@ +#ifndef __JIN_ERROR_H +#define __JIN_ERROR_H +#include "../luax.h" +#include <string.h> + +namespace JinEngine +{ + namespace Lua + { + + static const int FORMAT_MSG_BUFFER_SIZE = 2048; + + inline void error(lua_State* L, const char* fmt, ...) + { + char err[FORMAT_MSG_BUFFER_SIZE + 1] = { 0 }; + va_list args; + va_start(args, fmt); + vsnprintf(err + strlen(err), FORMAT_MSG_BUFFER_SIZE, fmt, args); + va_end(args); + luax_getglobal(L, "jin"); + luax_setfieldstring(L, "error", err); + } + + } +} + +#endif
\ No newline at end of file diff --git a/src/lua/common/je_lua_port.h b/src/lua/common/je_lua_port.h new file mode 100644 index 0000000..8e99ca4 --- /dev/null +++ b/src/lua/common/je_lua_port.h @@ -0,0 +1,8 @@ +#ifndef __JE_LUA_PORT_H +#define __JE_LUA_PORT_H + +#define LUA_PORT extern +#define LUA_IMPLEMENT static +#define LUA_EXPORT + +#endif
\ No newline at end of file diff --git a/src/lua/common/Proxy.h b/src/lua/common/je_lua_proxy.h index 5ebb5b2..b428dc9 100644 --- a/src/lua/common/Proxy.h +++ b/src/lua/common/je_lua_proxy.h @@ -1,7 +1,7 @@ #ifndef __JIN_COMMON_PROXY_H #define __JIN_COMMON_PROXY_H -#include "Reference.hpp" +#include "je_lua_reference.hpp" namespace JinEngine { diff --git a/src/lua/common/Reference.hpp b/src/lua/common/je_lua_reference.hpp index ba918bb..ba918bb 100644 --- a/src/lua/common/Reference.hpp +++ b/src/lua/common/je_lua_reference.hpp diff --git a/src/lua/jin.cpp b/src/lua/jin.cpp index faae9b2..10b60b6 100644 --- a/src/lua/jin.cpp +++ b/src/lua/jin.cpp @@ -1,39 +1,40 @@ -#include "jin.h" +#include "lua/common/je_lua_common.h" #include "lua/modules/luax.h" #include "embed/embed.h" +#include "jin.h" namespace JinEngine { namespace Lua { - extern int luaopen_core(lua_State* L); - extern int luaopen_graphics(lua_State* L); - extern int luaopen_audio(lua_State* L); - extern int luaopen_net(lua_State* L); - extern int luaopen_event(lua_State* L); - extern int luaopen_time(lua_State* L); - extern int luaopen_mouse(lua_State* L); - extern int luaopen_keyboard(lua_State* L); - extern int luaopen_filesystem(lua_State* L); - extern int luaopen_joypad(lua_State* L); - extern int luaopen_math(lua_State* L); - extern int luaopen_thread(lua_State* L); - extern int luaopen_bit(lua_State* L); + LUA_PORT int luaopen_core(lua_State* L); + LUA_PORT int luaopen_graphics(lua_State* L); + LUA_PORT int luaopen_audio(lua_State* L); + LUA_PORT int luaopen_net(lua_State* L); + LUA_PORT int luaopen_event(lua_State* L); + LUA_PORT int luaopen_time(lua_State* L); + LUA_PORT int luaopen_mouse(lua_State* L); + LUA_PORT int luaopen_keyboard(lua_State* L); + LUA_PORT int luaopen_filesystem(lua_State* L); + LUA_PORT int luaopen_joypad(lua_State* L); + LUA_PORT int luaopen_math(lua_State* L); + LUA_PORT int luaopen_thread(lua_State* L); + LUA_PORT int luaopen_bit(lua_State* L); - static int l_getversion(lua_State* L) + LUA_IMPLEMENT int l_getversion(lua_State* L) { luax_pushstring(L, VERSION); return 1; } - static int l_getAuthor(lua_State* L) + LUA_IMPLEMENT int l_getAuthor(lua_State* L) { luax_pushstring(L, AUTHOR); return 1; } - static int l_getOS(lua_State* L) + LUA_IMPLEMENT int l_getOS(lua_State* L) { #ifdef _WIN32 luax_pushstring(L, "windows"); @@ -45,26 +46,26 @@ namespace JinEngine return 1; } - static int l_revision(lua_State* L) + LUA_IMPLEMENT int l_revision(lua_State* L) { luax_pushnumber(L, REVISION); return 1; } - static const luax_Str s[] = { + LUA_IMPLEMENT const luax_Str s[] = { { "version", VERSION }, { "author", AUTHOR }, { "codename", CODE_NAME }, { 0, 0 } }; - static const luax_Num n[] = { + LUA_IMPLEMENT const luax_Num n[] = { { "revision", REVISION }, { 0, 0 } }; /* sub modules */ - static const luax_Ref mods[] = { + LUA_IMPLEMENT const luax_Ref mods[] = { { "core", luaopen_core }, { "event", luaopen_event }, { "graphics", luaopen_graphics }, @@ -83,7 +84,7 @@ namespace JinEngine }; /* register jin module, keep it on the top of stack */ - int luaopen_jin(lua_State* L) + LUA_EXPORT int luaopen_jin(lua_State* L) { luax_globaltable(L, MODULE_NAME); @@ -101,7 +102,7 @@ namespace JinEngine return 1; } - void boot(lua_State* L) + LUA_EXPORT void boot(lua_State* L) { JinEngine::embed::boot(L); } diff --git a/src/lua/jin.h b/src/lua/jin.h index 71ad51b..a4dcd3e 100644 --- a/src/lua/jin.h +++ b/src/lua/jin.h @@ -4,6 +4,7 @@ #ifndef __JIN_M_JIN_H #define __JIN_M_JIN_H +#include "lua/common/je_lua_common.h" #include "luax.h" #define MODULE_NAME "jin" @@ -21,12 +22,12 @@ namespace JinEngine /// /// open jin module. /// - int luaopen_jin(lua_State* L); + LUA_EXPORT int luaopen_jin(lua_State* L); /// /// Boot jin. /// - void boot(lua_State* L); + LUA_EXPORT void boot(lua_State* L); } // namespace JinEngine } // namespace Lua diff --git a/src/lua/modules/audio/je_lua_audio.cpp b/src/lua/modules/audio/je_lua_audio.cpp index 198323d..96b7f92 100644 --- a/src/lua/modules/audio/je_lua_audio.cpp +++ b/src/lua/modules/audio/je_lua_audio.cpp @@ -1,6 +1,6 @@ #include "lua/modules/luax.h" #include "lua/modules/types.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "libjin/jin.h" namespace JinEngine @@ -14,7 +14,7 @@ namespace JinEngine typedef SDLAudio Audio; typedef SDLSource Source; - static int l_init(lua_State* L) + LUA_IMPLEMENT int l_init(lua_State* L) { Audio::Setting setting; setting.samplerate = 44100; @@ -29,38 +29,38 @@ namespace JinEngine return 1; } - static int l_play(lua_State* L) + LUA_IMPLEMENT int l_play(lua_State* L) { Audio::get()->play(); return 0; } - static int l_stop(lua_State* L) + LUA_IMPLEMENT int l_stop(lua_State* L) { Audio::get()->stop(); return 0; } - static int l_pause(lua_State* L) + LUA_IMPLEMENT int l_pause(lua_State* L) { Audio::get()->pause(); return 0; } - static int l_resume(lua_State* L) + LUA_IMPLEMENT int l_resume(lua_State* L) { Audio::get()->resume(); return 0; } - static int l_setVolume(lua_State* L) + LUA_IMPLEMENT int l_setVolume(lua_State* L) { float volume = luax_checknumber(L, 1); Audio::get()->setVolume(volume); return 0; } - static int l_newSource(lua_State* L) + LUA_IMPLEMENT int l_newSource(lua_State* L) { AssetDatabase* fs = AssetDatabase::get(); const char* f = luax_checkstring(L, 1); @@ -89,14 +89,14 @@ namespace JinEngine return 1; } - static int l_destroy(lua_State* L) + LUA_IMPLEMENT int l_destroy(lua_State* L) { Audio* audio = Audio::get(); audio->quit(); return 0; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "init", l_init }, { "play", l_play }, { "stop", l_stop }, @@ -108,9 +108,9 @@ namespace JinEngine { 0, 0 } }; - extern int luaopen_Source(lua_State* L); + LUA_PORT int luaopen_Source(lua_State* L); - int luaopen_audio(lua_State* L) + LUA_EXPORT int luaopen_audio(lua_State* L) { luaopen_Source(L); diff --git a/src/lua/modules/audio/je_lua_source.cpp b/src/lua/modules/audio/je_lua_source.cpp index bf43ceb..afb6cfe 100644 --- a/src/lua/modules/audio/je_lua_source.cpp +++ b/src/lua/modules/audio/je_lua_source.cpp @@ -1,6 +1,6 @@ #include "libjin/jin.h" #include "lua/modules/luax.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "lua/modules/types.h" namespace JinEngine @@ -12,48 +12,48 @@ namespace JinEngine typedef Ref<Source>& SourceRef; - static inline SourceRef checkSource(lua_State* L) + LUA_IMPLEMENT inline SourceRef checkSource(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_AUDIO_SOURCE); return proxy->getRef<Source>(); } - static int l_play(lua_State* L) + LUA_IMPLEMENT int l_play(lua_State* L) { SourceRef ref = checkSource(L); ref->play(); return 0; } - static int l_stop(lua_State* L) + LUA_IMPLEMENT int l_stop(lua_State* L) { SourceRef ref = checkSource(L); ref->stop(); return 0; } - static int l_pause(lua_State* L) + LUA_IMPLEMENT int l_pause(lua_State* L) { SourceRef ref = checkSource(L); ref->pause(); return 0; } - static int l_rewind(lua_State* L) + LUA_IMPLEMENT int l_rewind(lua_State* L) { SourceRef ref = checkSource(L); ref->rewind(); return 0; } - static int l_resume(lua_State* L) + LUA_IMPLEMENT int l_resume(lua_State* L) { SourceRef ref = checkSource(L); ref->resume(); return 0; } - static int l_isStop(lua_State* L) + LUA_IMPLEMENT int l_isStop(lua_State* L) { SourceRef ref = checkSource(L); bool isStop = ref->isStopped(); @@ -61,7 +61,7 @@ namespace JinEngine return 1; } - static int l_isPaused(lua_State* L) + LUA_IMPLEMENT int l_isPaused(lua_State* L) { SourceRef ref = checkSource(L); bool isPaused = ref->isPaused(); @@ -69,7 +69,7 @@ namespace JinEngine return 1; } - static int l_setVolume(lua_State* L) + LUA_IMPLEMENT int l_setVolume(lua_State* L) { SourceRef ref = checkSource(L); float volume = luax_checknumber(L, 2); @@ -77,7 +77,7 @@ namespace JinEngine return 0; } - static int l_setLoop(lua_State* L) + LUA_IMPLEMENT int l_setLoop(lua_State* L) { SourceRef ref = checkSource(L); bool loop = luax_checkbool(L, 2); @@ -85,14 +85,14 @@ namespace JinEngine return 0; } - static int l_gc(lua_State* L) + LUA_IMPLEMENT int l_gc(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_AUDIO_SOURCE); proxy->release(); return 0; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "__gc", l_gc }, { "play", l_play }, { "stop", l_stop }, @@ -106,7 +106,7 @@ namespace JinEngine { 0, 0 } }; - int luaopen_Source(lua_State* L) + LUA_EXPORT int luaopen_Source(lua_State* L) { luax_newtype(L, JIN_AUDIO_SOURCE, f); return 0; diff --git a/src/lua/modules/bit/je_lua_bit.cpp b/src/lua/modules/bit/je_lua_bit.cpp index cedd60a..f182ebd 100644 --- a/src/lua/modules/bit/je_lua_bit.cpp +++ b/src/lua/modules/bit/je_lua_bit.cpp @@ -1,5 +1,7 @@ +#include "lua/common/je_lua_common.h" #include "lua/modules/luax.h" #include "libjin/jin.h" + #include <cstdlib> namespace JinEngine @@ -7,7 +9,7 @@ namespace JinEngine namespace Lua { - static int l_and(lua_State* L) + LUA_IMPLEMENT int l_and(lua_State* L) { int a = luax_checkinteger(L, 1); int b = luax_checkinteger(L, 2); @@ -15,7 +17,7 @@ namespace JinEngine return 1; } - static int l_or(lua_State* L) + LUA_IMPLEMENT int l_or(lua_State* L) { int a = luax_checkinteger(L, 1); int b = luax_checkinteger(L, 2); @@ -23,7 +25,7 @@ namespace JinEngine return 1; } - static int l_xor(lua_State* L) + LUA_IMPLEMENT int l_xor(lua_State* L) { int a = luax_checkinteger(L, 1); int b = luax_checkinteger(L, 2); @@ -31,14 +33,14 @@ namespace JinEngine return 1; } - static int l_not(lua_State* L) + LUA_IMPLEMENT int l_not(lua_State* L) { int n = luax_checkinteger(L, 1); luax_pushinteger(L, ~n); return 1; } - static int l_lshift(lua_State* L) + LUA_IMPLEMENT int l_lshift(lua_State* L) { int a = luax_checkinteger(L, 1); int b = luax_checkinteger(L, 2); @@ -46,7 +48,7 @@ namespace JinEngine return 1; } - static int l_rshift(lua_State* L) + LUA_IMPLEMENT int l_rshift(lua_State* L) { int a = luax_checkinteger(L, 1); int b = luax_checkinteger(L, 2); @@ -54,7 +56,7 @@ namespace JinEngine return 1; } - static int l_include(lua_State* L) + LUA_IMPLEMENT int l_include(lua_State* L) { int a = luax_checkinteger(L, 1); int b = luax_checkinteger(L, 2); @@ -62,7 +64,7 @@ namespace JinEngine return 1; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "bAnd", l_and }, { "bOr" , l_or }, { "bXor", l_xor }, @@ -73,7 +75,7 @@ namespace JinEngine { 0, 0 } }; - int luaopen_bit(lua_State* L) + LUA_EXPORT int luaopen_bit(lua_State* L) { luax_newlib(L, f); diff --git a/src/lua/modules/core/je_lua_core.cpp b/src/lua/modules/core/je_lua_core.cpp index 1b7d762..0e4cdbb 100644 --- a/src/lua/modules/core/je_lua_core.cpp +++ b/src/lua/modules/core/je_lua_core.cpp @@ -1,3 +1,4 @@ +#include "lua/common/je_lua_common.h" #include "lua/modules/luax.h" #include "libjin/jin.h" @@ -8,34 +9,34 @@ namespace JinEngine using namespace JinEngine::Game; - static int l_running(lua_State* L) + LUA_IMPLEMENT int l_running(lua_State* L) { - static Application* game = Application::get(); - bool running = game->running(); + static Application* app = Application::get(); + bool running = app->running(); luax_pushboolean(L, running); return 1; } - static int l_stop(lua_State* L) + LUA_IMPLEMENT int l_stop(lua_State* L) { Application::get()->stop(); return 0; } - static int l_quit(lua_State* L) + LUA_IMPLEMENT int l_quit(lua_State* L) { Application::get()->quit(); return 0; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "running", l_running }, { "stop", l_stop }, { "quit", l_quit }, { 0, 0 } }; - int luaopen_core(lua_State* L) + LUA_EXPORT int luaopen_core(lua_State* L) { luax_newlib(L, f); diff --git a/src/lua/modules/event/je_lua_event.cpp b/src/lua/modules/event/je_lua_event.cpp index 9f565d0..9e2e834 100644 --- a/src/lua/modules/event/je_lua_event.cpp +++ b/src/lua/modules/event/je_lua_event.cpp @@ -1,21 +1,22 @@ /** * Event module */ +#include "lua/common/je_lua_common.h" #include "lua/modules/luax.h" #include "libjin/jin.h" +using namespace JinEngine; +using namespace JinEngine::Input; + namespace JinEngine { namespace Lua { - using namespace JinEngine; - using namespace JinEngine::Input; - /** * Load event poll, return a iterator(a table). */ - static int l_event_poll(lua_State *L) + LUA_IMPLEMENT int l_event_poll(lua_State *L) { /* table to store events */ luax_newtable(L); @@ -112,7 +113,7 @@ namespace JinEngine return 1; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "poll", l_event_poll }, { 0, 0 } }; @@ -120,7 +121,7 @@ namespace JinEngine /** * load event module */ - int luaopen_event(lua_State* L) + LUA_EXPORT int luaopen_event(lua_State* L) { luax_newlib(L, f); return 1; diff --git a/src/lua/modules/filesystem/je_lua_filesystem.cpp b/src/lua/modules/filesystem/je_lua_filesystem.cpp index 7466ce8..3c3c12c 100644 --- a/src/lua/modules/filesystem/je_lua_filesystem.cpp +++ b/src/lua/modules/filesystem/je_lua_filesystem.cpp @@ -1,3 +1,4 @@ +#include "lua/common/je_lua_common.h" #include "lua/modules/luax.h" #include "libjin/jin.h" #include <string> @@ -9,25 +10,25 @@ namespace JinEngine namespace Lua { - static struct + LUA_IMPLEMENT struct { AssetDatabase* fs; } context; - static int l_init(lua_State* L) + LUA_IMPLEMENT int l_init(lua_State* L) { context.fs = AssetDatabase::get(); return 0; } - static int l_mount(lua_State* L) + LUA_IMPLEMENT int l_mount(lua_State* L) { const char* path = luax_checkstring(L, 1); context.fs->mount(path); return 0; } - static int l_exist(lua_State * L) + LUA_IMPLEMENT int l_exist(lua_State * L) { const char* path = luax_checkstring(L, 1); int r = context.fs->exists(path); @@ -35,7 +36,7 @@ namespace JinEngine return 1; } - static int l_isDir(lua_State* L) + LUA_IMPLEMENT int l_isDir(lua_State* L) { const char* path = luax_checkstring(L, 1); int r = context.fs->isDir(path); @@ -43,7 +44,7 @@ namespace JinEngine return 1; } - static int l_isFile(lua_State* L) + LUA_IMPLEMENT int l_isFile(lua_State* L) { const char* path = luax_checkstring(L, 1); int r = context.fs->isFile(path); @@ -51,7 +52,7 @@ namespace JinEngine return 1; } - static int loadbuffer(lua_State* L) + LUA_IMPLEMENT int loadbuffer(lua_State* L) { const char* filename = lua_tostring(L, -1); Buffer bf; @@ -60,7 +61,7 @@ namespace JinEngine return 1; } - static int loader(lua_State* L) + LUA_IMPLEMENT int loader(lua_State* L) { const char * filename = lua_tostring(L, -1); @@ -107,7 +108,7 @@ namespace JinEngine return 1; } - static int l_read(lua_State* L) + LUA_IMPLEMENT int l_read(lua_State* L) { AssetDatabase* fs = context.fs; const char* file = luax_checkstring(L, 1); @@ -119,7 +120,7 @@ namespace JinEngine return 2; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "init", l_init }, { "mount", l_mount }, { "isDirectory", l_isDir }, @@ -129,7 +130,7 @@ namespace JinEngine { 0, 0 } }; - int luaopen_filesystem(lua_State* L) + LUA_EXPORT int luaopen_filesystem(lua_State* L) { luax_newlib(L, f); luax_registersearcher(L, loader, 1); diff --git a/src/lua/modules/graphics/je_lua_bitmap.cpp b/src/lua/modules/graphics/je_lua_bitmap.cpp index 13517f9..a8d5bc0 100644 --- a/src/lua/modules/graphics/je_lua_bitmap.cpp +++ b/src/lua/modules/graphics/je_lua_bitmap.cpp @@ -1,31 +1,31 @@ +#include "lua/common/je_lua_common.h" #include "lua/modules/luax.h" #include "lua/modules/types.h" -#include "lua/common/common.h" #include "libjin/jin.h" +using namespace JinEngine::Graphics; + namespace JinEngine { namespace Lua { - using namespace JinEngine::Graphics; - typedef Ref<Bitmap>& BitmapRef; - static inline BitmapRef checkBitmap(lua_State* L) + LUA_IMPLEMENT inline BitmapRef checkBitmap(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_BITMAP); return proxy->getRef<Bitmap>(); } - static int l_gc(lua_State* L) + LUA_IMPLEMENT int l_gc(lua_State* L) { BitmapRef ref = checkBitmap(L); ref.release(); return 0; } - static int l_getWidth(lua_State* L) + LUA_IMPLEMENT int l_getWidth(lua_State* L) { BitmapRef ref = checkBitmap(L); int w = ref->getWidth(); @@ -33,7 +33,7 @@ namespace JinEngine return 1; } - static int l_getHeight(lua_State* L) + LUA_IMPLEMENT int l_getHeight(lua_State* L) { BitmapRef ref = checkBitmap(L); int h = ref->getHeight(); @@ -41,7 +41,7 @@ namespace JinEngine return 1; } - static int l_getSize(lua_State* L) + LUA_IMPLEMENT int l_getSize(lua_State* L) { BitmapRef ref = checkBitmap(L); int w = ref->getWidth(); @@ -51,7 +51,7 @@ namespace JinEngine return 2; } - static int l_getPixel(lua_State* L) + LUA_IMPLEMENT int l_getPixel(lua_State* L) { BitmapRef ref = checkBitmap(L); int x = luax_checkinteger(L, 2); @@ -64,7 +64,7 @@ namespace JinEngine return 4; } - static int l_setPixel(lua_State* L) + LUA_IMPLEMENT int l_setPixel(lua_State* L) { BitmapRef ref = checkBitmap(L); int x = luax_checkinteger(L, 2); @@ -82,7 +82,7 @@ namespace JinEngine return 0; } - static int l_clone(lua_State* L) + LUA_IMPLEMENT int l_clone(lua_State* L) { BitmapRef ref = checkBitmap(L); Bitmap* bitmap = ref.getObject(); @@ -92,7 +92,7 @@ namespace JinEngine return 1; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "__gc", l_gc }, { "getWidth", l_getWidth }, { "getHeight", l_getHeight }, @@ -103,7 +103,7 @@ namespace JinEngine { 0, 0 } }; - int luaopen_Bitmap(lua_State* L) + LUA_EXPORT int luaopen_Bitmap(lua_State* L) { luax_newtype(L, JIN_GRAPHICS_BITMAP, f); return 0; diff --git a/src/lua/modules/graphics/je_lua_canvas.cpp b/src/lua/modules/graphics/je_lua_canvas.cpp index e49e209..9461c03 100644 --- a/src/lua/modules/graphics/je_lua_canvas.cpp +++ b/src/lua/modules/graphics/je_lua_canvas.cpp @@ -1,6 +1,6 @@ #include "lua/modules/luax.h" #include "lua/modules/types.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "libjin/jin.h" namespace JinEngine @@ -12,27 +12,27 @@ namespace JinEngine typedef Ref<Canvas>& CanvasRef; - static inline CanvasRef checkCanvas(lua_State* L) + LUA_IMPLEMENT inline CanvasRef checkCanvas(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_CANVAS); return proxy->getRef<Canvas>(); } - static int l_getWidth(lua_State* L) + LUA_IMPLEMENT int l_getWidth(lua_State* L) { CanvasRef ref = checkCanvas(L); luax_pushnumber(L, ref->getWidth()); return 1; } - static int l_getHeight(lua_State* L) + LUA_IMPLEMENT int l_getHeight(lua_State* L) { CanvasRef ref = checkCanvas(L); luax_pushnumber(L, ref->getHeight()); return 1; } - static int l_getSize(lua_State* L) + LUA_IMPLEMENT int l_getSize(lua_State* L) { CanvasRef ref = checkCanvas(L); luax_pushnumber(L, ref->getWidth()); @@ -40,14 +40,14 @@ namespace JinEngine return 2; } - static int l_gc(lua_State* L) + LUA_IMPLEMENT int l_gc(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_CANVAS); proxy->release(); return 0; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "__gc", l_gc }, { "getWidth", l_getWidth }, { "getHeight", l_getHeight }, @@ -55,7 +55,7 @@ namespace JinEngine { 0, 0 } }; - int luaopen_Canvas(lua_State* L) + LUA_EXPORT int luaopen_Canvas(lua_State* L) { luax_newtype(L, JIN_GRAPHICS_CANVAS, f); return 0; diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp index f98d640..df68957 100644 --- a/src/lua/modules/graphics/je_lua_graphics.cpp +++ b/src/lua/modules/graphics/je_lua_graphics.cpp @@ -4,7 +4,7 @@ #include "libjin/jin.h" #include "lua/modules/luax.h" #include "lua/modules/types.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" using namespace std; using namespace JinEngine; @@ -27,7 +27,7 @@ namespace JinEngine Font* defaultFont = nullptr; } context; - static int l_init(lua_State* L) + LUA_IMPLEMENT int l_init(lua_State* L) { Window* wnd = Window::get(); Window::Setting setting; @@ -45,21 +45,6 @@ namespace JinEngine { /* load default font */ Bitmap* bitmap = Bitmap::createBitmap(default_font_bitmap, sizeof(default_font_bitmap)); - const Color* pixels = bitmap->getPixels(); - ofstream f = ofstream(); - f.open("font.pixels", ios_base::app); - for (int y = 0; y < bitmap->getHeight(); ++y) - { - for (int x = 0; x < bitmap->getWidth(); ++x) - { - Color c = pixels[x + y * bitmap->getWidth()]; - f << (int)c.r << ","; - f << (int)c.g << ","; - f << (int)c.b << ","; - f << (int)c.a << ","; - } - } - TextureFont* tf = TextureFont::createTextureFont(bitmap, Text(Encode::UTF8, default_charset), default_font_split, bitmap->getHeight()); context.defaultFont = tf; delete bitmap; @@ -70,7 +55,7 @@ namespace JinEngine return 1; } - static int l_setTitle(lua_State* L) + LUA_IMPLEMENT int l_setTitle(lua_State* L) { Window* wnd = Window::get(); const char* title = luax_checkstring(L, 1); @@ -78,14 +63,14 @@ namespace JinEngine return 0; } - static int l_destroy(lua_State* L) + LUA_IMPLEMENT int l_destroy(lua_State* L) { Window* wnd = Window::get(); wnd->quit(); return 0; } - static int l_getSize(lua_State* L) + LUA_IMPLEMENT int l_getSize(lua_State* L) { Window* wnd = Window::get(); luax_pushnumber(L, wnd->getW()); @@ -93,21 +78,21 @@ namespace JinEngine return 2; } - static int l_getWidth(lua_State* L) + LUA_IMPLEMENT int l_getWidth(lua_State* L) { Window* wnd = Window::get(); luax_pushnumber(L, wnd->getW()); return 1; } - static int l_getHeight(lua_State* L) + LUA_IMPLEMENT int l_getHeight(lua_State* L) { Window* wnd = Window::get(); luax_pushnumber(L, wnd->getH()); return 1; } - static int l_newBitmap(lua_State* L) + LUA_IMPLEMENT int l_newBitmap(lua_State* L) { Bitmap* bitmap = nullptr; if (luax_gettop(L) == 2) @@ -162,7 +147,7 @@ namespace JinEngine } /* jin.graphics.newTexture(bitmap) */ - static int l_newTexture(lua_State* L) + LUA_IMPLEMENT int l_newTexture(lua_State* L) { Texture* texture = nullptr; if (luax_istype(L, 1, JIN_GRAPHICS_BITMAP)) @@ -182,7 +167,7 @@ namespace JinEngine return 1; } - static int l_newShader(lua_State* L) + LUA_IMPLEMENT int l_newShader(lua_State* L) { const char* program = luax_checkstring(L, 1); Shader* jsl = Shader::createShader(program); @@ -197,7 +182,7 @@ namespace JinEngine return 1; } - static int l_newShaderf(lua_State* L) + LUA_IMPLEMENT int l_newShaderf(lua_State* L) { const char* path = luax_checkstring(L, 1); AssetDatabase* fs = AssetDatabase::get(); @@ -221,7 +206,7 @@ namespace JinEngine return 1; } - static int l_newCanvas(lua_State* L) + LUA_IMPLEMENT int l_newCanvas(lua_State* L) { int w = luax_checknumber(L, 1); int h = luax_checknumber(L, 2); @@ -231,13 +216,13 @@ namespace JinEngine return 1; } - static int l_clear(lua_State* L) + LUA_IMPLEMENT int l_clear(lua_State* L) { glClear(GL_COLOR_BUFFER_BIT); return 0; } - static int l_setClearColor(lua_State* L) + LUA_IMPLEMENT int l_setClearColor(lua_State* L) { if (luax_gettop(L) == 0) { @@ -257,13 +242,13 @@ namespace JinEngine return 0; } - static int l_present(lua_State* L) + LUA_IMPLEMENT int l_present(lua_State* L) { Window::get()->swapBuffers(); return 0; } - static void l_draw_texture(lua_State* L) + LUA_IMPLEMENT void l_draw_texture(lua_State* L) { if (!luax_istype(L, 1, JIN_GRAPHICS_TEXTURE)) return; @@ -279,7 +264,7 @@ namespace JinEngine tex->render(x, y, sx, sy, r, ox, oy); } - static void l_draw_canvas(lua_State* L) + LUA_IMPLEMENT void l_draw_canvas(lua_State* L) { if (!luax_istype(L, 1, JIN_GRAPHICS_CANVAS)) return; @@ -296,7 +281,7 @@ namespace JinEngine } /* jin.graphics.draw(text, font, x, y) */ - static void l_draw_text(lua_State* L) + LUA_IMPLEMENT void l_draw_text(lua_State* L) { if (!luax_istype(L, 1, JIN_GRAPHICS_TEXT)) return; @@ -326,7 +311,7 @@ namespace JinEngine } /* jin.graphics.draw(page, x, y) */ - static void l_draw_page(lua_State* L) + LUA_IMPLEMENT void l_draw_page(lua_State* L) { if (!luax_istype(L, 1, JIN_GRAPHICS_PAGE)) return; @@ -338,7 +323,7 @@ namespace JinEngine font->render(page, x, y); } - static int l_draw(lua_State* L) + LUA_IMPLEMENT int l_draw(lua_State* L) { if (luax_istype(L, 1, JIN_GRAPHICS_TEXTURE)) l_draw_texture(L); @@ -357,7 +342,7 @@ namespace JinEngine } // draw(tex, quad, x, y, sx, sy, r, ax, ay) - static int l_drawq(lua_State* L) + LUA_IMPLEMENT int l_drawq(lua_State* L) { if (!luax_istable(L, 2)) { @@ -398,7 +383,7 @@ namespace JinEngine /* print(string, x, y, lineheight, spacing) */ /* need set font */ - static int l_print(lua_State* L) + LUA_IMPLEMENT int l_print(lua_State* L) { Font* font = context.curFont; if (font == nullptr) @@ -414,7 +399,7 @@ namespace JinEngine return 0; } - static int l_setColor(lua_State* L) + LUA_IMPLEMENT int l_setColor(lua_State* L) { if (luax_gettop(L) == 0) { @@ -436,7 +421,7 @@ namespace JinEngine return 0; } - static int l_getColor(lua_State * L) + LUA_IMPLEMENT int l_getColor(lua_State * L) { luax_pushnumber(L, context.curRenderColor.r); luax_pushnumber(L, context.curRenderColor.g); @@ -445,7 +430,7 @@ namespace JinEngine return 4; } - static int l_bindCanvas(lua_State* L) + LUA_IMPLEMENT int l_bindCanvas(lua_State* L) { if (luax_gettop(L) == 0) { @@ -459,13 +444,13 @@ namespace JinEngine return 0; } - static int l_unbindCanvas(lua_State* L) + LUA_IMPLEMENT int l_unbindCanvas(lua_State* L) { Canvas::unbind(); return 0; } - static int l_useShader(lua_State* L) + LUA_IMPLEMENT int l_useShader(lua_State* L) { if (luax_gettop(L) == 0) { @@ -485,13 +470,13 @@ namespace JinEngine return 0; } - static int l_setBlend(lua_State* L) + LUA_IMPLEMENT int l_setBlend(lua_State* L) { return 0; } - static RenderMode strtomode(const char* str) + LUA_IMPLEMENT RenderMode strtomode(const char* str) { std::string s = std::string(str); if (s == "fill") return RenderMode::FILL; @@ -499,7 +484,7 @@ namespace JinEngine else return RenderMode::NONE; } - static int l_point(lua_State* L) + LUA_IMPLEMENT int l_point(lua_State* L) { int x = luax_checknumber(L, 1); int y = luax_checknumber(L, 2); @@ -508,7 +493,7 @@ namespace JinEngine return 0; } - static int l_line(lua_State* L) + LUA_IMPLEMENT int l_line(lua_State* L) { int x1 = luax_checknumber(L, 1); int y1 = luax_checknumber(L, 2); @@ -519,7 +504,7 @@ namespace JinEngine return 0; } - static int l_rect(lua_State* L) + LUA_IMPLEMENT int l_rect(lua_State* L) { const char* modestr = luax_checkstring(L, 1); RenderMode mode = strtomode(modestr); @@ -540,7 +525,7 @@ namespace JinEngine return 0; } - static int l_circle(lua_State* L) + LUA_IMPLEMENT int l_circle(lua_State* L) { const char* modestr = luax_checkstring(L, 1); RenderMode mode = strtomode(modestr); @@ -560,7 +545,7 @@ namespace JinEngine return 0; } - static int l_triangle(lua_State* L) + LUA_IMPLEMENT int l_triangle(lua_State* L) { const char* modestr = luax_checkstring(L, 1); RenderMode mode = strtomode(modestr); @@ -586,7 +571,7 @@ namespace JinEngine return 0; } - static int l_polygon(lua_State* L) + LUA_IMPLEMENT int l_polygon(lua_State* L) { const char* modestr = luax_checkstring(L, 1); int n = luax_checknumber(L, 2); @@ -601,7 +586,7 @@ namespace JinEngine int tn = luax_tableidxlen(L, 3); if (tn != n * 2) { - static char* emsg = \ + LUA_IMPLEMENT char* emsg = \ "number of polygon vertices doesn't match " \ "provided n, expect %d numbers but get %d"; luax_error(L, emsg, n * 2, tn); @@ -621,7 +606,7 @@ namespace JinEngine return 0; } - static int l_newTTFData(lua_State* L) + LUA_IMPLEMENT int l_newTTFData(lua_State* L) { Proxy* proxy = (Proxy*)luax_newinstance(L, JIN_GRAPHICS_TTFDATA, sizeof(Proxy)); TTFData* fd = nullptr; @@ -643,7 +628,7 @@ namespace JinEngine } /* newText(str[, encode]) */ - static int l_newText(lua_State* L) + LUA_IMPLEMENT int l_newText(lua_State* L) { Encode encode = Encode::UTF8; if (luax_gettop(L) == 2) @@ -667,7 +652,7 @@ namespace JinEngine } /* newTextureFont(bitmap, text, color | cellw, cellh) */ - static int l_newTextureFont(lua_State* L) + LUA_IMPLEMENT int l_newTextureFont(lua_State* L) { Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_BITMAP); Bitmap* bitmap = p->getObject<Bitmap>(); @@ -719,7 +704,7 @@ namespace JinEngine } /* setFont(font) */ - static int l_setFont(lua_State* L) + LUA_IMPLEMENT int l_setFont(lua_State* L) { if (luax_istype(L, 1, JIN_GRAPHICS_TTF)) { @@ -736,13 +721,13 @@ namespace JinEngine return 0; } - static int l_unsetFont(lua_State* L) + LUA_IMPLEMENT int l_unsetFont(lua_State* L) { context.curFont = context.defaultFont; return 0; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { /* window */ { "init", l_init }, { "setTitle", l_setTitle }, @@ -786,17 +771,17 @@ namespace JinEngine { 0, 0 } }; - extern int luaopen_Texture(lua_State* L); - extern int luaopen_Text(lua_State* L); - extern int luaopen_TTF(lua_State* L); - extern int luaopen_TextureFont(lua_State* L); - extern int luaopen_TTFData(lua_State* L); - extern int luaopen_Page(lua_State* L); - extern int luaopen_Canvas(lua_State* L); - extern int luaopen_JSL(lua_State* L); - extern int luaopen_Bitmap(lua_State* L); + LUA_PORT int luaopen_Texture(lua_State* L); + LUA_PORT int luaopen_Text(lua_State* L); + LUA_PORT int luaopen_TTF(lua_State* L); + LUA_PORT int luaopen_TextureFont(lua_State* L); + LUA_PORT int luaopen_TTFData(lua_State* L); + LUA_PORT int luaopen_Page(lua_State* L); + LUA_PORT int luaopen_Canvas(lua_State* L); + LUA_PORT int luaopen_JSL(lua_State* L); + LUA_PORT int luaopen_Bitmap(lua_State* L); - int luaopen_graphics(lua_State* L) + LUA_EXPORT int luaopen_graphics(lua_State* L) { // register types luaopen_Bitmap(L); diff --git a/src/lua/modules/graphics/je_lua_page.cpp b/src/lua/modules/graphics/je_lua_page.cpp index 8c9e918..2505ec5 100644 --- a/src/lua/modules/graphics/je_lua_page.cpp +++ b/src/lua/modules/graphics/je_lua_page.cpp @@ -1,6 +1,6 @@ #include "lua/modules/luax.h" #include "lua/modules/types.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "libjin/jin.h" #include <iostream> @@ -20,7 +20,7 @@ namespace JinEngine return proxy->getObject<Page>(); } - static int l_gc(lua_State* L) + LUA_IMPLEMENT int l_gc(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_PAGE); { @@ -33,7 +33,7 @@ namespace JinEngine return 0; } - static int l_getSize(lua_State* L) + LUA_IMPLEMENT int l_getSize(lua_State* L) { Page* page = getPage(L); luax_pushinteger(L, page->size.w); @@ -41,21 +41,21 @@ namespace JinEngine return 2; } - static int l_getWidth(lua_State* L) + LUA_IMPLEMENT int l_getWidth(lua_State* L) { Page* page = getPage(L); luax_pushinteger(L, page->size.w); return 1; } - static int l_getHeight(lua_State* L) + LUA_IMPLEMENT int l_getHeight(lua_State* L) { Page* page = getPage(L); luax_pushinteger(L, page->size.h); return 1; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "__gc", l_gc }, { "getSize", l_getSize }, { "getWidth", l_getWidth }, @@ -63,7 +63,7 @@ namespace JinEngine { 0, 0 } }; - int luaopen_Page(lua_State* L) + LUA_EXPORT int luaopen_Page(lua_State* L) { luax_newtype(L, JIN_GRAPHICS_PAGE, f); return 0; diff --git a/src/lua/modules/graphics/je_lua_shader.cpp b/src/lua/modules/graphics/je_lua_shader.cpp index d7733d4..6aa45e2 100644 --- a/src/lua/modules/graphics/je_lua_shader.cpp +++ b/src/lua/modules/graphics/je_lua_shader.cpp @@ -1,6 +1,6 @@ #include "lua/modules/luax.h" #include "lua/modules/types.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "libjin/jin.h" namespace JinEngine @@ -21,7 +21,7 @@ namespace JinEngine /** * jsl:sendNumber("variable", 0.1) */ - static int l_sendNumber (lua_State* L) + LUA_IMPLEMENT int l_sendNumber (lua_State* L) { ShaderRef ref = checkShader(L); const char* variable = luax_checkstring(L, 2); @@ -30,7 +30,7 @@ namespace JinEngine return 0; } - static int l_sendTexture (lua_State* L) + LUA_IMPLEMENT int l_sendTexture (lua_State* L) { ShaderRef ref = checkShader(L); const char* variable = luax_checkstring(L, 2); @@ -40,7 +40,7 @@ namespace JinEngine return 0; } - static int l_sendCanvas (lua_State* L) + LUA_IMPLEMENT int l_sendCanvas (lua_State* L) { ShaderRef ref = checkShader(L); const char* variable = luax_checkstring(L, 2); @@ -50,7 +50,7 @@ namespace JinEngine return 0; } - static int l_sendVec2 (lua_State* L) + LUA_IMPLEMENT int l_sendVec2 (lua_State* L) { ShaderRef ref = checkShader(L); const char* variable = luax_checkstring(L, 2); @@ -65,7 +65,7 @@ namespace JinEngine return 0; } - static int l_sendVec3 (lua_State* L) + LUA_IMPLEMENT int l_sendVec3 (lua_State* L) { ShaderRef ref = checkShader(L); const char* variable = luax_checkstring(L, 2); @@ -81,7 +81,7 @@ namespace JinEngine return 0; } - static int l_sendVec4 (lua_State* L) + LUA_IMPLEMENT int l_sendVec4 (lua_State* L) { ShaderRef ref = checkShader(L); const char* variable = luax_checkstring(L, 2); @@ -98,19 +98,19 @@ namespace JinEngine return 0; } - static int l_sendColor (lua_State* L) + LUA_IMPLEMENT int l_sendColor (lua_State* L) { return l_sendVec4(L); } - static int l_gc(lua_State* L) + LUA_IMPLEMENT int l_gc(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SHADER); proxy->release(); return 0; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "__gc", l_gc }, { "sendNumber", l_sendNumber }, { "sendTexture", l_sendTexture }, @@ -125,7 +125,7 @@ namespace JinEngine /** * JSL program */ - int luaopen_JSL(lua_State* L) + LUA_EXPORT int luaopen_JSL(lua_State* L) { luax_newtype(L, JIN_GRAPHICS_SHADER, f); return 0; diff --git a/src/lua/modules/graphics/je_lua_text.cpp b/src/lua/modules/graphics/je_lua_text.cpp index cbc82f1..34b0d77 100644 --- a/src/lua/modules/graphics/je_lua_text.cpp +++ b/src/lua/modules/graphics/je_lua_text.cpp @@ -1,6 +1,6 @@ #include "lua/modules/luax.h" #include "lua/modules/types.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "libjin/jin.h" namespace JinEngine @@ -10,19 +10,19 @@ namespace JinEngine using namespace JinEngine::Graphics; - static int l_gc(lua_State* L) + LUA_IMPLEMENT int l_gc(lua_State* L) { Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXT); p->release(); return 0; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "__gc", l_gc }, { 0, 0 } }; - int luaopen_Text(lua_State* L) + LUA_EXPORT int luaopen_Text(lua_State* L) { luax_newtype(L, JIN_GRAPHICS_TEXT, f); return 0; diff --git a/src/lua/modules/graphics/je_lua_texture.cpp b/src/lua/modules/graphics/je_lua_texture.cpp index 61bfaee..04d8f34 100644 --- a/src/lua/modules/graphics/je_lua_texture.cpp +++ b/src/lua/modules/graphics/je_lua_texture.cpp @@ -1,6 +1,6 @@ #include "lua/modules/luax.h" #include "lua/modules/types.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "libjin/jin.h" namespace JinEngine @@ -12,27 +12,27 @@ namespace JinEngine typedef Ref<Texture>& TextureRef; - static inline TextureRef checkTexture(lua_State* L) + LUA_IMPLEMENT inline TextureRef checkTexture(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTURE); return proxy->getRef<Texture>(); } - static int l_getWidth(lua_State* L) + LUA_IMPLEMENT int l_getWidth(lua_State* L) { TextureRef ref = checkTexture(L); luax_pushnumber(L, ref->getWidth()); return 1; } - static int l_getHeight(lua_State *L) + LUA_IMPLEMENT int l_getHeight(lua_State *L) { TextureRef ref = checkTexture(L); luax_pushnumber(L, ref->getHeight()); return 1; } - static int l_getSize(lua_State* L) + LUA_IMPLEMENT int l_getSize(lua_State* L) { TextureRef ref = checkTexture(L); luax_pushnumber(L, ref->getWidth()); @@ -40,14 +40,14 @@ namespace JinEngine return 2; } - static int l_gc(lua_State* L) + LUA_IMPLEMENT int l_gc(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTURE); proxy->release(); return 0; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "__gc", l_gc }, { "getWidth", l_getWidth }, { "getHeight", l_getHeight }, @@ -55,7 +55,7 @@ namespace JinEngine { 0, 0 } }; - int luaopen_Texture(lua_State* L) + LUA_EXPORT int luaopen_Texture(lua_State* L) { luax_newtype(L, JIN_GRAPHICS_TEXTURE, f); return 0; diff --git a/src/lua/modules/graphics/je_lua_texture_font.cpp b/src/lua/modules/graphics/je_lua_texture_font.cpp index a2e88ba..c3b9f64 100644 --- a/src/lua/modules/graphics/je_lua_texture_font.cpp +++ b/src/lua/modules/graphics/je_lua_texture_font.cpp @@ -1,6 +1,6 @@ #include "lua/modules/luax.h" #include "lua/modules/types.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "libjin/jin.h" namespace JinEngine @@ -10,7 +10,7 @@ namespace JinEngine using namespace JinEngine::Graphics; - static int l_gc(lua_State* L) + LUA_IMPLEMENT int l_gc(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTUREFONT); proxy->release(); @@ -18,7 +18,7 @@ namespace JinEngine } /* typeset(Text | string, lineheight, spacing) */ - static int l_typeset(lua_State* L) + LUA_IMPLEMENT int l_typeset(lua_State* L) { Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTUREFONT); TextureFont* tf = p->getObject<TextureFont>(); @@ -50,13 +50,13 @@ namespace JinEngine return 1; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "__gc", l_gc }, { "typeset", l_typeset }, { 0, 0 } }; - int luaopen_TextureFont(lua_State* L) + LUA_EXPORT int luaopen_TextureFont(lua_State* L) { luax_newtype(L, JIN_GRAPHICS_TEXTUREFONT, f); diff --git a/src/lua/modules/graphics/je_lua_ttf.cpp b/src/lua/modules/graphics/je_lua_ttf.cpp index 414c7eb..2818b06 100644 --- a/src/lua/modules/graphics/je_lua_ttf.cpp +++ b/src/lua/modules/graphics/je_lua_ttf.cpp @@ -1,16 +1,16 @@ #include "lua/modules/luax.h" #include "lua/modules/types.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "libjin/jin.h" +using namespace JinEngine::Graphics; + namespace JinEngine { namespace Lua { - using namespace JinEngine::Graphics; - - static int l_gc(lua_State* L) + LUA_IMPLEMENT int l_gc(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TTF); { @@ -24,7 +24,7 @@ namespace JinEngine } /* typeset(Text | string, lineheight, spacing) */ - static int l_typeset(lua_State* L) + LUA_IMPLEMENT int l_typeset(lua_State* L) { Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TTF); TTF* ttf = p->getObject<TTF>(); @@ -56,13 +56,13 @@ namespace JinEngine return 1; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "__gc", l_gc }, { "typeset", l_typeset }, { 0, 0 } }; - int luaopen_TTF(lua_State* L) + LUA_EXPORT int luaopen_TTF(lua_State* L) { luax_newtype(L, JIN_GRAPHICS_TTF, f); diff --git a/src/lua/modules/graphics/je_lua_ttf_data.cpp b/src/lua/modules/graphics/je_lua_ttf_data.cpp index 43c3613..269789c 100644 --- a/src/lua/modules/graphics/je_lua_ttf_data.cpp +++ b/src/lua/modules/graphics/je_lua_ttf_data.cpp @@ -1,16 +1,16 @@ #include "lua/modules/luax.h" #include "lua/modules/types.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "libjin/jin.h" +using namespace JinEngine::Graphics; + namespace JinEngine { namespace Lua { - using namespace JinEngine::Graphics; - - static int l_newTTF(lua_State* L) + LUA_IMPLEMENT int l_newTTF(lua_State* L) { Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TTFDATA); int fontsize = luax_checkinteger(L, 2); @@ -28,20 +28,20 @@ namespace JinEngine return 1; } - static int l_gc(lua_State* L) + LUA_IMPLEMENT int l_gc(lua_State* L) { Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TTFDATA); p->release(); return 0; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "__gc", l_gc }, { "newTTF", l_newTTF }, { 0, 0 } }; - int luaopen_TTFData(lua_State* L) + LUA_EXPORT int luaopen_TTFData(lua_State* L) { luax_newtype(L, JIN_GRAPHICS_TTFDATA, f); return 0; diff --git a/src/lua/modules/joypad/je_lua_joypad.cpp b/src/lua/modules/joypad/je_lua_joypad.cpp index d67a624..5972f40 100644 --- a/src/lua/modules/joypad/je_lua_joypad.cpp +++ b/src/lua/modules/joypad/je_lua_joypad.cpp @@ -1,16 +1,17 @@ -#include "libjin/jin.h" #include "lua/modules/luax.h" +#include "lua/common/je_lua_common.h" +#include "libjin/jin.h" namespace JinEngine { namespace Lua { - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { 0, 0 } }; - int luaopen_joypad(lua_State* L) + LUA_EXPORT int luaopen_joypad(lua_State* L) { luax_newlib(L, f); diff --git a/src/lua/modules/keyboard/je_lua_keyboard.cpp b/src/lua/modules/keyboard/je_lua_keyboard.cpp index 727a51e..6b7f3cd 100644 --- a/src/lua/modules/keyboard/je_lua_keyboard.cpp +++ b/src/lua/modules/keyboard/je_lua_keyboard.cpp @@ -1,3 +1,4 @@ +#include "lua/common/je_lua_common.h" #include "lua/modules/luax.h" namespace JinEngine @@ -6,7 +7,7 @@ namespace JinEngine { //https://wiki.libsdl.org/SDL_Keycode - int luaopen_keyboard(lua_State* L) + LUA_EXPORT int luaopen_keyboard(lua_State* L) { luax_newlib(L, 0); return 1; diff --git a/src/lua/modules/math/je_lua_math.cpp b/src/lua/modules/math/je_lua_math.cpp index 4891762..fd8ffa5 100644 --- a/src/lua/modules/math/je_lua_math.cpp +++ b/src/lua/modules/math/je_lua_math.cpp @@ -1,3 +1,4 @@ +#include "lua/common/je_lua_common.h" #include "lua/modules/luax.h" #include "libjin/jin.h" @@ -6,7 +7,7 @@ namespace JinEngine namespace Lua { - static int l_mod(lua_State* L) + LUA_IMPLEMENT int l_mod(lua_State* L) { int n = luax_checkinteger(L, 1); int m = luax_checkinteger(L, 2); @@ -15,12 +16,12 @@ namespace JinEngine return 1; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "mod", l_mod }, { 0, 0 } }; - int luaopen_math(lua_State* L) + LUA_EXPORT int luaopen_math(lua_State* L) { luax_newlib(L, f); return 1; diff --git a/src/lua/modules/mouse/je_lua_mouse.cpp b/src/lua/modules/mouse/je_lua_mouse.cpp index 9d45178..5802c72 100644 --- a/src/lua/modules/mouse/je_lua_mouse.cpp +++ b/src/lua/modules/mouse/je_lua_mouse.cpp @@ -1,3 +1,4 @@ +#include "lua/common/je_lua_common.h" #include "lua/modules/luax.h" #include "libjin/jin.h" @@ -8,7 +9,7 @@ namespace JinEngine using namespace JinEngine::Input; - static int l_pos(lua_State* L) + LUA_IMPLEMENT int l_pos(lua_State* L) { static Mouse* mouse = Mouse::get(); int x, y; @@ -18,7 +19,7 @@ namespace JinEngine return 2; } - static int l_setVisible(lua_State* L) + LUA_IMPLEMENT int l_setVisible(lua_State* L) { bool visible = luax_checkbool(L, 1); Mouse* mouse = Mouse::get(); @@ -26,13 +27,13 @@ namespace JinEngine return 0; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "position", l_pos }, { "setVisible", l_setVisible }, { 0, 0 } }; - int luaopen_mouse(lua_State* L) + LUA_EXPORT int luaopen_mouse(lua_State* L) { luax_newlib(L, f); return 1; diff --git a/src/lua/modules/net/je_lua_buffer.cpp b/src/lua/modules/net/je_lua_buffer.cpp index d2342f3..fd73364 100644 --- a/src/lua/modules/net/je_lua_buffer.cpp +++ b/src/lua/modules/net/je_lua_buffer.cpp @@ -1,6 +1,6 @@ #include "lua/modules/luax.h" #include "lua/modules/types.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "libjin/jin.h" #include "je_lua_buffer.h" @@ -22,7 +22,7 @@ namespace JinEngine } // net.Buffer:append(value) -> value_length - static int l_append(lua_State* L) + LUA_IMPLEMENT int l_append(lua_State* L) { BufferRef ref = checkNetBuffer(L); const int vp = 2; @@ -66,7 +66,7 @@ namespace JinEngine } // net.Buffer:grabString(offset) -> string, length - static int l_grabString(lua_State* L) + LUA_IMPLEMENT int l_grabString(lua_State* L) { BufferRef ref = checkNetBuffer(L); int offset = luax_checkinteger(L, 2); @@ -80,7 +80,7 @@ namespace JinEngine } // net.Buffer:grabInteger(offset) -> integer, length - static int l_grabInteger(lua_State* L) + LUA_IMPLEMENT int l_grabInteger(lua_State* L) { BufferRef ref = checkNetBuffer(L); int offset = luax_checkinteger(L, 2); @@ -91,7 +91,7 @@ namespace JinEngine return 2; } - static int l_grabFloat(lua_State* L) + LUA_IMPLEMENT int l_grabFloat(lua_State* L) { BufferRef ref = checkNetBuffer(L); int offset = luax_checkinteger(L, 2); @@ -102,7 +102,7 @@ namespace JinEngine return 2; } - static int l_grabBoolean(lua_State* L) + LUA_IMPLEMENT int l_grabBoolean(lua_State* L) { BufferRef ref = checkNetBuffer(L); int offset = luax_checkinteger(L, 2); @@ -113,14 +113,14 @@ namespace JinEngine return 2; } - static int l_gc(lua_State* L) + LUA_IMPLEMENT int l_gc(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_NETWORK_BUFFER); proxy->release(); return 0; } - static const luaL_Reg netbuffer_function[] = { + LUA_IMPLEMENT const luaL_Reg netbuffer_function[] = { { "__gc", l_gc }, { "append", l_append }, { "grabString", l_grabString }, @@ -132,7 +132,7 @@ namespace JinEngine } // namespace Net - int luaopen_Buffer(lua_State* L) + LUA_EXPORT int luaopen_Buffer(lua_State* L) { luax_newtype(L, JIN_NETWORK_BUFFER, Net::netbuffer_function); return 0; diff --git a/src/lua/modules/net/je_lua_buffer.h b/src/lua/modules/net/je_lua_buffer.h index 8733778..d713f53 100644 --- a/src/lua/modules/net/je_lua_buffer.h +++ b/src/lua/modules/net/je_lua_buffer.h @@ -3,7 +3,7 @@ #include <cstring> #include <cstdlib> -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" namespace JinEngine { diff --git a/src/lua/modules/net/je_lua_net.cpp b/src/lua/modules/net/je_lua_net.cpp index c477477..de5d506 100644 --- a/src/lua/modules/net/je_lua_net.cpp +++ b/src/lua/modules/net/je_lua_net.cpp @@ -1,7 +1,7 @@ #include "lua/modules/luax.h" #include "lua/modules/types.h" #include "libjin/jin.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "je_lua_buffer.h" namespace JinEngine @@ -12,13 +12,13 @@ namespace Lua using namespace JinEngine::Lua::Net; using namespace JinEngine::Net; - static int l_initNetwork(lua_State* L) + LUA_IMPLEMENT int l_initNetwork(lua_State* L) { JinEngine::Net::NetManager::get()->init(); return 1; } - static int l_Socket(lua_State* L) + LUA_IMPLEMENT int l_Socket(lua_State* L) { SocketInformation info = { 0 }; { @@ -53,7 +53,7 @@ namespace Lua return 1; } - static int l_Buffer(lua_State* L) + LUA_IMPLEMENT int l_Buffer(lua_State* L) { int size = luax_checkinteger(L, 1); Proxy* proxy = (Proxy*)luax_newinstance(L, JIN_NETWORK_BUFFER, sizeof(Proxy)); @@ -62,17 +62,17 @@ namespace Lua return 1; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "init", l_initNetwork }, { "newSocket", l_Socket }, { "newBuffer", l_Buffer }, { 0, 0 } }; - extern int luaopen_Socket(lua_State* L); - extern int luaopen_Buffer(lua_State* L); + LUA_PORT int luaopen_Socket(lua_State* L); + LUA_PORT int luaopen_Buffer(lua_State* L); - int luaopen_net(lua_State* L) + LUA_EXPORT int luaopen_net(lua_State* L) { luaopen_Socket(L); luaopen_Buffer(L); diff --git a/src/lua/modules/net/je_lua_socket.cpp b/src/lua/modules/net/je_lua_socket.cpp index 7ad6057..512bde3 100644 --- a/src/lua/modules/net/je_lua_socket.cpp +++ b/src/lua/modules/net/je_lua_socket.cpp @@ -1,6 +1,6 @@ #include "lua/modules/luax.h" #include "lua/modules/types.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "libjin/jin.h" #include "je_lua_buffer.h" @@ -16,20 +16,20 @@ namespace JinEngine const int BUFFER_SIZE = 1024; - static inline SocketRef checkSocket(lua_State* L, int pos = 1) + LUA_IMPLEMENT inline SocketRef checkSocket(lua_State* L, int pos = 1) { Proxy* proxy = (Proxy*)luax_checktype(L, pos, JIN_NETWORK_SOCKET); return proxy->getRef<Socket>(); } - static inline Ref<Buffer>& checkNetBuffer(lua_State* L, int pos = 1) + LUA_IMPLEMENT inline Ref<Buffer>& checkNetBuffer(lua_State* L, int pos = 1) { Proxy* proxy = (Proxy*)luax_checktype(L, pos, JIN_NETWORK_BUFFER); return proxy->getRef<Buffer>(); } // return net.Socket - static int l_accept(lua_State* L) + LUA_IMPLEMENT int l_accept(lua_State* L) { SocketRef socket = checkSocket(L); Socket* client = socket->accept(); @@ -39,7 +39,7 @@ namespace JinEngine } // return net.Buffer - static int l_receive(lua_State* L) + LUA_IMPLEMENT int l_receive(lua_State* L) { SocketRef socket = checkSocket(L); char buffer[BUFFER_SIZE] = {0}; @@ -51,7 +51,7 @@ namespace JinEngine } // Socket:receiveFrom(address, port) - static int l_receiveFrom(lua_State* L) + LUA_IMPLEMENT int l_receiveFrom(lua_State* L) { SocketRef socket = checkSocket(L); int address = luax_checkinteger(L, 2); @@ -65,7 +65,7 @@ namespace JinEngine } // Socket:send(net.Buffer) -> data_length - static int l_send(lua_State* L) + LUA_IMPLEMENT int l_send(lua_State* L) { SocketRef socket = checkSocket(L); Ref<Buffer>& ref = checkNetBuffer(L, 2); @@ -75,7 +75,7 @@ namespace JinEngine } // Socket:sendTo(address, port, net.Buffer) - static int l_sendTo(lua_State* L) + LUA_IMPLEMENT int l_sendTo(lua_State* L) { SocketRef socket = checkSocket(L); int address = luax_checkinteger(L, 2); @@ -85,14 +85,14 @@ namespace JinEngine return 0; } - static int l_close(lua_State* L) + LUA_IMPLEMENT int l_close(lua_State* L) { SocketRef socket = checkSocket(L); socket->close(); return 0; } - static int l_configBlocking(lua_State* L) + LUA_IMPLEMENT int l_configBlocking(lua_State* L) { SocketRef socket = checkSocket(L); bool blocking = luax_checkbool(L, 2); @@ -100,14 +100,14 @@ namespace JinEngine return 0; } - static int l_gc(lua_State* L) + LUA_IMPLEMENT int l_gc(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_NETWORK_SOCKET); proxy->release(); return 0; } - static const luaL_Reg socket_function[] = { + LUA_IMPLEMENT const luaL_Reg socket_function[] = { { "__gc", l_gc }, { "accept", l_accept }, { "receive", l_receive }, @@ -119,7 +119,7 @@ namespace JinEngine { 0, 0 } }; - int luaopen_Socket(lua_State* L) + LUA_EXPORT int luaopen_Socket(lua_State* L) { luax_newtype(L, JIN_NETWORK_SOCKET, socket_function); return 0; diff --git a/src/lua/modules/thread/je_lua_thread.cpp b/src/lua/modules/thread/je_lua_thread.cpp index d086595..9c2cb35 100644 --- a/src/lua/modules/thread/je_lua_thread.cpp +++ b/src/lua/modules/thread/je_lua_thread.cpp @@ -2,7 +2,7 @@ #include "lua/modules/types.h" #include "libjin/jin.h" #include "lua/jin.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "je_lua_thread.h" namespace JinEngine @@ -22,7 +22,7 @@ namespace JinEngine return proxy->getRef<Thread>(); } - static int threadRunner(void* t) + LUA_IMPLEMENT int threadRunner(void* t) { ThreadRef ref = *(Ref<Thread>*)t; lua_State* L = lua_open(); @@ -38,14 +38,14 @@ namespace JinEngine return 0; } - static int l_thread_gc(lua_State* L) + LUA_IMPLEMENT int l_thread_gc(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_THREAD_THREAD); proxy->release(); return 0; } - static int l_start(lua_State* L) + LUA_IMPLEMENT int l_start(lua_State* L) { ThreadRef ref = checkThread(L); bool result = ref->start(&ref); @@ -53,14 +53,14 @@ namespace JinEngine return 1; } - static int l_wait(lua_State* L) + LUA_IMPLEMENT int l_wait(lua_State* L) { ThreadRef ref = checkThread(L); ref->wait(); return 0; } - static int l_send(lua_State* L) + LUA_IMPLEMENT int l_send(lua_State* L) { ThreadRef ref = checkThread(L); int slot = luax_checkinteger(L, 2); @@ -93,7 +93,7 @@ namespace JinEngine return 0; } - static int l_receive(lua_State* L) + LUA_IMPLEMENT int l_receive(lua_State* L) { ThreadRef ref = checkThread(L); int slot = luax_checkinteger(L, 2); @@ -102,7 +102,7 @@ namespace JinEngine return 1; } - static int l_fetch(lua_State* L) + LUA_IMPLEMENT int l_fetch(lua_State* L) { ThreadRef ref = checkThread(L); int slot = luax_checkinteger(L, 2); @@ -136,7 +136,7 @@ namespace JinEngine return 1; } - static int l_demand(lua_State* L) + LUA_IMPLEMENT int l_demand(lua_State* L) { ThreadRef ref = checkThread(L); int slot = luax_checkinteger(L, 2); @@ -171,7 +171,7 @@ namespace JinEngine return 1; } - static int l_remove(lua_State* L) + LUA_IMPLEMENT int l_remove(lua_State* L) { ThreadRef ref = checkThread(L); int slot = luax_checkinteger(L, 2); @@ -179,7 +179,7 @@ namespace JinEngine return 0; } - static int l_getName(lua_State* L) + LUA_IMPLEMENT int l_getName(lua_State* L) { ThreadRef ref = checkThread(L); const char* name = ref->getName(); @@ -187,7 +187,7 @@ namespace JinEngine return 1; } - static int l_isRunning(lua_State* L) + LUA_IMPLEMENT int l_isRunning(lua_State* L) { ThreadRef ref = checkThread(L); bool running = ref->isRunning(); @@ -195,7 +195,7 @@ namespace JinEngine return 1; } - static const luaL_Reg thread_function[] = { + LUA_IMPLEMENT const luaL_Reg thread_function[] = { { "__gc", l_thread_gc }, { "start", l_start }, { "wait", l_wait }, @@ -209,14 +209,14 @@ namespace JinEngine { 0, 0 } }; - static int luaopen_Thread(lua_State* L) + LUA_IMPLEMENT int luaopen_Thread(lua_State* L) { luax_newtype(L, JIN_THREAD_THREAD, thread_function); return 0; } - static int l_newThread(lua_State* L) + LUA_IMPLEMENT int l_newThread(lua_State* L) { const char* name = luax_checkstring(L, 1); const char* code = luax_checkstring(L, 2); @@ -226,20 +226,20 @@ namespace JinEngine return 1; } - static int l_getThread(lua_State* L) + LUA_IMPLEMENT int l_getThread(lua_State* L) { luax_getglobal(L, MODULE_NAME); luax_getfield(L, -1, "_curThread"); return 1; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "newThread", l_newThread }, { "getThread", l_getThread }, { 0, 0 } }; - int luaopen_thread(lua_State* L) + LUA_EXPORT int luaopen_thread(lua_State* L) { luaopen_Thread(L); diff --git a/src/lua/modules/thread/je_lua_thread.h b/src/lua/modules/thread/je_lua_thread.h index 60d588a..de9a8a8 100644 --- a/src/lua/modules/thread/je_lua_thread.h +++ b/src/lua/modules/thread/je_lua_thread.h @@ -1,5 +1,5 @@ #include "libjin/jin.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" namespace JinEngine { diff --git a/src/lua/modules/time/je_lua_time.cpp b/src/lua/modules/time/je_lua_time.cpp index f6e6f26..aeda9c6 100644 --- a/src/lua/modules/time/je_lua_time.cpp +++ b/src/lua/modules/time/je_lua_time.cpp @@ -1,5 +1,6 @@ +#include "SDL2/SDL.h" +#include "lua/common/je_lua_common.h" #include "lua/modules/luax.h" -#include <SDL2/SDL.h> #include "libjin/jin.h" namespace JinEngine @@ -9,26 +10,26 @@ namespace JinEngine using namespace JinEngine::Time; - static int l_sec(lua_State* L) + LUA_IMPLEMENT int l_sec(lua_State* L) { luax_pushnumber(L, getSecond()); return 1; } - static int l_sleep(lua_State* L) + LUA_IMPLEMENT int l_sleep(lua_State* L) { double sec = luax_checknumber(L, 1); sleep(sec * 1000.0f); return 0; } - static const luaL_Reg f[] = { + LUA_IMPLEMENT const luaL_Reg f[] = { { "second", l_sec }, { "sleep", l_sleep }, { 0, 0 }, }; - int luaopen_time(lua_State* L) + LUA_EXPORT int luaopen_time(lua_State* L) { luax_newlib(L, f); return 1; |