aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libjin/common/je_subsystem.hpp2
-rw-r--r--src/lua/modules/audio/je_lua_audio.cpp3
-rw-r--r--src/lua/modules/graphics/je_lua_graphics.cpp2
-rw-r--r--src/lua/modules/net/je_lua_net.cpp118
4 files changed, 63 insertions, 62 deletions
diff --git a/src/libjin/common/je_subsystem.hpp b/src/libjin/common/je_subsystem.hpp
index 0119b74..384d986 100644
--- a/src/libjin/common/je_subsystem.hpp
+++ b/src/libjin/common/je_subsystem.hpp
@@ -30,7 +30,7 @@ namespace JinEngine
/// @param setting Subsystem setting.
/// @return True if initialize sucessful, otherwise return false.
///
- bool init(const SettingBase* setting = nullptr)
+ bool start(const SettingBase* setting = nullptr)
{
static bool success = startSystem(setting);
return success;
diff --git a/src/lua/modules/audio/je_lua_audio.cpp b/src/lua/modules/audio/je_lua_audio.cpp
index 47ed078..6257c93 100644
--- a/src/lua/modules/audio/je_lua_audio.cpp
+++ b/src/lua/modules/audio/je_lua_audio.cpp
@@ -31,7 +31,8 @@ namespace JinEngine
Audio::Setting setting;
setting.samplerate = 44100;
setting.samples = 44100;
- context.initialized = Audio::get()->init(&setting);
+ Audio* audio = Audio::get();
+ context.initialized = audio->start(&setting);
if (!context.initialized)
{
luax_error(L, "could not init audio");
diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp
index 05231c2..8ace62c 100644
--- a/src/lua/modules/graphics/je_lua_graphics.cpp
+++ b/src/lua/modules/graphics/je_lua_graphics.cpp
@@ -61,7 +61,7 @@ namespace JinEngine
setting.vsync = luax_getfieldbool(L, 1, "vsync");
setting.fullscreen = luax_getfieldbool(L, 1, "fullscreen");
setting.resizable = luax_getfieldbool(L, 1, "resizable");
- context.initialized = wnd->init(&setting);
+ context.initialized = wnd->start(&setting);
if (!context.initialized)
{
luax_pushboolean(L, context.initialized);
diff --git a/src/lua/modules/net/je_lua_net.cpp b/src/lua/modules/net/je_lua_net.cpp
index 76ea0fe..e631827 100644
--- a/src/lua/modules/net/je_lua_net.cpp
+++ b/src/lua/modules/net/je_lua_net.cpp
@@ -7,75 +7,75 @@
namespace JinEngine
{
-namespace Lua
-{
+ namespace Lua
+ {
- using namespace JinEngine::Lua::Net;
- using namespace JinEngine::Net;
+ using namespace JinEngine::Lua::Net;
+ using namespace JinEngine::Net;
- LUA_IMPLEMENT int l_initNetwork(lua_State* L)
- {
- JinEngine::Net::NetManager::get()->init();
- return 1;
- }
+ LUA_IMPLEMENT int l_initNetwork(lua_State* L)
+ {
+ JinEngine::Net::NetManager::get()->start();
+ return 1;
+ }
- LUA_IMPLEMENT int l_Socket(lua_State* L)
- {
- SocketInformation info = { 0 };
+ LUA_IMPLEMENT int l_Socket(lua_State* L)
{
- const char* socketType = luax_checkstring(L, 1);
- if (strcmp(socketType, "TCP") == 0)
- info.type = SocketType::TCP;
- else if (strcmp(socketType, "UDP") == 0)
- info.type = SocketType::UDP;
- else
- {
- luax_error(L, "jin.net.Socket() first paramter wrong, must be TCP or UDP");
- return 0;
- }
- // type, port
- if (luax_gettop(L) == 2)
+ SocketInformation info = { 0 };
{
- info.port = luax_checkinteger(L, 2);
- }
- // type, address, port
- else if (luax_gettop(L) == 3)
- {
- if (luax_isstringstrict(L, 2))
- info.address = tk_strtohl(luax_checkstring(L, 2));
- else if (luax_isintegerstrict(L, 2))
- info.address = luax_checkinteger(L, 2);
- info.port = luax_checkinteger(L, 3);
+ const char* socketType = luax_checkstring(L, 1);
+ if (strcmp(socketType, "TCP") == 0)
+ info.type = SocketType::TCP;
+ else if (strcmp(socketType, "UDP") == 0)
+ info.type = SocketType::UDP;
+ else
+ {
+ luax_error(L, "jin.net.Socket() first paramter wrong, must be TCP or UDP");
+ return 0;
+ }
+ // type, port
+ if (luax_gettop(L) == 2)
+ {
+ info.port = luax_checkinteger(L, 2);
+ }
+ // type, address, port
+ else if (luax_gettop(L) == 3)
+ {
+ if (luax_isstringstrict(L, 2))
+ info.address = tk_strtohl(luax_checkstring(L, 2));
+ else if (luax_isintegerstrict(L, 2))
+ info.address = luax_checkinteger(L, 2);
+ info.port = luax_checkinteger(L, 3);
+ }
}
+ Socket* socket = new Socket(info);
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Socket, new Shared<Socket>(socket, Jin_Lua_Socket));
+ return 1;
}
- Socket* socket = new Socket(info);
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Socket, new Shared<Socket>(socket, Jin_Lua_Socket));
- return 1;
- }
- LUA_IMPLEMENT int l_Buffer(lua_State* L)
- {
- int size = luax_checkinteger(L, 1);
- Net::Buffer* buffer = new Net::Buffer(size);
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared<Buffer>(buffer, Jin_Lua_Buffer));
- return 1;
- }
+ LUA_IMPLEMENT int l_Buffer(lua_State* L)
+ {
+ int size = luax_checkinteger(L, 1);
+ Net::Buffer* buffer = new Net::Buffer(size);
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared<Buffer>(buffer, Jin_Lua_Buffer));
+ return 1;
+ }
- LUA_EXPORT int luaopen_net(lua_State* L)
- {
- luaopen_Socket(L);
- luaopen_Buffer(L);
+ LUA_EXPORT int luaopen_net(lua_State* L)
+ {
+ luaopen_Socket(L);
+ luaopen_Buffer(L);
- luaL_Reg methods[] = {
- { "init", l_initNetwork },
- { "newSocket", l_Socket },
- { "newBuffer", l_Buffer },
- { 0, 0 }
- };
- luax_newlib(L, methods);
+ luaL_Reg methods[] = {
+ { "init", l_initNetwork },
+ { "newSocket", l_Socket },
+ { "newBuffer", l_Buffer },
+ { 0, 0 }
+ };
+ luax_newlib(L, methods);
- return 1;
- }
+ return 1;
+ }
-} // namespace Lua
+ } // namespace Lua
} // namespace JinEngine \ No newline at end of file