aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lua/audio/luaopen_Source.cpp46
-rw-r--r--src/lua/audio/luaopen_audio.cpp19
-rw-r--r--src/lua/bit/luaopen_bit.cpp15
-rw-r--r--src/lua/core/luaopen_core.cpp8
-rw-r--r--src/lua/event/luaopen_event.cpp4
-rw-r--r--src/lua/filesystem/luaopen_filesystem.cpp10
-rw-r--r--src/lua/graphics/luaopen_Canvas.cpp24
-rw-r--r--src/lua/graphics/luaopen_Font.cpp6
-rw-r--r--src/lua/graphics/luaopen_Image.cpp14
-rw-r--r--src/lua/graphics/luaopen_JSL.cpp6
-rw-r--r--src/lua/graphics/luaopen_graphics.cpp63
-rw-r--r--src/lua/luaopen_jin.cpp34
-rw-r--r--src/lua/math/luaopen_math.cpp2
-rw-r--r--src/lua/mouse/luaopen_mouse.cpp4
-rw-r--r--src/lua/net/luaopen_Buffer.cpp10
-rw-r--r--src/lua/net/luaopen_Socket.cpp16
-rw-r--r--src/lua/net/luaopen_net.cpp8
-rw-r--r--src/lua/thread/luaopen_Thread.cpp20
-rw-r--r--src/lua/thread/luaopen_thread.cpp20
-rw-r--r--src/lua/time/luaopen_time.cpp10
20 files changed, 163 insertions, 176 deletions
diff --git a/src/lua/audio/luaopen_Source.cpp b/src/lua/audio/luaopen_Source.cpp
index 3e4408a..658adcb 100644
--- a/src/lua/audio/luaopen_Source.cpp
+++ b/src/lua/audio/luaopen_Source.cpp
@@ -9,7 +9,9 @@ namespace lua
using namespace jin::audio;
- static inline Ref<Source>& checkSource(lua_State* L)
+ typedef Ref<Source>& SourceRef;
+
+ static inline SourceRef checkSource(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_AUDIO_SOURCE);
return proxy->getRef<Source>();
@@ -17,42 +19,42 @@ namespace lua
static int l_play(lua_State* L)
{
- Ref<Source>& ref = checkSource(L);
+ SourceRef ref = checkSource(L);
ref->play();
return 0;
}
static int l_stop(lua_State* L)
{
- Ref<Source>& ref = checkSource(L);
+ SourceRef ref = checkSource(L);
ref->stop();
return 0;
}
static int l_pause(lua_State* L)
{
- Ref<Source>& ref = checkSource(L);
+ SourceRef ref = checkSource(L);
ref->pause();
return 0;
}
static int l_rewind(lua_State* L)
{
- Ref<Source>& ref = checkSource(L);
+ SourceRef ref = checkSource(L);
ref->rewind();
return 0;
}
static int l_resume(lua_State* L)
{
- Ref<Source>& ref = checkSource(L);
+ SourceRef ref = checkSource(L);
ref->resume();
return 0;
}
static int l_isStop(lua_State* L)
{
- Ref<Source>& ref = checkSource(L);
+ SourceRef ref = checkSource(L);
bool isStop = ref->isStopped();
luax_pushboolean(L, isStop);
return 1;
@@ -60,7 +62,7 @@ namespace lua
static int l_isPaused(lua_State* L)
{
- Ref<Source>& ref = checkSource(L);
+ SourceRef ref = checkSource(L);
bool isPaused = ref->isPaused();
luax_pushboolean(L, isPaused);
return 1;
@@ -68,7 +70,7 @@ namespace lua
static int l_setVolume(lua_State* L)
{
- Ref<Source>& ref = checkSource(L);
+ SourceRef ref = checkSource(L);
float volume = luax_checknumber(L, 2);
ref->setVolume(volume);
return 0;
@@ -76,7 +78,7 @@ namespace lua
static int l_setLoop(lua_State* L)
{
- Ref<Source>& ref = checkSource(L);
+ SourceRef ref = checkSource(L);
bool loop = luax_checkbool(L, 2);
ref->setLoop(loop);
return 0;
@@ -90,17 +92,17 @@ namespace lua
}
static const luaL_Reg f[] = {
- { "__gc", l_gc },
- { "play", l_play },
- { "stop", l_stop },
- { "pause", l_pause },
- { "resume", l_resume },
- { "rewind", l_rewind },
- { "isStop", l_isStop },
- { "isPaused", l_isPaused },
+ { "__gc", l_gc },
+ { "play", l_play },
+ { "stop", l_stop },
+ { "pause", l_pause },
+ { "resume", l_resume },
+ { "rewind", l_rewind },
+ { "isStop", l_isStop },
+ { "isPaused", l_isPaused },
{ "setVolume", l_setVolume },
- { "setLoop", l_setLoop },
- {0, 0}
+ { "setLoop", l_setLoop },
+ {0, 0 }
};
int luaopen_Source(lua_State* L)
@@ -109,5 +111,5 @@ namespace lua
return 0;
}
-}
-} \ No newline at end of file
+} // lua
+} // jin \ No newline at end of file
diff --git a/src/lua/audio/luaopen_audio.cpp b/src/lua/audio/luaopen_audio.cpp
index 40bfb04..731e4d9 100644
--- a/src/lua/audio/luaopen_audio.cpp
+++ b/src/lua/audio/luaopen_audio.cpp
@@ -84,16 +84,15 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"init", l_init},
- {"play", l_play },
- {"stop", l_stop},
- {"pause", l_pause},
- {"resume", l_resume},
- {"setVolume",l_setVolume},
- {"Source", l_newSource},
- //
- {"destroy",l_destroy},
- {0, 0}
+ { "init", l_init },
+ { "play", l_play },
+ { "stop", l_stop },
+ { "pause", l_pause },
+ { "resume", l_resume },
+ { "setVolume",l_setVolume },
+ { "Source", l_newSource },
+ { "destroy", l_destroy },
+ { 0, 0 }
};
extern int luaopen_Source(lua_State* L);
diff --git a/src/lua/bit/luaopen_bit.cpp b/src/lua/bit/luaopen_bit.cpp
index 9520909..3b086bb 100644
--- a/src/lua/bit/luaopen_bit.cpp
+++ b/src/lua/bit/luaopen_bit.cpp
@@ -63,15 +63,14 @@ namespace lua
}
static const luaL_Reg f[] = {
- { "bAnd", l_and },
- { "bOr" , l_or },
- { "bXor", l_xor },
- { "bNot", l_not },
- { "bLs", l_lshift },
- { "bRs", l_rshift },
+ { "bAnd", l_and },
+ { "bOr" , l_or },
+ { "bXor", l_xor },
+ { "bNot", l_not },
+ { "bLs", l_lshift },
+ { "bRs", l_rshift },
{ "bInc", l_include },
-
- { 0, 0 }
+ { 0, 0 }
};
int luaopen_bit(lua_State* L)
diff --git a/src/lua/core/luaopen_core.cpp b/src/lua/core/luaopen_core.cpp
index d20a3bc..3b234b6 100644
--- a/src/lua/core/luaopen_core.cpp
+++ b/src/lua/core/luaopen_core.cpp
@@ -28,10 +28,10 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"running", l_running},
- {"stop", l_stop}, // for end game loop
- {"quit", l_quit}, // for exit whole game
- {0, 0}
+ {"running", l_running },
+ {"stop", l_stop },
+ {"quit", l_quit },
+ {0, 0 }
};
int luaopen_core(lua_State* L)
diff --git a/src/lua/event/luaopen_event.cpp b/src/lua/event/luaopen_event.cpp
index 522a650..fd113c6 100644
--- a/src/lua/event/luaopen_event.cpp
+++ b/src/lua/event/luaopen_event.cpp
@@ -89,8 +89,8 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"poll", l_event_poll},
- {0 ,0 }
+ { "poll", l_event_poll },
+ { 0, 0 }
};
/**
diff --git a/src/lua/filesystem/luaopen_filesystem.cpp b/src/lua/filesystem/luaopen_filesystem.cpp
index f4138fc..f764a68 100644
--- a/src/lua/filesystem/luaopen_filesystem.cpp
+++ b/src/lua/filesystem/luaopen_filesystem.cpp
@@ -119,11 +119,11 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"init", l_init},
- {"mount", l_mount},
- {"isdir", l_isDir},
- {"exist", l_exist},
- {0, 0}
+ { "init", l_init },
+ { "mount", l_mount },
+ { "isdir", l_isDir },
+ { "exist", l_exist },
+ { 0, 0 }
};
int luaopen_filesystem(lua_State* L)
diff --git a/src/lua/graphics/luaopen_Canvas.cpp b/src/lua/graphics/luaopen_Canvas.cpp
index 302d139..0009ff4 100644
--- a/src/lua/graphics/luaopen_Canvas.cpp
+++ b/src/lua/graphics/luaopen_Canvas.cpp
@@ -9,7 +9,9 @@ namespace lua
using namespace jin::graphics;
- static inline Ref<Canvas>& checkCanvas(lua_State* L)
+ typedef Ref<Canvas>& CanvasRef;
+
+ static inline CanvasRef checkCanvas(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_CANVAS);
return proxy->getRef<Canvas>();
@@ -17,21 +19,21 @@ namespace lua
static int l_getWidth(lua_State* L)
{
- Ref<Canvas>& ref = checkCanvas(L);
+ CanvasRef ref = checkCanvas(L);
luax_pushnumber(L, ref->getWidth());
return 1;
}
static int l_getHeight(lua_State* L)
{
- Ref<Canvas>& ref = checkCanvas(L);
+ CanvasRef ref = checkCanvas(L);
luax_pushnumber(L, ref->getHeight());
return 1;
}
static int l_getSize(lua_State* L)
{
- Ref<Canvas>& ref = checkCanvas(L);
+ CanvasRef ref = checkCanvas(L);
luax_pushnumber(L, ref->getWidth());
luax_pushnumber(L, ref->getHeight());
return 2;
@@ -39,7 +41,7 @@ namespace lua
static int l_setAnchor(lua_State* L)
{
- Ref<Canvas>& ref = checkCanvas(L);
+ CanvasRef ref = checkCanvas(L);
int x = luax_checknumber(L, 1);
int y = luax_checknumber(L, 2);
ref->setAnchor(x, y);
@@ -54,12 +56,12 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"__gc", l_gc},
- {"getWidth", l_getWidth},
- {"getHeight", l_getHeight},
- {"getSize", l_getSize},
- {"setAnchor", l_setAnchor},
- {0, 0 }
+ { "__gc", l_gc },
+ { "getWidth", l_getWidth },
+ { "getHeight", l_getHeight },
+ { "getSize", l_getSize },
+ { "setAnchor", l_setAnchor },
+ { 0, 0 }
};
int luaopen_Canvas(lua_State* L)
diff --git a/src/lua/graphics/luaopen_Font.cpp b/src/lua/graphics/luaopen_Font.cpp
index 6686d03..5e13806 100644
--- a/src/lua/graphics/luaopen_Font.cpp
+++ b/src/lua/graphics/luaopen_Font.cpp
@@ -32,9 +32,9 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"__gc", l_gc},
- {"box", l_box},
- {0, 0}
+ { "__gc", l_gc },
+ { "box", l_box },
+ { 0, 0 }
};
int luaopen_Font(lua_State* L)
diff --git a/src/lua/graphics/luaopen_Image.cpp b/src/lua/graphics/luaopen_Image.cpp
index 4ed92cf..df9b411 100644
--- a/src/lua/graphics/luaopen_Image.cpp
+++ b/src/lua/graphics/luaopen_Image.cpp
@@ -69,13 +69,13 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"__gc", l_gc},
- {"getWidth", l_getWidth},
- {"getHeight", l_getHeight},
- {"getSize", l_getSize},
- {"getPixel", l_getPixel},
- {"setAnchor", l_setAnchor},
- {0, 0 }
+ { "__gc", l_gc },
+ { "getWidth", l_getWidth },
+ { "getHeight", l_getHeight },
+ { "getSize", l_getSize },
+ { "getPixel", l_getPixel },
+ { "setAnchor", l_setAnchor },
+ { 0, 0 }
};
int luaopen_Image(lua_State* L)
diff --git a/src/lua/graphics/luaopen_JSL.cpp b/src/lua/graphics/luaopen_JSL.cpp
index cd77a03..1c46f84 100644
--- a/src/lua/graphics/luaopen_JSL.cpp
+++ b/src/lua/graphics/luaopen_JSL.cpp
@@ -127,9 +127,9 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"__gc", l_gc },
- {"send", l_send},
- {0, 0}
+ { "__gc", l_gc },
+ { "send", l_send },
+ { 0, 0 }
};
/**
diff --git a/src/lua/graphics/luaopen_graphics.cpp b/src/lua/graphics/luaopen_graphics.cpp
index 4a5ccce..b86b523 100644
--- a/src/lua/graphics/luaopen_graphics.cpp
+++ b/src/lua/graphics/luaopen_graphics.cpp
@@ -473,43 +473,32 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"init", l_init},
- {"size", l_getSize},
- {"Image", l_newImage},
- {"Shader", l_newShader},
- {"Canvas", l_newCanvas},
- {"Font", l_newFont},
- /**
- * before using box and write
- * must call study to set
- * current font
- */
- {"box", l_box},
- {"write", l_write},
- {"clear", l_clear},
- {"draw", l_draw},
- {"color", l_setColor},
- {"palette", l_getColor},
- {"present", l_present},
- //{"blend", l_setBlend},
- // study font
- {"study", l_study},
- // bind canvas
- {"bind", l_bindCanvas},
- {"unbind", l_unbindCanvas},
- // use shader
- {"use", l_useShader},
- {"unuse", l_unuseShader},
- // draw shapes
- {"point", l_drawpoint},
- {"line", l_drawLine},
- {"rect", l_drawRect},
- {"circle", l_drawCircle},
- {"triangle", l_drawTriangle},
- {"polygon", l_drawPolygon},
- // quit window
- {"destroy", l_destroy},
- {0, 0}
+ { "init", l_init },
+ { "size", l_getSize },
+ { "Image", l_newImage },
+ { "Shader", l_newShader },
+ { "Canvas", l_newCanvas },
+ { "Font", l_newFont },
+ { "box", l_box },
+ { "write", l_write },
+ { "clear", l_clear },
+ { "draw", l_draw },
+ { "color", l_setColor },
+ { "palette", l_getColor },
+ { "present", l_present },
+ { "study", l_study },
+ { "bind", l_bindCanvas },
+ { "unbind", l_unbindCanvas },
+ { "use", l_useShader },
+ { "unuse", l_unuseShader },
+ { "point", l_drawpoint },
+ { "line", l_drawLine },
+ { "rect", l_drawRect },
+ { "circle", l_drawCircle },
+ { "triangle", l_drawTriangle },
+ { "polygon", l_drawPolygon },
+ { "destroy", l_destroy },
+ { 0, 0 }
};
extern int luaopen_Image(lua_State* L);
diff --git a/src/lua/luaopen_jin.cpp b/src/lua/luaopen_jin.cpp
index 4697ec2..a271a77 100644
--- a/src/lua/luaopen_jin.cpp
+++ b/src/lua/luaopen_jin.cpp
@@ -61,20 +61,20 @@ namespace lua
// submodules
static const luaL_Reg mods[] = {
- { "core", luaopen_core },
- { "event", luaopen_event },
- { "graphics", luaopen_graphics },
- { "time", luaopen_time },
- { "mouse", luaopen_mouse },
- { "keyboard", luaopen_keyboard },
+ { "core", luaopen_core },
+ { "event", luaopen_event },
+ { "graphics", luaopen_graphics },
+ { "time", luaopen_time },
+ { "mouse", luaopen_mouse },
+ { "keyboard", luaopen_keyboard },
{ "filesystem", luaopen_filesystem },
- { "net", luaopen_net },
- { "audio", luaopen_audio },
- { "joypad", luaopen_joypad },
- { "math", luaopen_math },
- { "thread", luaopen_thread },
- { "bit", luaopen_bit },
- { 0, 0 }
+ { "net", luaopen_net },
+ { "audio", luaopen_audio },
+ { "joypad", luaopen_joypad },
+ { "math", luaopen_math },
+ { "thread", luaopen_thread },
+ { "bit", luaopen_bit },
+ { 0, 0 }
};
int luaopen_jin(lua_State* L)
@@ -88,7 +88,6 @@ namespace lua
// register submodules
for (int i = 0; mods[i].name; ++i)
{
- // open submodules
mods[i].func(L);
luax_setfield(L, -2, mods[i].name);
}
@@ -96,13 +95,10 @@ namespace lua
return 1;
}
- /**
- * boot jin
- */
void boot(lua_State* L)
{
jin::embed::boot(L);
}
-}
-} \ No newline at end of file
+} // lua
+} // jin \ No newline at end of file
diff --git a/src/lua/math/luaopen_math.cpp b/src/lua/math/luaopen_math.cpp
index 462e8d1..0a82271 100644
--- a/src/lua/math/luaopen_math.cpp
+++ b/src/lua/math/luaopen_math.cpp
@@ -17,7 +17,7 @@ namespace lua
static const luaL_Reg f[] = {
{ "mod", l_mod },
- { 0, 0 }
+ { 0, 0 }
};
int luaopen_math(lua_State* L)
diff --git a/src/lua/mouse/luaopen_mouse.cpp b/src/lua/mouse/luaopen_mouse.cpp
index eb6a779..d3488f3 100644
--- a/src/lua/mouse/luaopen_mouse.cpp
+++ b/src/lua/mouse/luaopen_mouse.cpp
@@ -18,8 +18,8 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"position", l_pos},
- {0, 0}
+ { "position", l_pos },
+ { 0, 0 }
};
int luaopen_mouse(lua_State* L)
diff --git a/src/lua/net/luaopen_Buffer.cpp b/src/lua/net/luaopen_Buffer.cpp
index 9708357..1018dcc 100644
--- a/src/lua/net/luaopen_Buffer.cpp
+++ b/src/lua/net/luaopen_Buffer.cpp
@@ -114,13 +114,13 @@ namespace net
}
static const luaL_Reg netbuffer_function[] = {
- { "__gc", l_gc },
- { "append", l_append },
- { "grabString", l_grabString },
+ { "__gc", l_gc },
+ { "append", l_append },
+ { "grabString", l_grabString },
{ "grabInteger", l_grabInteger },
{ "grabBoolean", l_grabBoolean },
- { "grabFloat", l_grabFloat },
- { 0, 0 }
+ { "grabFloat", l_grabFloat },
+ { 0, 0 }
};
} // net
diff --git a/src/lua/net/luaopen_Socket.cpp b/src/lua/net/luaopen_Socket.cpp
index 0ee5f4c..6a6f1e1 100644
--- a/src/lua/net/luaopen_Socket.cpp
+++ b/src/lua/net/luaopen_Socket.cpp
@@ -105,15 +105,15 @@ namespace lua
}
static const luaL_Reg socket_function[] = {
- { "__gc", l_gc },
- { "accept", l_accept },
- { "receive", l_receive },
- { "receiveFrom", l_receiveFrom },
- { "send", l_send },
- { "sendTo", l_sendTo },
- { "close", l_close },
+ { "__gc", l_gc },
+ { "accept", l_accept },
+ { "receive", l_receive },
+ { "receiveFrom", l_receiveFrom },
+ { "send", l_send },
+ { "sendTo", l_sendTo },
+ { "close", l_close },
{ "configBlocking", l_configBlocking },
- { 0, 0 }
+ { 0, 0 }
};
int luaopen_Socket(lua_State* L)
diff --git a/src/lua/net/luaopen_net.cpp b/src/lua/net/luaopen_net.cpp
index a3f7900..5457c07 100644
--- a/src/lua/net/luaopen_net.cpp
+++ b/src/lua/net/luaopen_net.cpp
@@ -63,10 +63,10 @@ namespace lua
}
static const luaL_Reg f[] = {
- { "init", l_initNetwork },
- { "Socket", l_Socket },
- { "Buffer", l_Buffer },
- { 0, 0 }
+ { "init", l_initNetwork },
+ { "Socket", l_Socket },
+ { "Buffer", l_Buffer },
+ { 0, 0 }
};
extern int luaopen_Socket(lua_State* L);
diff --git a/src/lua/thread/luaopen_Thread.cpp b/src/lua/thread/luaopen_Thread.cpp
index 5d44c30..3277704 100644
--- a/src/lua/thread/luaopen_Thread.cpp
+++ b/src/lua/thread/luaopen_Thread.cpp
@@ -192,17 +192,17 @@ namespace lua
}
static const luaL_Reg thread_function[] = {
- { "__gc", l_thread_gc },
- { "start", l_start },
- { "wait", l_wait },
- { "send", l_send },
- { "receive", l_receive },
- { "fetch", l_fetch },
- { "demand", l_demand },
- { "remove", l_remove },
- { "getName", l_getName },
+ { "__gc", l_thread_gc },
+ { "start", l_start },
+ { "wait", l_wait },
+ { "send", l_send },
+ { "receive", l_receive },
+ { "fetch", l_fetch },
+ { "demand", l_demand },
+ { "remove", l_remove },
+ { "getName", l_getName },
{ "isRunning", l_isRunning },
- { 0, 0 }
+ { 0, 0 }
};
static int luaopen_Thread(lua_State* L)
diff --git a/src/lua/thread/luaopen_thread.cpp b/src/lua/thread/luaopen_thread.cpp
index 5d44c30..3277704 100644
--- a/src/lua/thread/luaopen_thread.cpp
+++ b/src/lua/thread/luaopen_thread.cpp
@@ -192,17 +192,17 @@ namespace lua
}
static const luaL_Reg thread_function[] = {
- { "__gc", l_thread_gc },
- { "start", l_start },
- { "wait", l_wait },
- { "send", l_send },
- { "receive", l_receive },
- { "fetch", l_fetch },
- { "demand", l_demand },
- { "remove", l_remove },
- { "getName", l_getName },
+ { "__gc", l_thread_gc },
+ { "start", l_start },
+ { "wait", l_wait },
+ { "send", l_send },
+ { "receive", l_receive },
+ { "fetch", l_fetch },
+ { "demand", l_demand },
+ { "remove", l_remove },
+ { "getName", l_getName },
{ "isRunning", l_isRunning },
- { 0, 0 }
+ { 0, 0 }
};
static int luaopen_Thread(lua_State* L)
diff --git a/src/lua/time/luaopen_time.cpp b/src/lua/time/luaopen_time.cpp
index 4ef5372..d77b713 100644
--- a/src/lua/time/luaopen_time.cpp
+++ b/src/lua/time/luaopen_time.cpp
@@ -23,9 +23,9 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"second", l_sec},
- {"sleep", l_sleep},
- {0, 0},
+ { "second", l_sec },
+ { "sleep", l_sleep },
+ { 0, 0 },
};
int luaopen_time(lua_State* L)
@@ -34,5 +34,5 @@ namespace lua
return 1;
}
-}
-} \ No newline at end of file
+} // lua
+} // jin \ No newline at end of file