aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-11-15 19:29:27 +0800
committerchai <chaifix@163.com>2018-11-15 19:29:27 +0800
commit7e51ff3bfae0becc260452a427a1fc1232a4b348 (patch)
treee2c4cddcd5ed719a611be4c92edf1991a63203c5 /src
parenta6f2d5fff89b7322009c46a9272668ca4c32ce64 (diff)
*修改代码结构
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/buildvm/buildvm.exebin121856 -> 121856 bytes
-rw-r--r--src/3rdparty/minilua/minilua.exebin209920 -> 209920 bytes
-rw-r--r--src/libjin/Graphics/je_bitmap.cpp20
-rw-r--r--src/libjin/Graphics/je_bitmap.h2
-rw-r--r--src/libjin/Graphics/je_sprite.h2
-rw-r--r--src/lua/common/je_lua_function.cpp0
-rw-r--r--src/lua/common/je_lua_function.h6
-rw-r--r--src/lua/common/je_lua_proxy.h5
-rw-r--r--src/lua/common/je_lua_shared.hpp7
-rw-r--r--src/lua/libraries/luax/luax.h7
-rw-r--r--src/lua/luax.h4
-rw-r--r--src/lua/modules/audio/je_lua_audio.cpp2
-rw-r--r--src/lua/modules/audio/je_lua_source.cpp3
-rw-r--r--src/lua/modules/audio/je_lua_source.h2
-rw-r--r--src/lua/modules/graphics/je_lua_bitmap.cpp3
-rw-r--r--src/lua/modules/graphics/je_lua_bitmap.h2
-rw-r--r--src/lua/modules/graphics/je_lua_canvas.cpp4
-rw-r--r--src/lua/modules/graphics/je_lua_canvas.h2
-rw-r--r--src/lua/modules/graphics/je_lua_graphics.cpp63
-rw-r--r--src/lua/modules/graphics/je_lua_page.cpp3
-rw-r--r--src/lua/modules/graphics/je_lua_page.h2
-rw-r--r--src/lua/modules/graphics/je_lua_shader.cpp3
-rw-r--r--src/lua/modules/graphics/je_lua_shader.h2
-rw-r--r--src/lua/modules/graphics/je_lua_sprite.cpp39
-rw-r--r--src/lua/modules/graphics/je_lua_sprite.h2
-rw-r--r--src/lua/modules/graphics/je_lua_spritesheet.cpp3
-rw-r--r--src/lua/modules/graphics/je_lua_spritesheet.h2
-rw-r--r--src/lua/modules/graphics/je_lua_text.cpp3
-rw-r--r--src/lua/modules/graphics/je_lua_text.h2
-rw-r--r--src/lua/modules/graphics/je_lua_texture.cpp4
-rw-r--r--src/lua/modules/graphics/je_lua_texture.h2
-rw-r--r--src/lua/modules/graphics/je_lua_texture_font.cpp4
-rw-r--r--src/lua/modules/graphics/je_lua_texture_font.h2
-rw-r--r--src/lua/modules/graphics/je_lua_ttf.cpp4
-rw-r--r--src/lua/modules/graphics/je_lua_ttf.h2
-rw-r--r--src/lua/modules/graphics/je_lua_ttf_data.cpp3
-rw-r--r--src/lua/modules/graphics/je_lua_ttf_data.h2
-rw-r--r--src/lua/modules/net/je_lua_buffer.cpp3
-rw-r--r--src/lua/modules/net/je_lua_buffer.h2
-rw-r--r--src/lua/modules/net/je_lua_net.cpp4
-rw-r--r--src/lua/modules/net/je_lua_socket.cpp3
-rw-r--r--src/lua/modules/net/je_lua_socket.h2
-rw-r--r--src/lua/modules/thread/je_lua_thread.cpp3
-rw-r--r--src/lua/modules/time/je_lua_time.cpp2
-rw-r--r--src/lua/modules/time/je_lua_timer.cpp4
-rw-r--r--src/lua/modules/time/je_lua_timer.h2
46 files changed, 173 insertions, 70 deletions
diff --git a/src/3rdparty/buildvm/buildvm.exe b/src/3rdparty/buildvm/buildvm.exe
index 6d94ce5..a41ba10 100644
--- a/src/3rdparty/buildvm/buildvm.exe
+++ b/src/3rdparty/buildvm/buildvm.exe
Binary files differ
diff --git a/src/3rdparty/minilua/minilua.exe b/src/3rdparty/minilua/minilua.exe
index d7f6719..5369029 100644
--- a/src/3rdparty/minilua/minilua.exe
+++ b/src/3rdparty/minilua/minilua.exe
Binary files differ
diff --git a/src/libjin/Graphics/je_bitmap.cpp b/src/libjin/Graphics/je_bitmap.cpp
index 711b8b5..cdab46d 100644
--- a/src/libjin/Graphics/je_bitmap.cpp
+++ b/src/libjin/Graphics/je_bitmap.cpp
@@ -56,6 +56,20 @@ namespace JinEngine
return bitmap;
}
+ /*static*/ Bitmap* Bitmap::createBitmap(int width, int height, std::function<Color(int, int, int, int)> drawer)
+ {
+ Bitmap* bitmap = new Bitmap(width, height);
+ for (int y = 0; y < height; ++y)
+ {
+ for (int x = 0; x < width; ++x)
+ {
+ Color c = drawer(width, height, x, y);
+ bitmap->setPixel(c, x, y);
+ }
+ }
+ return bitmap;
+ }
+
/*static */ Bitmap* Bitmap::clone(const Bitmap* bitmap)
{
Bitmap* b = new Bitmap();
@@ -78,7 +92,7 @@ namespace JinEngine
height = h;
pixels = new Color[w*h];
if (pixels == nullptr)
- throw Exception("Not enough memory.");
+ throw Exception("No enough memory.");
}
Bitmap::~Bitmap()
@@ -110,8 +124,8 @@ namespace JinEngine
void Bitmap::setPixel(const Color& c, int x, int y)
{
- if (pixels == nullptr)
- return;
+ if (pixels == nullptr)
+ throw Exception("Bitmap don't have pixel space.");
if (without<int>(x, 0, width - 1) || without<int>(y, 0, height - 1))
return;
if (x + y * width >= width * height)
diff --git a/src/libjin/Graphics/je_bitmap.h b/src/libjin/Graphics/je_bitmap.h
index c3041f8..5ab11ca 100644
--- a/src/libjin/Graphics/je_bitmap.h
+++ b/src/libjin/Graphics/je_bitmap.h
@@ -67,7 +67,7 @@ namespace JinEngine
///
/// Create bitmap and set bitmap pixels with given drawer.
///
- static Bitmap* createBitmap(int width, int height, std::function<Color(int, int)> drawer);
+ static Bitmap* createBitmap(int width, int height, std::function<Color(int, int, int, int)> drawer);
///
/// Create bitmap with another one.
diff --git a/src/libjin/Graphics/je_sprite.h b/src/libjin/Graphics/je_sprite.h
index d48fbbc..65e00eb 100644
--- a/src/libjin/Graphics/je_sprite.h
+++ b/src/libjin/Graphics/je_sprite.h
@@ -55,6 +55,8 @@ namespace JinEngine
const Math::Vector2<int>& getOrigin() { return mOrigin; }
const Math::Vector2<float>& getScale() { return mScale; }
const Color& getColor() { return mColor; }
+ const Graphic* getGraphic() { return mGraphic; }
+ const Shaders::Shader* getShader() { return mShader; }
///
/// Render callback.
diff --git a/src/lua/common/je_lua_function.cpp b/src/lua/common/je_lua_function.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/lua/common/je_lua_function.cpp
diff --git a/src/lua/common/je_lua_function.h b/src/lua/common/je_lua_function.h
new file mode 100644
index 0000000..49c1b31
--- /dev/null
+++ b/src/lua/common/je_lua_function.h
@@ -0,0 +1,6 @@
+#ifndef __JE_LUA_FUNCTION_H__
+#define __JE_LUA_FUNCTION_H__
+
+
+
+#endif \ No newline at end of file
diff --git a/src/lua/common/je_lua_proxy.h b/src/lua/common/je_lua_proxy.h
index 9f55490..ca4a56a 100644
--- a/src/lua/common/je_lua_proxy.h
+++ b/src/lua/common/je_lua_proxy.h
@@ -18,6 +18,7 @@ namespace JinEngine
if (s == nullptr)
return;
shared = s;
+ shared->retain();
}
void release()
@@ -28,13 +29,13 @@ namespace JinEngine
shared = nullptr;
}
}
-
+/*
void retain()
{
if (shared != nullptr)
shared->retain();
}
-
+*/
template<class T>
Shared<T>& getShared()
{
diff --git a/src/lua/common/je_lua_shared.hpp b/src/lua/common/je_lua_shared.hpp
index 9cd7073..91705d1 100644
--- a/src/lua/common/je_lua_shared.hpp
+++ b/src/lua/common/je_lua_shared.hpp
@@ -85,12 +85,17 @@ namespace JinEngine
return mDependencies.find(key)->second;
}
+ bool isType(const char* t)
+ {
+ return strcmp(type, t) == 0;
+ }
+
protected:
using DepMap = std::map<int, SharedBase*>;
SharedBase(void* obj, const char* t)
- : mCount(1)
+ : mCount(0)
, mObject(obj)
, type(t)
{
diff --git a/src/lua/libraries/luax/luax.h b/src/lua/libraries/luax/luax.h
index 450805b..311bc95 100644
--- a/src/lua/libraries/luax/luax.h
+++ b/src/lua/libraries/luax/luax.h
@@ -89,6 +89,12 @@ inline bool luax_checkbool(lua_State *L, int numArg)
*/
/* get value and leaves it on top of stack */
#define luax_rawgetnumber(L, i, k) (lua_rawgeti(L,i, k), lua_tonumber(L, -1))
+inline float luax_rawgetnumberthenpop(lua_State* L, int i, int k)
+{
+ float n = luax_rawgetnumber(L, i, k);
+ luax_pop(L, 1);
+ return n;
+}
#define luax_rawgeti lua_rawgeti
@@ -277,6 +283,7 @@ inline int luax_istype(lua_State* L, int idx, const char* tname)
#define luax_istable(L, i) luax_is(table, L, i)
#define luax_isnil(L, i) luax_is(nil, L, i)
#define luax_isboolean(L, i) luax_is(boolean, L, i)
+#define luax_isfunction(L, i) luax_is(function, L, i)
#define luax_isuserdata lua_isuserdata
#define luax_islightuserdata lua_islightuserdata
inline int luax_isinteger(lua_State* L, int i)
diff --git a/src/lua/luax.h b/src/lua/luax.h
index 1c2081c..89e456e 100644
--- a/src/lua/luax.h
+++ b/src/lua/luax.h
@@ -4,8 +4,4 @@
#include "LuaJIT/lua.hpp"
#include "lua/libraries/luax/luax.h"
-#define luax_newclass(l, f) \
-extern int f(lua_State*);\
-f(l)
-
#endif \ No newline at end of file
diff --git a/src/lua/modules/audio/je_lua_audio.cpp b/src/lua/modules/audio/je_lua_audio.cpp
index 6851018..50c5268 100644
--- a/src/lua/modules/audio/je_lua_audio.cpp
+++ b/src/lua/modules/audio/je_lua_audio.cpp
@@ -112,7 +112,7 @@ namespace JinEngine
LUA_EXPORT int luaopen_audio(lua_State* L)
{
- luax_newclass(L, luaopen_Source);
+ luaopen_Source(L);
luaL_Reg f[] = {
{ "init", l_init },
diff --git a/src/lua/modules/audio/je_lua_source.cpp b/src/lua/modules/audio/je_lua_source.cpp
index 8978c22..e152847 100644
--- a/src/lua/modules/audio/je_lua_source.cpp
+++ b/src/lua/modules/audio/je_lua_source.cpp
@@ -94,7 +94,7 @@ namespace JinEngine
return 0;
}
- LUA_EXPORT int luaopen_Source(lua_State* L)
+ LUA_EXPORT void luaopen_Source(lua_State* L)
{
luaL_Reg f[] = {
{ "__gc", l_gc },
@@ -111,7 +111,6 @@ namespace JinEngine
};
luax_newtype(L, Jin_Lua_Source, f);
- return 0;
}
} // namespace Lua
diff --git a/src/lua/modules/audio/je_lua_source.h b/src/lua/modules/audio/je_lua_source.h
index 076a691..f7e6b48 100644
--- a/src/lua/modules/audio/je_lua_source.h
+++ b/src/lua/modules/audio/je_lua_source.h
@@ -8,6 +8,8 @@ namespace JinEngine
extern const char* Jin_Lua_Source;
+ void luaopen_Source(lua_State* L);
+
}
}
diff --git a/src/lua/modules/graphics/je_lua_bitmap.cpp b/src/lua/modules/graphics/je_lua_bitmap.cpp
index 4b7c492..6b7655f 100644
--- a/src/lua/modules/graphics/je_lua_bitmap.cpp
+++ b/src/lua/modules/graphics/je_lua_bitmap.cpp
@@ -95,7 +95,7 @@ namespace JinEngine
return 1;
}
- LUA_EXPORT int luaopen_Bitmap(lua_State* L)
+ LUA_EXPORT void luaopen_Bitmap(lua_State* L)
{
luaL_Reg f[] = {
{ "__gc", l_gc },
@@ -108,7 +108,6 @@ namespace JinEngine
{ 0, 0 }
};
luax_newtype(L, Jin_Lua_Bitmap, f);
- return 0;
}
} // namespace Graphics
diff --git a/src/lua/modules/graphics/je_lua_bitmap.h b/src/lua/modules/graphics/je_lua_bitmap.h
index 047766e..b463d83 100644
--- a/src/lua/modules/graphics/je_lua_bitmap.h
+++ b/src/lua/modules/graphics/je_lua_bitmap.h
@@ -8,6 +8,8 @@ namespace JinEngine
extern const char* Jin_Lua_Bitmap;
+ void luaopen_Bitmap(lua_State* L);
+
}
}
diff --git a/src/lua/modules/graphics/je_lua_canvas.cpp b/src/lua/modules/graphics/je_lua_canvas.cpp
index be6bb84..f7bd650 100644
--- a/src/lua/modules/graphics/je_lua_canvas.cpp
+++ b/src/lua/modules/graphics/je_lua_canvas.cpp
@@ -50,7 +50,7 @@ namespace JinEngine
return 0;
}
- LUA_EXPORT int luaopen_Canvas(lua_State* L)
+ LUA_EXPORT void luaopen_Canvas(lua_State* L)
{
luaL_Reg f[] = {
{ "__gc", l_gc },
@@ -60,8 +60,6 @@ namespace JinEngine
{ 0, 0 }
};
luax_newtype(L, Jin_Lua_Canvas, f);
-
- return 0;
}
} // namespace Lua
diff --git a/src/lua/modules/graphics/je_lua_canvas.h b/src/lua/modules/graphics/je_lua_canvas.h
index c7b8504..d1fa885 100644
--- a/src/lua/modules/graphics/je_lua_canvas.h
+++ b/src/lua/modules/graphics/je_lua_canvas.h
@@ -8,6 +8,8 @@ namespace JinEngine
extern const char* Jin_Lua_Canvas;
+ void luaopen_Canvas(lua_State* L);
+
}
}
diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp
index c535216..0a5394d 100644
--- a/src/lua/modules/graphics/je_lua_graphics.cpp
+++ b/src/lua/modules/graphics/je_lua_graphics.cpp
@@ -140,16 +140,43 @@ namespace JinEngine
{
int w = luax_checkinteger(L, 1);
int h = luax_checkinteger(L, 2);
- if (!luax_istable(L, 3))
+ if (luax_istable(L, 3))
{
- luax_typerror(L, 3, "table");
+ unsigned int r = luax_rawgetnumber(L, 3, 1);
+ unsigned int g = luax_rawgetnumber(L, 3, 2);
+ unsigned int b = luax_rawgetnumber(L, 3, 3);
+ unsigned int a = luax_rawgetnumber(L, 3, 4);
+ bitmap = Bitmap::createBitmap(w, h, Color(r, g, b, a));
+ }
+ else if (luax_isfunction(L, 3))
+ {
+ std::function<Color(int, int, int, int)> drawer = [=](int w, int h, int x, int y)->Color{
+ luax_pushvalue(L, 3);
+ luax_pushnumber(L, w);
+ luax_pushnumber(L, h);
+ luax_pushnumber(L, x);
+ luax_pushnumber(L, y);
+ // Call drawer function.
+ luax_call(L, 4, 1);
+ // Get result color.
+ if (!luax_istable(L, -1))
+ luax_error(L, "Return value of bitmap drawer is wrong, should be a color table.");
+ Color c;
+ c.r = luax_rawgetnumberthenpop(L, -1, 1);
+ c.g = luax_rawgetnumberthenpop(L, -1, 2);
+ c.b = luax_rawgetnumberthenpop(L, -1, 3);
+ c.a = luax_rawgetnumberthenpop(L, -1, 4);
+ // Pop return value.
+ luax_pop(L, 1);
+ return c;
+ };
+ bitmap = Bitmap::createBitmap(w, h, drawer);
+ }
+ else
+ {
+ luax_typerror(L, 3, "color table or color setter");
return 1;
}
- unsigned int r = luax_rawgetnumber(L, 3, 1);
- unsigned int g = luax_rawgetnumber(L, 3, 2);
- unsigned int b = luax_rawgetnumber(L, 3, 3);
- unsigned int a = luax_rawgetnumber(L, 3, 4);
- bitmap = Bitmap::createBitmap(w, h, Color(r, g, b, a));
}
else
{
@@ -777,17 +804,17 @@ namespace JinEngine
LUA_EXPORT int luaopen_graphics(lua_State* L)
{
- luax_newclass(L, luaopen_Bitmap);
- luax_newclass(L, luaopen_Texture);
- luax_newclass(L, luaopen_Canvas);
- luax_newclass(L, luaopen_TTFData);
- luax_newclass(L, luaopen_TTF);
- luax_newclass(L, luaopen_Text);
- luax_newclass(L, luaopen_TextureFont);
- luax_newclass(L, luaopen_Page);
- luax_newclass(L, luaopen_JSL);
- luax_newclass(L, luaopen_Sprite);
- luax_newclass(L, luaopen_SpriteSheet);
+ luaopen_Bitmap(L);
+ luaopen_Texture(L);
+ luaopen_Canvas(L);
+ luaopen_TTFData(L);
+ luaopen_TTF(L);
+ luaopen_Text(L);
+ luaopen_TextureFont(L);
+ luaopen_Page(L);
+ luaopen_Shader(L);
+ luaopen_Sprite(L);
+ luaopen_SpriteSheet(L);
luaL_Reg f[] = {
/* window */
diff --git a/src/lua/modules/graphics/je_lua_page.cpp b/src/lua/modules/graphics/je_lua_page.cpp
index 526c2ec..20ec398 100644
--- a/src/lua/modules/graphics/je_lua_page.cpp
+++ b/src/lua/modules/graphics/je_lua_page.cpp
@@ -53,7 +53,7 @@ namespace JinEngine
return 1;
}
- LUA_EXPORT int luaopen_Page(lua_State* L)
+ LUA_EXPORT void luaopen_Page(lua_State* L)
{
luaL_Reg f[] = {
{ "__gc", l_gc },
@@ -63,7 +63,6 @@ namespace JinEngine
{ 0, 0 }
};
luax_newtype(L, Jin_Lua_Page, f);
- return 0;
}
} // namespace Lua
diff --git a/src/lua/modules/graphics/je_lua_page.h b/src/lua/modules/graphics/je_lua_page.h
index 6ebf718..e4a21a3 100644
--- a/src/lua/modules/graphics/je_lua_page.h
+++ b/src/lua/modules/graphics/je_lua_page.h
@@ -14,6 +14,8 @@ namespace JinEngine
extern const char* Jin_Lua_Page;
+ void luaopen_Page(lua_State* L);
+
}
}
diff --git a/src/lua/modules/graphics/je_lua_shader.cpp b/src/lua/modules/graphics/je_lua_shader.cpp
index 61c8eef..1612a69 100644
--- a/src/lua/modules/graphics/je_lua_shader.cpp
+++ b/src/lua/modules/graphics/je_lua_shader.cpp
@@ -117,7 +117,7 @@ namespace JinEngine
return 0;
}
- LUA_EXPORT int luaopen_JSL(lua_State* L)
+ LUA_EXPORT void luaopen_Shader(lua_State* L)
{
luaL_Reg f[] = {
{ "__gc", l_gc },
@@ -131,7 +131,6 @@ namespace JinEngine
{ 0, 0 }
};
luax_newtype(L, Jin_Lua_Shader, f);
- return 0;
}
} // namespace Lua
diff --git a/src/lua/modules/graphics/je_lua_shader.h b/src/lua/modules/graphics/je_lua_shader.h
index 57ad570..5a84372 100644
--- a/src/lua/modules/graphics/je_lua_shader.h
+++ b/src/lua/modules/graphics/je_lua_shader.h
@@ -8,6 +8,8 @@ namespace JinEngine
extern const char* Jin_Lua_Shader;
+ void luaopen_Shader(lua_State* L);
+
}
}
diff --git a/src/lua/modules/graphics/je_lua_sprite.cpp b/src/lua/modules/graphics/je_lua_sprite.cpp
index ec5887c..97128a9 100644
--- a/src/lua/modules/graphics/je_lua_sprite.cpp
+++ b/src/lua/modules/graphics/je_lua_sprite.cpp
@@ -197,7 +197,41 @@ namespace JinEngine
return 0;
}
- LUA_EXPORT int luaopen_Sprite(lua_State* L)
+ LUA_IMPLEMENT int l_getGraphic(lua_State* L)
+ {
+ Proxy* pxySprite = (Proxy*)luax_checktype(L, 1, Jin_Lua_Sprite);
+ Shared<Sprite>& shrSprite = pxySprite->getShared<Sprite>();
+ SharedBase* shrGraphic = shrSprite.getDependency((int)SpriteDependency::DEP_GRAPHIC);
+ if (shrGraphic->isType(Jin_Lua_Canvas))
+ {
+ Proxy* pxyCanvas = luax_newinstance(L, Jin_Lua_Canvas);
+ pxyCanvas->bind(shrGraphic);
+ return 1;
+ }
+ else if (shrGraphic->isType(Jin_Lua_Texture))
+ {
+ Proxy* pxyTexture = luax_newinstance(L, Jin_Lua_Texture);
+ pxyTexture->bind(shrGraphic);
+ return 1;
+ }
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_getShader(lua_State* L)
+ {
+ Proxy* pxySprite = (Proxy*)luax_checktype(L, 1, Jin_Lua_Sprite);
+ Shared<Sprite>& shrSprite = pxySprite->getShared<Sprite>();
+ SharedBase* shrShader = shrSprite.getDependency((int)SpriteDependency::DEP_SHADER);
+ if (shrShader != nullptr && shrShader->isType(Jin_Lua_Shader))
+ {
+ Proxy* pxyShader = luax_newinstance(L, Jin_Lua_Shader);
+ pxyShader->bind(shrShader);
+ return 1;
+ }
+ return 0;
+ }
+
+ LUA_EXPORT void luaopen_Sprite(lua_State* L)
{
luaL_Reg methods[] = {
{ "__gc", l_gc },
@@ -217,10 +251,11 @@ namespace JinEngine
{ "getOrigin", l_getOrigin },
{ "getScale", l_getScale },
{ "getColor", l_getColor },
+ { "getShader", l_getShader },
+ { "getGraphic", l_getGraphic },
{ 0, 0 }
};
luax_newtype(L, Jin_Lua_Sprite, methods);
- return 0;
}
} // namespace Lua
diff --git a/src/lua/modules/graphics/je_lua_sprite.h b/src/lua/modules/graphics/je_lua_sprite.h
index cbadc34..02c44bf 100644
--- a/src/lua/modules/graphics/je_lua_sprite.h
+++ b/src/lua/modules/graphics/je_lua_sprite.h
@@ -16,6 +16,8 @@ namespace JinEngine
extern const char* Jin_Lua_Sprite;
+ void luaopen_Sprite(lua_State* L);
+
}
}
diff --git a/src/lua/modules/graphics/je_lua_spritesheet.cpp b/src/lua/modules/graphics/je_lua_spritesheet.cpp
index ef1bd85..15469e9 100644
--- a/src/lua/modules/graphics/je_lua_spritesheet.cpp
+++ b/src/lua/modules/graphics/je_lua_spritesheet.cpp
@@ -40,7 +40,7 @@ namespace JinEngine
return 1;
}
- LUA_EXPORT int luaopen_SpriteSheet(lua_State* L)
+ LUA_EXPORT void luaopen_SpriteSheet(lua_State* L)
{
luaL_Reg methods[] = {
{ "__gc", l_gc },
@@ -48,7 +48,6 @@ namespace JinEngine
{ 0, 0 }
};
luax_newtype(L, Jin_Lua_SpriteSheet, methods);
- return 0;
}
}
diff --git a/src/lua/modules/graphics/je_lua_spritesheet.h b/src/lua/modules/graphics/je_lua_spritesheet.h
index ec94de8..bcae60b 100644
--- a/src/lua/modules/graphics/je_lua_spritesheet.h
+++ b/src/lua/modules/graphics/je_lua_spritesheet.h
@@ -13,6 +13,8 @@ namespace JinEngine
extern const char* Jin_Lua_SpriteSheet;
+ void luaopen_SpriteSheet(lua_State* L);
+
}
}
diff --git a/src/lua/modules/graphics/je_lua_text.cpp b/src/lua/modules/graphics/je_lua_text.cpp
index 5e12ff8..9377a0a 100644
--- a/src/lua/modules/graphics/je_lua_text.cpp
+++ b/src/lua/modules/graphics/je_lua_text.cpp
@@ -19,14 +19,13 @@ namespace JinEngine
return 0;
}
- LUA_EXPORT int luaopen_Text(lua_State* L)
+ LUA_EXPORT void luaopen_Text(lua_State* L)
{
luaL_Reg f[] = {
{ "__gc", l_gc },
{ 0, 0 }
};
luax_newtype(L, Jin_Lua_Text, f);
- return 0;
}
} // namespace Lua
diff --git a/src/lua/modules/graphics/je_lua_text.h b/src/lua/modules/graphics/je_lua_text.h
index bae5913..dfcc9cc 100644
--- a/src/lua/modules/graphics/je_lua_text.h
+++ b/src/lua/modules/graphics/je_lua_text.h
@@ -8,6 +8,8 @@ namespace JinEngine
extern const char* Jin_Lua_Text;
+ void luaopen_Text(lua_State* L);
+
}
}
diff --git a/src/lua/modules/graphics/je_lua_texture.cpp b/src/lua/modules/graphics/je_lua_texture.cpp
index 08a98eb..79ddc63 100644
--- a/src/lua/modules/graphics/je_lua_texture.cpp
+++ b/src/lua/modules/graphics/je_lua_texture.cpp
@@ -2,6 +2,7 @@
#include "lua/common/je_lua_common.h"
#include "libjin/jin.h"
+#include "je_lua_texture.h"
using namespace JinEngine::Graphics;
@@ -49,7 +50,7 @@ namespace JinEngine
return 0;
}
- LUA_EXPORT int luaopen_Texture(lua_State* L)
+ LUA_EXPORT void luaopen_Texture(lua_State* L)
{
luaL_Reg f[] = {
{ "__gc", l_gc },
@@ -59,7 +60,6 @@ namespace JinEngine
{ 0, 0 }
};
luax_newtype(L, Jin_Lua_Texture, f);
- return 0;
}
}// namespace Lua
diff --git a/src/lua/modules/graphics/je_lua_texture.h b/src/lua/modules/graphics/je_lua_texture.h
index 48f22ab..c8bb71c 100644
--- a/src/lua/modules/graphics/je_lua_texture.h
+++ b/src/lua/modules/graphics/je_lua_texture.h
@@ -8,6 +8,8 @@ namespace JinEngine
extern const char* Jin_Lua_Texture;
+ void luaopen_Texture(lua_State* L);
+
}
}
diff --git a/src/lua/modules/graphics/je_lua_texture_font.cpp b/src/lua/modules/graphics/je_lua_texture_font.cpp
index 0c3c4d9..8ca3ce5 100644
--- a/src/lua/modules/graphics/je_lua_texture_font.cpp
+++ b/src/lua/modules/graphics/je_lua_texture_font.cpp
@@ -52,7 +52,7 @@ namespace JinEngine
return 1;
}
- LUA_EXPORT int luaopen_TextureFont(lua_State* L)
+ LUA_EXPORT void luaopen_TextureFont(lua_State* L)
{
luaL_Reg f[] = {
{ "__gc", l_gc },
@@ -60,8 +60,6 @@ namespace JinEngine
{ 0, 0 }
};
luax_newtype(L, Jin_Lua_TextureFont, f);
-
- return 0;
}
} // namespace Lua
diff --git a/src/lua/modules/graphics/je_lua_texture_font.h b/src/lua/modules/graphics/je_lua_texture_font.h
index 1339221..d1fffe5 100644
--- a/src/lua/modules/graphics/je_lua_texture_font.h
+++ b/src/lua/modules/graphics/je_lua_texture_font.h
@@ -8,6 +8,8 @@ namespace JinEngine
extern const char* Jin_Lua_TextureFont;
+ void luaopen_TextureFont(lua_State* L);
+
}
}
diff --git a/src/lua/modules/graphics/je_lua_ttf.cpp b/src/lua/modules/graphics/je_lua_ttf.cpp
index 1f5be50..c5d922b 100644
--- a/src/lua/modules/graphics/je_lua_ttf.cpp
+++ b/src/lua/modules/graphics/je_lua_ttf.cpp
@@ -52,7 +52,7 @@ namespace JinEngine
return 1;
}
- LUA_EXPORT int luaopen_TTF(lua_State* L)
+ LUA_EXPORT void luaopen_TTF(lua_State* L)
{
luaL_Reg f[] = {
{ "__gc", l_gc },
@@ -60,8 +60,6 @@ namespace JinEngine
{ 0, 0 }
};
luax_newtype(L, Jin_Lua_TTF, f);
-
- return 0;
}
} // namespace Lua
diff --git a/src/lua/modules/graphics/je_lua_ttf.h b/src/lua/modules/graphics/je_lua_ttf.h
index 01f99e6..bfe503d 100644
--- a/src/lua/modules/graphics/je_lua_ttf.h
+++ b/src/lua/modules/graphics/je_lua_ttf.h
@@ -8,6 +8,8 @@ namespace JinEngine
extern const char* Jin_Lua_TTF;
+ void luaopen_TTF(lua_State* L);
+
}
}
diff --git a/src/lua/modules/graphics/je_lua_ttf_data.cpp b/src/lua/modules/graphics/je_lua_ttf_data.cpp
index fb43ae4..1277318 100644
--- a/src/lua/modules/graphics/je_lua_ttf_data.cpp
+++ b/src/lua/modules/graphics/je_lua_ttf_data.cpp
@@ -37,7 +37,7 @@ namespace JinEngine
return 0;
}
- LUA_EXPORT int luaopen_TTFData(lua_State* L)
+ LUA_EXPORT void luaopen_TTFData(lua_State* L)
{
luaL_Reg f[] = {
{ "__gc", l_gc },
@@ -46,7 +46,6 @@ namespace JinEngine
};
luax_newtype(L, Jin_Lua_TTFData, f);
- return 0;
}
} // namespace Lua
diff --git a/src/lua/modules/graphics/je_lua_ttf_data.h b/src/lua/modules/graphics/je_lua_ttf_data.h
index f858f1a..1fd832d 100644
--- a/src/lua/modules/graphics/je_lua_ttf_data.h
+++ b/src/lua/modules/graphics/je_lua_ttf_data.h
@@ -13,6 +13,8 @@ namespace JinEngine
extern const char* Jin_Lua_TTFData;
+ void luaopen_TTFData(lua_State* L);
+
}
}
diff --git a/src/lua/modules/net/je_lua_buffer.cpp b/src/lua/modules/net/je_lua_buffer.cpp
index 2565d60..0198095 100644
--- a/src/lua/modules/net/je_lua_buffer.cpp
+++ b/src/lua/modules/net/je_lua_buffer.cpp
@@ -118,7 +118,7 @@ namespace JinEngine
return 0;
}
- LUA_EXPORT int luaopen_Buffer(lua_State* L)
+ LUA_EXPORT void luaopen_Buffer(lua_State* L)
{
luaL_Reg netbuffer_function[] = {
{ "__gc", l_gc },
@@ -131,7 +131,6 @@ namespace JinEngine
};
luax_newtype(L, Jin_Lua_Buffer, netbuffer_function);
- return 0;
}
} // namespace Lua
diff --git a/src/lua/modules/net/je_lua_buffer.h b/src/lua/modules/net/je_lua_buffer.h
index d24a4e2..d226640 100644
--- a/src/lua/modules/net/je_lua_buffer.h
+++ b/src/lua/modules/net/je_lua_buffer.h
@@ -12,6 +12,8 @@ namespace JinEngine
extern const char* Jin_Lua_Buffer;
+ void luaopen_Buffer(lua_State* L);
+
namespace Net
{
diff --git a/src/lua/modules/net/je_lua_net.cpp b/src/lua/modules/net/je_lua_net.cpp
index 795eb18..b081733 100644
--- a/src/lua/modules/net/je_lua_net.cpp
+++ b/src/lua/modules/net/je_lua_net.cpp
@@ -66,8 +66,8 @@ namespace Lua
LUA_EXPORT int luaopen_net(lua_State* L)
{
- luax_newclass(L, luaopen_Socket);
- luax_newclass(L, luaopen_Buffer);
+ luaopen_Socket(L);
+ luaopen_Buffer(L);
luaL_Reg f[] = {
{ "init", l_initNetwork },
diff --git a/src/lua/modules/net/je_lua_socket.cpp b/src/lua/modules/net/je_lua_socket.cpp
index 309f92e..db170e4 100644
--- a/src/lua/modules/net/je_lua_socket.cpp
+++ b/src/lua/modules/net/je_lua_socket.cpp
@@ -109,7 +109,7 @@ namespace JinEngine
return 0;
}
- LUA_EXPORT int luaopen_Socket(lua_State* L)
+ LUA_EXPORT void luaopen_Socket(lua_State* L)
{
luaL_Reg socket_function[] = {
{ "__gc", l_gc },
@@ -123,7 +123,6 @@ namespace JinEngine
{ 0, 0 }
};
luax_newtype(L, Jin_Lua_Socket, socket_function);
- return 0;
}
} // namespace Lua
diff --git a/src/lua/modules/net/je_lua_socket.h b/src/lua/modules/net/je_lua_socket.h
index 83c08fb..b33fac6 100644
--- a/src/lua/modules/net/je_lua_socket.h
+++ b/src/lua/modules/net/je_lua_socket.h
@@ -8,6 +8,8 @@ namespace JinEngine
extern const char* Jin_Lua_Socket;
+ void luaopen_Socket(lua_State* L);
+
}
}
diff --git a/src/lua/modules/thread/je_lua_thread.cpp b/src/lua/modules/thread/je_lua_thread.cpp
index 19b3374..d7b50ab 100644
--- a/src/lua/modules/thread/je_lua_thread.cpp
+++ b/src/lua/modules/thread/je_lua_thread.cpp
@@ -30,7 +30,6 @@ namespace JinEngine
luaopen_jin(L);
luax_getglobal(L, MODULE_NAME);
Proxy* proxy = luax_newinstance(L, Jin_Lua_Thread);
- shared.retain();
proxy->bind(&shared);
luax_setfield(L, -2, "_curThread");
luax_dostring(L, shared->code.c_str());
@@ -128,7 +127,6 @@ namespace JinEngine
case Thread::Variant::POINTER:
Proxy* p = (Proxy*)v.pointer;
Proxy* proxy = luax_newinstance(L, p->getObjectType());
- p->retain();
proxy->bind(p->shared);
break;
@@ -163,7 +161,6 @@ namespace JinEngine
Proxy* p = (Proxy*)v.pointer;
const char* objType = p->getObjectType();
Proxy* proxy = luax_newinstance(L, objType);
- p->retain();
proxy->bind(p->shared);
break;
diff --git a/src/lua/modules/time/je_lua_time.cpp b/src/lua/modules/time/je_lua_time.cpp
index b0e82de..39ec899 100644
--- a/src/lua/modules/time/je_lua_time.cpp
+++ b/src/lua/modules/time/je_lua_time.cpp
@@ -54,7 +54,7 @@ namespace JinEngine
LUA_EXPORT int luaopen_time(lua_State* L)
{
- luax_newclass(L, luaopen_Timer);
+ luaopen_Timer(L);
luaL_Reg f[] = {
{ "second", l_sec },
{ "sleep", l_sleep },
diff --git a/src/lua/modules/time/je_lua_timer.cpp b/src/lua/modules/time/je_lua_timer.cpp
index 67f92e2..9104a42 100644
--- a/src/lua/modules/time/je_lua_timer.cpp
+++ b/src/lua/modules/time/je_lua_timer.cpp
@@ -120,7 +120,7 @@ namespace JinEngine
return 0;
}
- LUA_EXPORT int luaopen_Timer(lua_State* L)
+ LUA_EXPORT void luaopen_Timer(lua_State* L)
{
luaL_Reg f[] = {
{ "__gc", l_gc },
@@ -134,8 +134,6 @@ namespace JinEngine
};
luax_newtype(L, Jin_Lua_Timer, f);
-
- return 0;
}
}
diff --git a/src/lua/modules/time/je_lua_timer.h b/src/lua/modules/time/je_lua_timer.h
index 18081e7..35ec15d 100644
--- a/src/lua/modules/time/je_lua_timer.h
+++ b/src/lua/modules/time/je_lua_timer.h
@@ -12,6 +12,8 @@ namespace JinEngine
extern const char* Jin_Lua_Handler;
+ void luaopen_Timer(lua_State* L);
+
}
}