aboutsummaryrefslogtreecommitdiff
path: root/src/lua/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/modules')
-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
35 files changed, 131 insertions, 59 deletions
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);
+
}
}