From 98c9825c49a1674f59eafb3253829ca7d5cac3c1 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 14 Jan 2019 16:40:14 +0800 Subject: *rename source file --- src/3rdparty/LuaJIT-2.0.5/src/buildvm.lib | Bin 33996 -> 33996 bytes src/3rdparty/LuaJIT-2.0.5/src/minilua.lib | Bin 33996 -> 33996 bytes src/jin/main.cpp | 2 +- src/libjin-lua/common/je_lua.h | 6 +- src/libjin-lua/common/je_lua_callback.cpp | 43 - src/libjin-lua/common/je_lua_callback.h | 66 - src/libjin-lua/common/je_lua_common.h | 8 - src/libjin-lua/common/je_lua_constant.h | 14 - src/libjin-lua/common/je_lua_function.cpp | 0 src/libjin-lua/common/je_lua_function.h | 6 - src/libjin-lua/common/je_lua_object.cpp | 112 -- src/libjin-lua/common/je_lua_object.h | 69 - src/libjin-lua/common/je_lua_port.h | 8 - src/libjin-lua/common/je_lua_reference.cpp | 42 - src/libjin-lua/common/je_lua_reference.h | 54 - src/libjin-lua/common/je_lua_runtime.cpp | 215 --- src/libjin-lua/common/je_lua_shared.cpp | 11 - src/libjin-lua/common/je_lua_shared.hpp | 84 - src/libjin-lua/common/l_callback.cpp | 43 + src/libjin-lua/common/l_callback.h | 66 + src/libjin-lua/common/l_common.h | 8 + src/libjin-lua/common/l_constant.h | 14 + src/libjin-lua/common/l_function.cpp | 0 src/libjin-lua/common/l_function.h | 6 + src/libjin-lua/common/l_object.cpp | 112 ++ src/libjin-lua/common/l_object.h | 69 + src/libjin-lua/common/l_port.h | 8 + src/libjin-lua/common/l_reference.cpp | 42 + src/libjin-lua/common/l_reference.h | 54 + src/libjin-lua/common/l_runtime.cpp | 215 +++ src/libjin-lua/common/l_shared.cpp | 11 + src/libjin-lua/common/l_shared.hpp | 84 + src/libjin-lua/je_lua_jin.cpp | 187 -- src/libjin-lua/je_lua_jin.h | 36 - src/libjin-lua/l_jin.cpp | 187 ++ src/libjin-lua/l_jin.h | 36 + src/libjin-lua/modules/ai/je_lua_ai.cpp | 13 - src/libjin-lua/modules/ai/je_lua_ai.h | 17 - src/libjin-lua/modules/ai/je_lua_behavior_tree.cpp | 11 - src/libjin-lua/modules/ai/je_lua_behavior_tree.h | 14 - src/libjin-lua/modules/ai/je_lua_state_machine.cpp | 25 - src/libjin-lua/modules/ai/je_lua_state_machine.h | 14 - src/libjin-lua/modules/ai/l_ai.cpp | 13 + src/libjin-lua/modules/ai/l_ai.h | 17 + src/libjin-lua/modules/ai/l_behavior_tree.cpp | 11 + src/libjin-lua/modules/ai/l_behavior_tree.h | 14 + src/libjin-lua/modules/ai/l_state_machine.cpp | 25 + src/libjin-lua/modules/ai/l_state_machine.h | 14 + src/libjin-lua/modules/audio/je_lua_audio.cpp | 132 -- src/libjin-lua/modules/audio/je_lua_audio.h | 16 - src/libjin-lua/modules/audio/je_lua_source.cpp | 114 -- src/libjin-lua/modules/audio/je_lua_source.h | 16 - src/libjin-lua/modules/audio/l_audio.cpp | 132 ++ src/libjin-lua/modules/audio/l_audio.h | 16 + src/libjin-lua/modules/audio/l_source.cpp | 114 ++ src/libjin-lua/modules/audio/l_source.h | 16 + src/libjin-lua/modules/bit/je_lua_bit.cpp | 86 - src/libjin-lua/modules/bit/je_lua_bit.h | 14 - src/libjin-lua/modules/bit/l_bit.cpp | 86 + src/libjin-lua/modules/bit/l_bit.h | 14 + src/libjin-lua/modules/core/je_lua_core.cpp | 46 - src/libjin-lua/modules/core/je_lua_core.h | 14 - src/libjin-lua/modules/core/l_core.cpp | 46 + src/libjin-lua/modules/core/l_core.h | 14 + src/libjin-lua/modules/event/je_lua_event.cpp | 130 -- src/libjin-lua/modules/event/je_lua_event.h | 14 - src/libjin-lua/modules/event/l_event.cpp | 130 ++ src/libjin-lua/modules/event/l_event.h | 14 + .../modules/filesystem/je_lua_filesystem.cpp | 140 -- .../modules/filesystem/je_lua_filesystem.h | 14 - src/libjin-lua/modules/filesystem/l_filesystem.cpp | 140 ++ src/libjin-lua/modules/filesystem/l_filesystem.h | 14 + .../modules/graphics/je_lua_animation.cpp | 122 -- src/libjin-lua/modules/graphics/je_lua_animation.h | 24 - .../modules/graphics/je_lua_animator.cpp | 163 -- src/libjin-lua/modules/graphics/je_lua_animator.h | 23 - src/libjin-lua/modules/graphics/je_lua_bitmap.cpp | 110 -- src/libjin-lua/modules/graphics/je_lua_bitmap.h | 16 - src/libjin-lua/modules/graphics/je_lua_canvas.cpp | 63 - src/libjin-lua/modules/graphics/je_lua_canvas.h | 16 - .../modules/graphics/je_lua_graphics.cpp | 1112 ----------- src/libjin-lua/modules/graphics/je_lua_graphics.h | 14 - src/libjin-lua/modules/graphics/je_lua_mesh.cpp | 87 - src/libjin-lua/modules/graphics/je_lua_mesh.h | 21 - src/libjin-lua/modules/graphics/je_lua_page.cpp | 66 - src/libjin-lua/modules/graphics/je_lua_page.h | 22 - .../modules/graphics/je_lua_particle_system.cpp | 422 ----- .../modules/graphics/je_lua_particle_system.h | 21 - src/libjin-lua/modules/graphics/je_lua_shader.cpp | 132 -- src/libjin-lua/modules/graphics/je_lua_shader.h | 16 - src/libjin-lua/modules/graphics/je_lua_sprite.cpp | 66 - src/libjin-lua/modules/graphics/je_lua_sprite.h | 24 - .../modules/graphics/je_lua_spritesheet.cpp | 118 -- .../modules/graphics/je_lua_spritesheet.h | 21 - src/libjin-lua/modules/graphics/je_lua_text.cpp | 31 - src/libjin-lua/modules/graphics/je_lua_text.h | 16 - src/libjin-lua/modules/graphics/je_lua_texture.cpp | 63 - src/libjin-lua/modules/graphics/je_lua_texture.h | 16 - .../modules/graphics/je_lua_texture_font.cpp | 63 - .../modules/graphics/je_lua_texture_font.h | 16 - src/libjin-lua/modules/graphics/je_lua_ttf.cpp | 63 - src/libjin-lua/modules/graphics/je_lua_ttf.h | 16 - .../modules/graphics/je_lua_ttf_data.cpp | 49 - src/libjin-lua/modules/graphics/je_lua_ttf_data.h | 21 - src/libjin-lua/modules/graphics/l_animation.cpp | 122 ++ src/libjin-lua/modules/graphics/l_animation.h | 24 + src/libjin-lua/modules/graphics/l_animator.cpp | 163 ++ src/libjin-lua/modules/graphics/l_animator.h | 23 + src/libjin-lua/modules/graphics/l_bitmap.cpp | 110 ++ src/libjin-lua/modules/graphics/l_bitmap.h | 16 + src/libjin-lua/modules/graphics/l_canvas.cpp | 63 + src/libjin-lua/modules/graphics/l_canvas.h | 16 + src/libjin-lua/modules/graphics/l_graphics.cpp | 1112 +++++++++++ src/libjin-lua/modules/graphics/l_graphics.h | 14 + src/libjin-lua/modules/graphics/l_mesh.cpp | 87 + src/libjin-lua/modules/graphics/l_mesh.h | 21 + src/libjin-lua/modules/graphics/l_page.cpp | 66 + src/libjin-lua/modules/graphics/l_page.h | 22 + .../modules/graphics/l_particle_system.cpp | 422 +++++ .../modules/graphics/l_particle_system.h | 21 + src/libjin-lua/modules/graphics/l_shader.cpp | 132 ++ src/libjin-lua/modules/graphics/l_shader.h | 16 + src/libjin-lua/modules/graphics/l_sprite.cpp | 66 + src/libjin-lua/modules/graphics/l_sprite.h | 24 + src/libjin-lua/modules/graphics/l_spritesheet.cpp | 118 ++ src/libjin-lua/modules/graphics/l_spritesheet.h | 21 + src/libjin-lua/modules/graphics/l_text.cpp | 31 + src/libjin-lua/modules/graphics/l_text.h | 16 + src/libjin-lua/modules/graphics/l_texture.cpp | 63 + src/libjin-lua/modules/graphics/l_texture.h | 16 + src/libjin-lua/modules/graphics/l_texture_font.cpp | 63 + src/libjin-lua/modules/graphics/l_texture_font.h | 16 + src/libjin-lua/modules/graphics/l_ttf.cpp | 63 + src/libjin-lua/modules/graphics/l_ttf.h | 16 + src/libjin-lua/modules/graphics/l_ttf_data.cpp | 49 + src/libjin-lua/modules/graphics/l_ttf_data.h | 21 + src/libjin-lua/modules/je_lua_modules.h | 19 - src/libjin-lua/modules/joypad/je_lua_joypad.cpp | 21 - src/libjin-lua/modules/joypad/je_lua_joypad.h | 14 - src/libjin-lua/modules/joypad/l_joypad.cpp | 21 + src/libjin-lua/modules/joypad/l_joypad.h | 14 + .../modules/keyboard/je_lua_keyboard.cpp | 17 - src/libjin-lua/modules/keyboard/je_lua_keyboard.h | 14 - src/libjin-lua/modules/keyboard/l_keyboard.cpp | 17 + src/libjin-lua/modules/keyboard/l_keyboard.h | 14 + src/libjin-lua/modules/l_modules.h | 19 + src/libjin-lua/modules/math/je_lua_math.cpp | 30 - src/libjin-lua/modules/math/je_lua_math.h | 14 - src/libjin-lua/modules/math/l_math.cpp | 30 + src/libjin-lua/modules/math/l_math.h | 14 + src/libjin-lua/modules/mouse/je_lua_mouse.cpp | 42 - src/libjin-lua/modules/mouse/je_lua_mouse.h | 14 - src/libjin-lua/modules/mouse/l_mouse.cpp | 42 + src/libjin-lua/modules/mouse/l_mouse.h | 14 + src/libjin-lua/modules/net/je_lua_buffer.cpp | 136 -- src/libjin-lua/modules/net/je_lua_buffer.h | 102 - src/libjin-lua/modules/net/je_lua_net.cpp | 79 - src/libjin-lua/modules/net/je_lua_net.h | 14 - src/libjin-lua/modules/net/je_lua_socket.cpp | 123 -- src/libjin-lua/modules/net/je_lua_socket.h | 16 - src/libjin-lua/modules/net/l_buffer.cpp | 136 ++ src/libjin-lua/modules/net/l_buffer.h | 102 + src/libjin-lua/modules/net/l_net.cpp | 79 + src/libjin-lua/modules/net/l_net.h | 14 + src/libjin-lua/modules/net/l_socket.cpp | 123 ++ src/libjin-lua/modules/net/l_socket.h | 16 + src/libjin-lua/modules/thread/je_lua_thread.cpp | 240 --- src/libjin-lua/modules/thread/je_lua_thread.h | 95 - src/libjin-lua/modules/thread/l_thread.cpp | 240 +++ src/libjin-lua/modules/thread/l_thread.h | 95 + src/libjin-lua/modules/time/je_lua_time.cpp | 65 - src/libjin-lua/modules/time/je_lua_time.h | 14 - src/libjin-lua/modules/time/je_lua_timer.cpp | 132 -- src/libjin-lua/modules/time/je_lua_timer.h | 20 - src/libjin-lua/modules/time/l_time.cpp | 65 + src/libjin-lua/modules/time/l_time.h | 14 + src/libjin-lua/modules/time/l_timer.cpp | 132 ++ src/libjin-lua/modules/time/l_timer.h | 20 + src/libjin-lua/scripts/physics/physics.lua.h | 1997 ++++++++++---------- src/libjin/graphics/gl.cpp | 2 +- src/libjin/graphics/gl.h | 2 +- src/libjin/graphics/window.cpp | 2 +- 182 files changed, 7063 insertions(+), 7026 deletions(-) delete mode 100644 src/libjin-lua/common/je_lua_callback.cpp delete mode 100644 src/libjin-lua/common/je_lua_callback.h delete mode 100644 src/libjin-lua/common/je_lua_common.h delete mode 100644 src/libjin-lua/common/je_lua_constant.h delete mode 100644 src/libjin-lua/common/je_lua_function.cpp delete mode 100644 src/libjin-lua/common/je_lua_function.h delete mode 100644 src/libjin-lua/common/je_lua_object.cpp delete mode 100644 src/libjin-lua/common/je_lua_object.h delete mode 100644 src/libjin-lua/common/je_lua_port.h delete mode 100644 src/libjin-lua/common/je_lua_reference.cpp delete mode 100644 src/libjin-lua/common/je_lua_reference.h delete mode 100644 src/libjin-lua/common/je_lua_runtime.cpp delete mode 100644 src/libjin-lua/common/je_lua_shared.cpp delete mode 100644 src/libjin-lua/common/je_lua_shared.hpp create mode 100644 src/libjin-lua/common/l_callback.cpp create mode 100644 src/libjin-lua/common/l_callback.h create mode 100644 src/libjin-lua/common/l_common.h create mode 100644 src/libjin-lua/common/l_constant.h create mode 100644 src/libjin-lua/common/l_function.cpp create mode 100644 src/libjin-lua/common/l_function.h create mode 100644 src/libjin-lua/common/l_object.cpp create mode 100644 src/libjin-lua/common/l_object.h create mode 100644 src/libjin-lua/common/l_port.h create mode 100644 src/libjin-lua/common/l_reference.cpp create mode 100644 src/libjin-lua/common/l_reference.h create mode 100644 src/libjin-lua/common/l_runtime.cpp create mode 100644 src/libjin-lua/common/l_shared.cpp create mode 100644 src/libjin-lua/common/l_shared.hpp delete mode 100644 src/libjin-lua/je_lua_jin.cpp delete mode 100644 src/libjin-lua/je_lua_jin.h create mode 100644 src/libjin-lua/l_jin.cpp create mode 100644 src/libjin-lua/l_jin.h delete mode 100644 src/libjin-lua/modules/ai/je_lua_ai.cpp delete mode 100644 src/libjin-lua/modules/ai/je_lua_ai.h delete mode 100644 src/libjin-lua/modules/ai/je_lua_behavior_tree.cpp delete mode 100644 src/libjin-lua/modules/ai/je_lua_behavior_tree.h delete mode 100644 src/libjin-lua/modules/ai/je_lua_state_machine.cpp delete mode 100644 src/libjin-lua/modules/ai/je_lua_state_machine.h create mode 100644 src/libjin-lua/modules/ai/l_ai.cpp create mode 100644 src/libjin-lua/modules/ai/l_ai.h create mode 100644 src/libjin-lua/modules/ai/l_behavior_tree.cpp create mode 100644 src/libjin-lua/modules/ai/l_behavior_tree.h create mode 100644 src/libjin-lua/modules/ai/l_state_machine.cpp create mode 100644 src/libjin-lua/modules/ai/l_state_machine.h delete mode 100644 src/libjin-lua/modules/audio/je_lua_audio.cpp delete mode 100644 src/libjin-lua/modules/audio/je_lua_audio.h delete mode 100644 src/libjin-lua/modules/audio/je_lua_source.cpp delete mode 100644 src/libjin-lua/modules/audio/je_lua_source.h create mode 100644 src/libjin-lua/modules/audio/l_audio.cpp create mode 100644 src/libjin-lua/modules/audio/l_audio.h create mode 100644 src/libjin-lua/modules/audio/l_source.cpp create mode 100644 src/libjin-lua/modules/audio/l_source.h delete mode 100644 src/libjin-lua/modules/bit/je_lua_bit.cpp delete mode 100644 src/libjin-lua/modules/bit/je_lua_bit.h create mode 100644 src/libjin-lua/modules/bit/l_bit.cpp create mode 100644 src/libjin-lua/modules/bit/l_bit.h delete mode 100644 src/libjin-lua/modules/core/je_lua_core.cpp delete mode 100644 src/libjin-lua/modules/core/je_lua_core.h create mode 100644 src/libjin-lua/modules/core/l_core.cpp create mode 100644 src/libjin-lua/modules/core/l_core.h delete mode 100644 src/libjin-lua/modules/event/je_lua_event.cpp delete mode 100644 src/libjin-lua/modules/event/je_lua_event.h create mode 100644 src/libjin-lua/modules/event/l_event.cpp create mode 100644 src/libjin-lua/modules/event/l_event.h delete mode 100644 src/libjin-lua/modules/filesystem/je_lua_filesystem.cpp delete mode 100644 src/libjin-lua/modules/filesystem/je_lua_filesystem.h create mode 100644 src/libjin-lua/modules/filesystem/l_filesystem.cpp create mode 100644 src/libjin-lua/modules/filesystem/l_filesystem.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_animation.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_animation.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_animator.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_animator.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_bitmap.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_bitmap.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_canvas.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_canvas.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_graphics.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_graphics.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_mesh.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_mesh.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_page.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_page.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_particle_system.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_particle_system.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_shader.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_shader.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_sprite.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_sprite.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_spritesheet.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_spritesheet.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_text.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_text.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_texture.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_texture.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_texture_font.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_texture_font.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_ttf.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_ttf.h delete mode 100644 src/libjin-lua/modules/graphics/je_lua_ttf_data.cpp delete mode 100644 src/libjin-lua/modules/graphics/je_lua_ttf_data.h create mode 100644 src/libjin-lua/modules/graphics/l_animation.cpp create mode 100644 src/libjin-lua/modules/graphics/l_animation.h create mode 100644 src/libjin-lua/modules/graphics/l_animator.cpp create mode 100644 src/libjin-lua/modules/graphics/l_animator.h create mode 100644 src/libjin-lua/modules/graphics/l_bitmap.cpp create mode 100644 src/libjin-lua/modules/graphics/l_bitmap.h create mode 100644 src/libjin-lua/modules/graphics/l_canvas.cpp create mode 100644 src/libjin-lua/modules/graphics/l_canvas.h create mode 100644 src/libjin-lua/modules/graphics/l_graphics.cpp create mode 100644 src/libjin-lua/modules/graphics/l_graphics.h create mode 100644 src/libjin-lua/modules/graphics/l_mesh.cpp create mode 100644 src/libjin-lua/modules/graphics/l_mesh.h create mode 100644 src/libjin-lua/modules/graphics/l_page.cpp create mode 100644 src/libjin-lua/modules/graphics/l_page.h create mode 100644 src/libjin-lua/modules/graphics/l_particle_system.cpp create mode 100644 src/libjin-lua/modules/graphics/l_particle_system.h create mode 100644 src/libjin-lua/modules/graphics/l_shader.cpp create mode 100644 src/libjin-lua/modules/graphics/l_shader.h create mode 100644 src/libjin-lua/modules/graphics/l_sprite.cpp create mode 100644 src/libjin-lua/modules/graphics/l_sprite.h create mode 100644 src/libjin-lua/modules/graphics/l_spritesheet.cpp create mode 100644 src/libjin-lua/modules/graphics/l_spritesheet.h create mode 100644 src/libjin-lua/modules/graphics/l_text.cpp create mode 100644 src/libjin-lua/modules/graphics/l_text.h create mode 100644 src/libjin-lua/modules/graphics/l_texture.cpp create mode 100644 src/libjin-lua/modules/graphics/l_texture.h create mode 100644 src/libjin-lua/modules/graphics/l_texture_font.cpp create mode 100644 src/libjin-lua/modules/graphics/l_texture_font.h create mode 100644 src/libjin-lua/modules/graphics/l_ttf.cpp create mode 100644 src/libjin-lua/modules/graphics/l_ttf.h create mode 100644 src/libjin-lua/modules/graphics/l_ttf_data.cpp create mode 100644 src/libjin-lua/modules/graphics/l_ttf_data.h delete mode 100644 src/libjin-lua/modules/je_lua_modules.h delete mode 100644 src/libjin-lua/modules/joypad/je_lua_joypad.cpp delete mode 100644 src/libjin-lua/modules/joypad/je_lua_joypad.h create mode 100644 src/libjin-lua/modules/joypad/l_joypad.cpp create mode 100644 src/libjin-lua/modules/joypad/l_joypad.h delete mode 100644 src/libjin-lua/modules/keyboard/je_lua_keyboard.cpp delete mode 100644 src/libjin-lua/modules/keyboard/je_lua_keyboard.h create mode 100644 src/libjin-lua/modules/keyboard/l_keyboard.cpp create mode 100644 src/libjin-lua/modules/keyboard/l_keyboard.h create mode 100644 src/libjin-lua/modules/l_modules.h delete mode 100644 src/libjin-lua/modules/math/je_lua_math.cpp delete mode 100644 src/libjin-lua/modules/math/je_lua_math.h create mode 100644 src/libjin-lua/modules/math/l_math.cpp create mode 100644 src/libjin-lua/modules/math/l_math.h delete mode 100644 src/libjin-lua/modules/mouse/je_lua_mouse.cpp delete mode 100644 src/libjin-lua/modules/mouse/je_lua_mouse.h create mode 100644 src/libjin-lua/modules/mouse/l_mouse.cpp create mode 100644 src/libjin-lua/modules/mouse/l_mouse.h delete mode 100644 src/libjin-lua/modules/net/je_lua_buffer.cpp delete mode 100644 src/libjin-lua/modules/net/je_lua_buffer.h delete mode 100644 src/libjin-lua/modules/net/je_lua_net.cpp delete mode 100644 src/libjin-lua/modules/net/je_lua_net.h delete mode 100644 src/libjin-lua/modules/net/je_lua_socket.cpp delete mode 100644 src/libjin-lua/modules/net/je_lua_socket.h create mode 100644 src/libjin-lua/modules/net/l_buffer.cpp create mode 100644 src/libjin-lua/modules/net/l_buffer.h create mode 100644 src/libjin-lua/modules/net/l_net.cpp create mode 100644 src/libjin-lua/modules/net/l_net.h create mode 100644 src/libjin-lua/modules/net/l_socket.cpp create mode 100644 src/libjin-lua/modules/net/l_socket.h delete mode 100644 src/libjin-lua/modules/thread/je_lua_thread.cpp delete mode 100644 src/libjin-lua/modules/thread/je_lua_thread.h create mode 100644 src/libjin-lua/modules/thread/l_thread.cpp create mode 100644 src/libjin-lua/modules/thread/l_thread.h delete mode 100644 src/libjin-lua/modules/time/je_lua_time.cpp delete mode 100644 src/libjin-lua/modules/time/je_lua_time.h delete mode 100644 src/libjin-lua/modules/time/je_lua_timer.cpp delete mode 100644 src/libjin-lua/modules/time/je_lua_timer.h create mode 100644 src/libjin-lua/modules/time/l_time.cpp create mode 100644 src/libjin-lua/modules/time/l_time.h create mode 100644 src/libjin-lua/modules/time/l_timer.cpp create mode 100644 src/libjin-lua/modules/time/l_timer.h (limited to 'src') diff --git a/src/3rdparty/LuaJIT-2.0.5/src/buildvm.lib b/src/3rdparty/LuaJIT-2.0.5/src/buildvm.lib index d4372fd..c7be727 100644 Binary files a/src/3rdparty/LuaJIT-2.0.5/src/buildvm.lib and b/src/3rdparty/LuaJIT-2.0.5/src/buildvm.lib differ diff --git a/src/3rdparty/LuaJIT-2.0.5/src/minilua.lib b/src/3rdparty/LuaJIT-2.0.5/src/minilua.lib index a3cce18..e2b3ac3 100644 Binary files a/src/3rdparty/LuaJIT-2.0.5/src/minilua.lib and b/src/3rdparty/LuaJIT-2.0.5/src/minilua.lib differ diff --git a/src/jin/main.cpp b/src/jin/main.cpp index 13dcc20..6bcfaec 100644 --- a/src/jin/main.cpp +++ b/src/jin/main.cpp @@ -1,4 +1,4 @@ -#include "libjin-lua/je_lua_jin.h" +#include "libjin-lua/l_jin.h" #include "libjin/jin.h" #ifdef _WIN32 diff --git a/src/libjin-lua/common/je_lua.h b/src/libjin-lua/common/je_lua.h index 74f9819..629874c 100644 --- a/src/libjin-lua/common/je_lua.h +++ b/src/libjin-lua/common/je_lua.h @@ -6,9 +6,9 @@ #include "LuaJIT/lua.hpp" #include "luax/luax.h" -#include "je_lua_shared.hpp" -#include "je_lua_object.h" -#include "je_lua_reference.h" +#include "l_shared.hpp" +#include "l_object.h" +#include "l_reference.h" namespace JinEngine { diff --git a/src/libjin-lua/common/je_lua_callback.cpp b/src/libjin-lua/common/je_lua_callback.cpp deleted file mode 100644 index 392f919..0000000 --- a/src/libjin-lua/common/je_lua_callback.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "je_lua_callback.h" - -namespace JinEngine -{ - namespace Lua - { - - LuaCallback::LuaCallback(lua_State* L) - : mLuaFunc(nullptr) - , mParams(0) - , mL(L) - { - } - - LuaCallback::~LuaCallback() - { - delete mLuaFunc; - for (auto p : mParams) - delete p; - } - - void LuaCallback::setFunc(int i) - { - if (mLuaFunc != nullptr) - delete mLuaFunc; - mLuaFunc = new LuaRef(mL, i); - } - - void LuaCallback::pushParam(int i) - { - mParams.push_back(new LuaRef(mL, i)); - } - - void LuaCallback::call() - { - mLuaFunc->push(); - for (auto p : mParams) - p->push(); - luax_call(mL, mParams.size(), 0); - } - - } -} \ No newline at end of file diff --git a/src/libjin-lua/common/je_lua_callback.h b/src/libjin-lua/common/je_lua_callback.h deleted file mode 100644 index 0467e45..0000000 --- a/src/libjin-lua/common/je_lua_callback.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef __JIN_COMMON_FUNCTION_H -#define __JIN_COMMON_FUNCTION_H - -#include - -#include "libjin/jin.h" -#include "je_lua_reference.h" - -namespace JinEngine -{ - namespace Lua - { - - /// - /// - /// - class LuaCallback - { - public: - /// - /// - /// - LuaCallback(lua_State* L); - - /// - /// - /// - ~LuaCallback(); - - /// - /// - /// - void setFunc(int i); - - /// - /// - /// - void pushParam(int i); - - /// - /// - /// - void call(); - - private: - /// - /// - /// - LuaRef* mLuaFunc; - - /// - /// - /// - std::vector mParams; - - /// - /// - /// - lua_State* const mL; - - }; - - } // namespace Lua -} // namespace JinEngine - -#endif // __JIN_COMMON_REFERENCE_H \ No newline at end of file diff --git a/src/libjin-lua/common/je_lua_common.h b/src/libjin-lua/common/je_lua_common.h deleted file mode 100644 index dbda9a0..0000000 --- a/src/libjin-lua/common/je_lua_common.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __JIN_M_TYPES_H -#define __JIN_M_TYPES_H - -#include "je_lua.h" -#include "je_lua_port.h" -#include "je_lua_reference.h" - -#endif \ No newline at end of file diff --git a/src/libjin-lua/common/je_lua_constant.h b/src/libjin-lua/common/je_lua_constant.h deleted file mode 100644 index c173b88..0000000 --- a/src/libjin-lua/common/je_lua_constant.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __JE_LUA_CONSTANT_H__ -#define __JE_LUA_CONSTANT_H__ - -namespace JinEngine -{ - namespace Lua - { - - - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/common/je_lua_function.cpp b/src/libjin-lua/common/je_lua_function.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/libjin-lua/common/je_lua_function.h b/src/libjin-lua/common/je_lua_function.h deleted file mode 100644 index 49c1b31..0000000 --- a/src/libjin-lua/common/je_lua_function.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __JE_LUA_FUNCTION_H__ -#define __JE_LUA_FUNCTION_H__ - - - -#endif \ No newline at end of file diff --git a/src/libjin-lua/common/je_lua_object.cpp b/src/libjin-lua/common/je_lua_object.cpp deleted file mode 100644 index c35356e..0000000 --- a/src/libjin-lua/common/je_lua_object.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "je_lua_object.h" -#include "je_lua.h" - -namespace JinEngine -{ - namespace Lua - { - - void LuaObject::bind(Shared* obj) - { - if (obj) - { - shared = obj; - shared->retain(); - dependencies = new std::map(); - } - } - - void LuaObject::release() - { - // Delete lua shared table reference and references. - if (dependencies) - { - clearDependencies(); - delete dependencies; - dependencies = nullptr; - } - // Try delete engine side shared. - if (shared) - { - shared->release(); - shared = nullptr; - } - } - - const char* LuaObject::getObjectType() - { - return type; - } - - Shared* LuaObject::getShared() - { - return shared; - } - - void LuaObject::setDependency(uint key, LuaObject* dep) - { - removeDependency(key); - dependencies->insert(std::pair(key, dep)); - luax_addreference(state, this, dep); - } - - void LuaObject::removeDependency(uint key) - { - if (!isDependOn(key)) - return; - DepsMap::iterator it = dependencies->find(key); - LuaObject* dep = it->second; - luax_removereference(state, this, dep); - dependencies->erase(it); - } - - void LuaObject::removeDependency(LuaObject* dependency) - { - for (DepsMap::iterator it = dependencies->begin(); it != dependencies->end();) - { - LuaObject* dep = it->second; - if (dep == dependency) - { - luax_removereference(state, this, dep); - dependencies->erase(it); - } - else - ++it; - } - } - - bool LuaObject::isDependOn(uint key) - { - return dependencies->find(key) != dependencies->end(); - } - - bool LuaObject::isDependOn(LuaObject* shared) - { - for (std::pair dep : (*dependencies)) - { - if (dep.second == shared) - return true; - } - return false; - } - - void LuaObject::clearDependencies() - { - luax_removereference(state, this); - dependencies->clear(); - } - - LuaObject* LuaObject::getDependency(uint key) - { - if (!isDependOn(key)) - return nullptr; - return dependencies->find(key)->second; - } - - int LuaObject::getDependenciesCount() - { - return dependencies->size(); - } - - } -} \ No newline at end of file diff --git a/src/libjin-lua/common/je_lua_object.h b/src/libjin-lua/common/je_lua_object.h deleted file mode 100644 index 6e86508..0000000 --- a/src/libjin-lua/common/je_lua_object.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef __JIN_COMMON_OBJECT_H__ -#define __JIN_COMMON_OBJECT_H__ - -#include "libjin/jin.h" -#include "je_lua_shared.hpp" - -struct lua_State; - -namespace JinEngine -{ - namespace Lua - { - - class LuaObject - { - public: - /// - /// Set lua_State and object it bind. - /// - void bind(Shared* obj); - - void release(); - - const char* getObjectType(); - - Shared* getShared(); - - template - T* getObject() - { - return shared->getObject(); - } - - void setDependency(uint key, LuaObject* dep); - - void removeDependency(uint key); - - void removeDependency(LuaObject* dep); - - bool isDependOn(uint key); - - bool isDependOn(LuaObject* shared); - - void clearDependencies(); - - LuaObject* getDependency(uint key); - - int getDependenciesCount(); - - ////////////////////////////////////////////////////////////////////////////////////////////////////// - // Lua state object. - ////////////////////////////////////////////////////////////////////////////////////////////////////// - - using DepsMap = std::map; - - lua_State* state; - - Shared* shared; - - const char* type; - - DepsMap* dependencies; - - }; - - } // namespace Lua -} // namespace JinEngine - -#endif // __JIN_COMMON_OBJECT_H__ \ No newline at end of file diff --git a/src/libjin-lua/common/je_lua_port.h b/src/libjin-lua/common/je_lua_port.h deleted file mode 100644 index 8e99ca4..0000000 --- a/src/libjin-lua/common/je_lua_port.h +++ /dev/null @@ -1,8 +0,0 @@ -#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/libjin-lua/common/je_lua_reference.cpp b/src/libjin-lua/common/je_lua_reference.cpp deleted file mode 100644 index 72c1c3e..0000000 --- a/src/libjin-lua/common/je_lua_reference.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "common/je_lua.h" - -#include "je_lua_reference.h" - -namespace JinEngine -{ - namespace Lua - { - - LuaRef::LuaRef(lua_State* L, int i) - : mL(L) - { - // Get value. - luax_pushvalue(mL, i); - // Set reference. - luax_getreferencestable(L); - luax_pushvalue(mL, -2); - mIndex = luax_ref(mL, -2); - luax_pop(L, 3); - } - - LuaRef::~LuaRef() - { - unref(); - } - - void LuaRef::unref() - { - luax_getreferencestable(mL); - luax_unref(mL, -1, mIndex); - luax_pop(mL, 1); - } - - void LuaRef::push() - { - luax_getreferencestable(mL); - luax_rawgeti(mL, -1, mIndex); - luax_remove(mL, -2); - } - - } -} \ No newline at end of file diff --git a/src/libjin-lua/common/je_lua_reference.h b/src/libjin-lua/common/je_lua_reference.h deleted file mode 100644 index 1a62dba..0000000 --- a/src/libjin-lua/common/je_lua_reference.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef __JIN_COMMON_REFERENCE_H -#define __JIN_COMMON_REFERENCE_H - -#include "common/je_lua.h" - -namespace JinEngine -{ - namespace Lua - { - - /// - /// This class wraps the reference functionality built into Lua, which allows C++ code to refer to Lua - /// variables. - /// - class LuaRef - { - public: - /// - /// - /// - LuaRef(lua_State* L, int i); - - /// - /// - /// - ~LuaRef(); - - /// - /// - /// - void unref(); - - /// - /// Push value onto the stack. - /// - void push(); - - private: - /// - /// - /// - lua_State* const mL; - - /// - /// - /// - int mIndex; - - }; - - } // namespace Lua -} // namespace JinEngine - -#endif // __JIN_COMMON_REFERENCE_H \ No newline at end of file diff --git a/src/libjin-lua/common/je_lua_runtime.cpp b/src/libjin-lua/common/je_lua_runtime.cpp deleted file mode 100644 index fb665f1..0000000 --- a/src/libjin-lua/common/je_lua_runtime.cpp +++ /dev/null @@ -1,215 +0,0 @@ -#include "libjin/jin.h" - -#include "je_lua.h" -#include "je_lua_object.h" - -using namespace std; -using namespace JinEngine::Math; - -namespace JinEngine -{ - namespace Lua - { - - static const char* Jin_Lua_Objects_Table = "Jin_Objects_Table"; - - static const char* Jin_Lua_Reference_Table = "Jin_Reference_Table"; - - static const char* Jin_Lua_Modules_Table = "Jin_Modules_Table"; - - using DepsMap = LuaObject::DepsMap; - - LuaObject* luax_newinstance(lua_State* L, const char* type, Shared* shared) - { - LuaObject* obj = static_cast(luax_newinstance(L, type, sizeof(LuaObject))); - obj->state = L; - obj->type = type; - obj->bind(shared); - // Add to objects_table, objects_table[shared] = luaObj - luax_getobjectstable(L); - luax_pushlightuserdata(L, shared); - luax_pushvalue(L, -3); - luax_settable(L, -3); - luax_pop(L, 1); // Pop objects table. - return obj; - } - - LuaObject* luax_checkobject(lua_State* L, int idx, const char* type) - { - return (LuaObject*)luax_checktype(L, idx, type); - } - - LuaObject* luax_copyinstance(lua_State* to, LuaObject* src) - { - if (to == src->state) - return nullptr; - // Copy dependencies. - DepsMap& srcDeps = *src->dependencies; - for (DepsMap::iterator it = srcDeps.begin(); it != srcDeps.end(); ++it) - { - LuaObject* obj = it->second; - Shared* shr = obj->shared; - // Try get lua object. - luax_getobject(src->state, obj); - LuaObject* luaObj = (LuaObject*)luax_checktype(src->state, -1, obj->getObjectType()); - luax_pop(src->state, 1); // Pop lua object. - luax_copyinstance(to, luaObj); - luax_pop(to, 1); // Pop reference object. - } - Shared* shr = src->getShared(); - LuaObject* obj = luax_newinstance(to, src->getObjectType(), shr); - (*obj->dependencies) = (*src->dependencies); - // Add to objects_table. - luax_getobjectstable(to); - luax_pushlightuserdata(to, shr); - luax_pushvalue(to, -3); - luax_settable(to, -3); - luax_pop(to, 1); // Pop objects table. - // Set dependencies. - DepsMap& deps = *obj->dependencies; - DepsMap::iterator it = deps.begin(); - for (; it != deps.end(); ++it) - { - LuaObject* dep = it->second; - luax_addreference(to, src, dep); - } - return obj; - } - - int luax_getobject(lua_State* L, LuaObject* obj) - { - luax_getobjectstable(L); - luax_pushlightuserdata(L, obj->shared); - luax_gettable(L, -2); - luax_remove(L, -2); // Remove objects table on stack. - return 1; - } - - void luax_removeobject(lua_State* L, LuaObject* obj) - { - luax_getobjectstable(L); - luax_pushlightuserdata(L, obj->shared); - luax_pushnil(L); - luax_settable(L, -3); - luax_pop(L, 1); - } - - int luax_getobjectstable(lua_State* L) - { - luax_getfield(L, LUA_REGISTRYINDEX, Jin_Lua_Objects_Table); - // If no such table, add one. - if (luax_isnil(L, -1) || !luax_istable(L, -1)) - { - luax_pop(L, 1); - luax_newtable(L); - - // metatable - luax_newtable(L); - // weak table - luax_pushliteral(L, "v"); - luax_setfield(L, -2, "__mode"); - // setmetatable(newtable, metatable) - luax_setmetatable(L, -2); - - luax_pushvalue(L, -1); - luax_setfield(L, LUA_REGISTRYINDEX, Jin_Lua_Objects_Table); - } - return 1; - } - - int luax_getmodulestable(lua_State* L) - { - luax_getfield(L, LUA_REGISTRYINDEX, Jin_Lua_Modules_Table); - // If no such table, add one. - if (luax_isnil(L, -1) || !luax_istable(L, -1)) - { - luax_pop(L, 1); - luax_newtable(L); - - // metatable - luax_newtable(L); - // weak table - luax_pushliteral(L, "v"); - luax_setfield(L, -2, "__mode"); - // setmetatable(newtable, metatable) - luax_setmetatable(L, -2); - - luax_pushvalue(L, -1); - luax_setfield(L, LUA_REGISTRYINDEX, Jin_Lua_Modules_Table); - } - return 1; - } - - int luax_getreferencestable(lua_State* L) - { - luax_getfield(L, LUA_REGISTRYINDEX, Jin_Lua_Reference_Table); - // If no such table, add one. - if (luax_isnil(L, -1) || !luax_istable(L, -1)) - { - luax_pop(L, 1); - luax_newtable(L); - luax_pushvalue(L, -1); - luax_setfield(L, LUA_REGISTRYINDEX, Jin_Lua_Reference_Table); - } - return 1; - } - - void luax_getreference(lua_State* L, LuaObject* obj) - { - luax_getreferencestable(L); - luax_pushlightuserdata(L, obj->shared); - luax_gettable(L, -2); - luax_remove(L, -2); - } - - bool luax_addreference(lua_State* L, LuaObject* obj, LuaObject* dep) - { - luax_getreference(L, obj); - // If no dependencies table, add one. - if (luax_isnil(L, -1)) - { - luax_pop(L, 1); - luax_getreferencestable(L); - luax_newtable(L); - luax_pushlightuserdata(L, obj->shared); - luax_pushvalue(L, -2); - luax_settable(L, -4); - luax_remove(L, -2); // Remove references table. - } - luax_pushlightuserdata(L, dep->shared); - luax_getobject(L, dep); - if (luax_isnil(L, -1)) - { - luax_pop(L, 3); // Pop nil, dep, reftbl. - return false; - } - luax_settable(L, -3); - luax_pop(L, 1); - return true; - } - - void luax_removereference(lua_State* L, LuaObject* obj) - { - luax_getreferencestable(L); - luax_pushlightuserdata(L, obj->shared); - luax_pushnil(L); - luax_settable(L, -3); - luax_pop(L, 1); - } - - void luax_removereference(lua_State* L, LuaObject* obj, LuaObject* dep) - { - luax_getreference(L, obj); - if (luax_isnil(L, -1)) - { - luax_pop(L, 1); - return; - } - luax_pushlightuserdata(L, dep->shared); - luax_pushnil(L); - luax_settable(L, -3); - luax_pop(L, 1); - } - - } -} \ No newline at end of file diff --git a/src/libjin-lua/common/je_lua_shared.cpp b/src/libjin-lua/common/je_lua_shared.cpp deleted file mode 100644 index fce6d81..0000000 --- a/src/libjin-lua/common/je_lua_shared.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "je_lua.h" -#include "je_lua_shared.hpp" -#include "libjin/jin.h" - -namespace JinEngine -{ - namespace Lua - { - - } -} \ No newline at end of file diff --git a/src/libjin-lua/common/je_lua_shared.hpp b/src/libjin-lua/common/je_lua_shared.hpp deleted file mode 100644 index 6a58ab3..0000000 --- a/src/libjin-lua/common/je_lua_shared.hpp +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef __JE_LUA_SHARED_H__ -#define __JE_LUA_SHARED_H__ - -#include -#include -#include - -#include "libjin/jin.h" - -namespace JinEngine -{ - namespace Lua - { - - class LuaObject; - - /// - /// Thread shared object wrapper. - /// - class Shared - { - public: - Shared(Object* obj) - : mCount(0) - , mObject(obj) - { - } - - inline Object* operator->() - { - return static_cast(mObject); - } - - inline Object* getObject() - { - return static_cast(mObject); - } - - template - inline T* getObject() - { - return static_cast(mObject); - } - - private: - friend class LuaObject; - - // Disable copy. - Shared(const Shared& shared); - - /// - /// Shared只能在堆 - /// - ~Shared() - { - delete mObject; - } - - /// - /// 在同一个线程的lua_State中,LuaObject和EngineObject应该是一一对应,由LuaObject(lua runtime)管理引用计数 - /// 和回收。Engine-side引用计数是为了维护不同线程的lua_State共享同一个EngineObject。每次由LuaObject绑定一个 - /// Shared时就增加一个引用计数,理论上在同一个线程中,一个EngineObject只能由一个LuaObject绑定,发生在new - /// instance过程中,那么mCount就表明EngineObject的共享线程数。 - /// - inline void Shared::retain() - { - ++mCount; - } - - inline void Shared::release() - { - if (--mCount <= 0) - delete this; - } - - Object* mObject; - int mCount; - - }; - - } // namespace Lua -} // namespace JinEngine - -#endif \ No newline at end of file diff --git a/src/libjin-lua/common/l_callback.cpp b/src/libjin-lua/common/l_callback.cpp new file mode 100644 index 0000000..a2adcea --- /dev/null +++ b/src/libjin-lua/common/l_callback.cpp @@ -0,0 +1,43 @@ +#include "l_callback.h" + +namespace JinEngine +{ + namespace Lua + { + + LuaCallback::LuaCallback(lua_State* L) + : mLuaFunc(nullptr) + , mParams(0) + , mL(L) + { + } + + LuaCallback::~LuaCallback() + { + delete mLuaFunc; + for (auto p : mParams) + delete p; + } + + void LuaCallback::setFunc(int i) + { + if (mLuaFunc != nullptr) + delete mLuaFunc; + mLuaFunc = new LuaRef(mL, i); + } + + void LuaCallback::pushParam(int i) + { + mParams.push_back(new LuaRef(mL, i)); + } + + void LuaCallback::call() + { + mLuaFunc->push(); + for (auto p : mParams) + p->push(); + luax_call(mL, mParams.size(), 0); + } + + } +} \ No newline at end of file diff --git a/src/libjin-lua/common/l_callback.h b/src/libjin-lua/common/l_callback.h new file mode 100644 index 0000000..af7200c --- /dev/null +++ b/src/libjin-lua/common/l_callback.h @@ -0,0 +1,66 @@ +#ifndef __JIN_COMMON_FUNCTION_H +#define __JIN_COMMON_FUNCTION_H + +#include + +#include "libjin/jin.h" +#include "l_reference.h" + +namespace JinEngine +{ + namespace Lua + { + + /// + /// + /// + class LuaCallback + { + public: + /// + /// + /// + LuaCallback(lua_State* L); + + /// + /// + /// + ~LuaCallback(); + + /// + /// + /// + void setFunc(int i); + + /// + /// + /// + void pushParam(int i); + + /// + /// + /// + void call(); + + private: + /// + /// + /// + LuaRef* mLuaFunc; + + /// + /// + /// + std::vector mParams; + + /// + /// + /// + lua_State* const mL; + + }; + + } // namespace Lua +} // namespace JinEngine + +#endif // __JIN_COMMON_REFERENCE_H \ No newline at end of file diff --git a/src/libjin-lua/common/l_common.h b/src/libjin-lua/common/l_common.h new file mode 100644 index 0000000..21daff2 --- /dev/null +++ b/src/libjin-lua/common/l_common.h @@ -0,0 +1,8 @@ +#ifndef __JIN_M_TYPES_H +#define __JIN_M_TYPES_H + +#include "je_lua.h" +#include "l_port.h" +#include "l_reference.h" + +#endif \ No newline at end of file diff --git a/src/libjin-lua/common/l_constant.h b/src/libjin-lua/common/l_constant.h new file mode 100644 index 0000000..c173b88 --- /dev/null +++ b/src/libjin-lua/common/l_constant.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_CONSTANT_H__ +#define __JE_LUA_CONSTANT_H__ + +namespace JinEngine +{ + namespace Lua + { + + + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/common/l_function.cpp b/src/libjin-lua/common/l_function.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/libjin-lua/common/l_function.h b/src/libjin-lua/common/l_function.h new file mode 100644 index 0000000..49c1b31 --- /dev/null +++ b/src/libjin-lua/common/l_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/libjin-lua/common/l_object.cpp b/src/libjin-lua/common/l_object.cpp new file mode 100644 index 0000000..e3ac158 --- /dev/null +++ b/src/libjin-lua/common/l_object.cpp @@ -0,0 +1,112 @@ +#include "l_object.h" +#include "je_lua.h" + +namespace JinEngine +{ + namespace Lua + { + + void LuaObject::bind(Shared* obj) + { + if (obj) + { + shared = obj; + shared->retain(); + dependencies = new std::map(); + } + } + + void LuaObject::release() + { + // Delete lua shared table reference and references. + if (dependencies) + { + clearDependencies(); + delete dependencies; + dependencies = nullptr; + } + // Try delete engine side shared. + if (shared) + { + shared->release(); + shared = nullptr; + } + } + + const char* LuaObject::getObjectType() + { + return type; + } + + Shared* LuaObject::getShared() + { + return shared; + } + + void LuaObject::setDependency(uint key, LuaObject* dep) + { + removeDependency(key); + dependencies->insert(std::pair(key, dep)); + luax_addreference(state, this, dep); + } + + void LuaObject::removeDependency(uint key) + { + if (!isDependOn(key)) + return; + DepsMap::iterator it = dependencies->find(key); + LuaObject* dep = it->second; + luax_removereference(state, this, dep); + dependencies->erase(it); + } + + void LuaObject::removeDependency(LuaObject* dependency) + { + for (DepsMap::iterator it = dependencies->begin(); it != dependencies->end();) + { + LuaObject* dep = it->second; + if (dep == dependency) + { + luax_removereference(state, this, dep); + dependencies->erase(it); + } + else + ++it; + } + } + + bool LuaObject::isDependOn(uint key) + { + return dependencies->find(key) != dependencies->end(); + } + + bool LuaObject::isDependOn(LuaObject* shared) + { + for (std::pair dep : (*dependencies)) + { + if (dep.second == shared) + return true; + } + return false; + } + + void LuaObject::clearDependencies() + { + luax_removereference(state, this); + dependencies->clear(); + } + + LuaObject* LuaObject::getDependency(uint key) + { + if (!isDependOn(key)) + return nullptr; + return dependencies->find(key)->second; + } + + int LuaObject::getDependenciesCount() + { + return dependencies->size(); + } + + } +} \ No newline at end of file diff --git a/src/libjin-lua/common/l_object.h b/src/libjin-lua/common/l_object.h new file mode 100644 index 0000000..15bd79d --- /dev/null +++ b/src/libjin-lua/common/l_object.h @@ -0,0 +1,69 @@ +#ifndef __JIN_COMMON_OBJECT_H__ +#define __JIN_COMMON_OBJECT_H__ + +#include "libjin/jin.h" +#include "l_shared.hpp" + +struct lua_State; + +namespace JinEngine +{ + namespace Lua + { + + class LuaObject + { + public: + /// + /// Set lua_State and object it bind. + /// + void bind(Shared* obj); + + void release(); + + const char* getObjectType(); + + Shared* getShared(); + + template + T* getObject() + { + return shared->getObject(); + } + + void setDependency(uint key, LuaObject* dep); + + void removeDependency(uint key); + + void removeDependency(LuaObject* dep); + + bool isDependOn(uint key); + + bool isDependOn(LuaObject* shared); + + void clearDependencies(); + + LuaObject* getDependency(uint key); + + int getDependenciesCount(); + + ////////////////////////////////////////////////////////////////////////////////////////////////////// + // Lua state object. + ////////////////////////////////////////////////////////////////////////////////////////////////////// + + using DepsMap = std::map; + + lua_State* state; + + Shared* shared; + + const char* type; + + DepsMap* dependencies; + + }; + + } // namespace Lua +} // namespace JinEngine + +#endif // __JIN_COMMON_OBJECT_H__ \ No newline at end of file diff --git a/src/libjin-lua/common/l_port.h b/src/libjin-lua/common/l_port.h new file mode 100644 index 0000000..8e99ca4 --- /dev/null +++ b/src/libjin-lua/common/l_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/libjin-lua/common/l_reference.cpp b/src/libjin-lua/common/l_reference.cpp new file mode 100644 index 0000000..2fcf792 --- /dev/null +++ b/src/libjin-lua/common/l_reference.cpp @@ -0,0 +1,42 @@ +#include "common/je_lua.h" + +#include "l_reference.h" + +namespace JinEngine +{ + namespace Lua + { + + LuaRef::LuaRef(lua_State* L, int i) + : mL(L) + { + // Get value. + luax_pushvalue(mL, i); + // Set reference. + luax_getreferencestable(L); + luax_pushvalue(mL, -2); + mIndex = luax_ref(mL, -2); + luax_pop(L, 3); + } + + LuaRef::~LuaRef() + { + unref(); + } + + void LuaRef::unref() + { + luax_getreferencestable(mL); + luax_unref(mL, -1, mIndex); + luax_pop(mL, 1); + } + + void LuaRef::push() + { + luax_getreferencestable(mL); + luax_rawgeti(mL, -1, mIndex); + luax_remove(mL, -2); + } + + } +} \ No newline at end of file diff --git a/src/libjin-lua/common/l_reference.h b/src/libjin-lua/common/l_reference.h new file mode 100644 index 0000000..1a62dba --- /dev/null +++ b/src/libjin-lua/common/l_reference.h @@ -0,0 +1,54 @@ +#ifndef __JIN_COMMON_REFERENCE_H +#define __JIN_COMMON_REFERENCE_H + +#include "common/je_lua.h" + +namespace JinEngine +{ + namespace Lua + { + + /// + /// This class wraps the reference functionality built into Lua, which allows C++ code to refer to Lua + /// variables. + /// + class LuaRef + { + public: + /// + /// + /// + LuaRef(lua_State* L, int i); + + /// + /// + /// + ~LuaRef(); + + /// + /// + /// + void unref(); + + /// + /// Push value onto the stack. + /// + void push(); + + private: + /// + /// + /// + lua_State* const mL; + + /// + /// + /// + int mIndex; + + }; + + } // namespace Lua +} // namespace JinEngine + +#endif // __JIN_COMMON_REFERENCE_H \ No newline at end of file diff --git a/src/libjin-lua/common/l_runtime.cpp b/src/libjin-lua/common/l_runtime.cpp new file mode 100644 index 0000000..0972ee5 --- /dev/null +++ b/src/libjin-lua/common/l_runtime.cpp @@ -0,0 +1,215 @@ +#include "libjin/jin.h" + +#include "je_lua.h" +#include "l_object.h" + +using namespace std; +using namespace JinEngine::Math; + +namespace JinEngine +{ + namespace Lua + { + + static const char* Jin_Lua_Objects_Table = "Jin_Objects_Table"; + + static const char* Jin_Lua_Reference_Table = "Jin_Reference_Table"; + + static const char* Jin_Lua_Modules_Table = "Jin_Modules_Table"; + + using DepsMap = LuaObject::DepsMap; + + LuaObject* luax_newinstance(lua_State* L, const char* type, Shared* shared) + { + LuaObject* obj = static_cast(luax_newinstance(L, type, sizeof(LuaObject))); + obj->state = L; + obj->type = type; + obj->bind(shared); + // Add to objects_table, objects_table[shared] = luaObj + luax_getobjectstable(L); + luax_pushlightuserdata(L, shared); + luax_pushvalue(L, -3); + luax_settable(L, -3); + luax_pop(L, 1); // Pop objects table. + return obj; + } + + LuaObject* luax_checkobject(lua_State* L, int idx, const char* type) + { + return (LuaObject*)luax_checktype(L, idx, type); + } + + LuaObject* luax_copyinstance(lua_State* to, LuaObject* src) + { + if (to == src->state) + return nullptr; + // Copy dependencies. + DepsMap& srcDeps = *src->dependencies; + for (DepsMap::iterator it = srcDeps.begin(); it != srcDeps.end(); ++it) + { + LuaObject* obj = it->second; + Shared* shr = obj->shared; + // Try get lua object. + luax_getobject(src->state, obj); + LuaObject* luaObj = (LuaObject*)luax_checktype(src->state, -1, obj->getObjectType()); + luax_pop(src->state, 1); // Pop lua object. + luax_copyinstance(to, luaObj); + luax_pop(to, 1); // Pop reference object. + } + Shared* shr = src->getShared(); + LuaObject* obj = luax_newinstance(to, src->getObjectType(), shr); + (*obj->dependencies) = (*src->dependencies); + // Add to objects_table. + luax_getobjectstable(to); + luax_pushlightuserdata(to, shr); + luax_pushvalue(to, -3); + luax_settable(to, -3); + luax_pop(to, 1); // Pop objects table. + // Set dependencies. + DepsMap& deps = *obj->dependencies; + DepsMap::iterator it = deps.begin(); + for (; it != deps.end(); ++it) + { + LuaObject* dep = it->second; + luax_addreference(to, src, dep); + } + return obj; + } + + int luax_getobject(lua_State* L, LuaObject* obj) + { + luax_getobjectstable(L); + luax_pushlightuserdata(L, obj->shared); + luax_gettable(L, -2); + luax_remove(L, -2); // Remove objects table on stack. + return 1; + } + + void luax_removeobject(lua_State* L, LuaObject* obj) + { + luax_getobjectstable(L); + luax_pushlightuserdata(L, obj->shared); + luax_pushnil(L); + luax_settable(L, -3); + luax_pop(L, 1); + } + + int luax_getobjectstable(lua_State* L) + { + luax_getfield(L, LUA_REGISTRYINDEX, Jin_Lua_Objects_Table); + // If no such table, add one. + if (luax_isnil(L, -1) || !luax_istable(L, -1)) + { + luax_pop(L, 1); + luax_newtable(L); + + // metatable + luax_newtable(L); + // weak table + luax_pushliteral(L, "v"); + luax_setfield(L, -2, "__mode"); + // setmetatable(newtable, metatable) + luax_setmetatable(L, -2); + + luax_pushvalue(L, -1); + luax_setfield(L, LUA_REGISTRYINDEX, Jin_Lua_Objects_Table); + } + return 1; + } + + int luax_getmodulestable(lua_State* L) + { + luax_getfield(L, LUA_REGISTRYINDEX, Jin_Lua_Modules_Table); + // If no such table, add one. + if (luax_isnil(L, -1) || !luax_istable(L, -1)) + { + luax_pop(L, 1); + luax_newtable(L); + + // metatable + luax_newtable(L); + // weak table + luax_pushliteral(L, "v"); + luax_setfield(L, -2, "__mode"); + // setmetatable(newtable, metatable) + luax_setmetatable(L, -2); + + luax_pushvalue(L, -1); + luax_setfield(L, LUA_REGISTRYINDEX, Jin_Lua_Modules_Table); + } + return 1; + } + + int luax_getreferencestable(lua_State* L) + { + luax_getfield(L, LUA_REGISTRYINDEX, Jin_Lua_Reference_Table); + // If no such table, add one. + if (luax_isnil(L, -1) || !luax_istable(L, -1)) + { + luax_pop(L, 1); + luax_newtable(L); + luax_pushvalue(L, -1); + luax_setfield(L, LUA_REGISTRYINDEX, Jin_Lua_Reference_Table); + } + return 1; + } + + void luax_getreference(lua_State* L, LuaObject* obj) + { + luax_getreferencestable(L); + luax_pushlightuserdata(L, obj->shared); + luax_gettable(L, -2); + luax_remove(L, -2); + } + + bool luax_addreference(lua_State* L, LuaObject* obj, LuaObject* dep) + { + luax_getreference(L, obj); + // If no dependencies table, add one. + if (luax_isnil(L, -1)) + { + luax_pop(L, 1); + luax_getreferencestable(L); + luax_newtable(L); + luax_pushlightuserdata(L, obj->shared); + luax_pushvalue(L, -2); + luax_settable(L, -4); + luax_remove(L, -2); // Remove references table. + } + luax_pushlightuserdata(L, dep->shared); + luax_getobject(L, dep); + if (luax_isnil(L, -1)) + { + luax_pop(L, 3); // Pop nil, dep, reftbl. + return false; + } + luax_settable(L, -3); + luax_pop(L, 1); + return true; + } + + void luax_removereference(lua_State* L, LuaObject* obj) + { + luax_getreferencestable(L); + luax_pushlightuserdata(L, obj->shared); + luax_pushnil(L); + luax_settable(L, -3); + luax_pop(L, 1); + } + + void luax_removereference(lua_State* L, LuaObject* obj, LuaObject* dep) + { + luax_getreference(L, obj); + if (luax_isnil(L, -1)) + { + luax_pop(L, 1); + return; + } + luax_pushlightuserdata(L, dep->shared); + luax_pushnil(L); + luax_settable(L, -3); + luax_pop(L, 1); + } + + } +} \ No newline at end of file diff --git a/src/libjin-lua/common/l_shared.cpp b/src/libjin-lua/common/l_shared.cpp new file mode 100644 index 0000000..03303da --- /dev/null +++ b/src/libjin-lua/common/l_shared.cpp @@ -0,0 +1,11 @@ +#include "je_lua.h" +#include "l_shared.hpp" +#include "libjin/jin.h" + +namespace JinEngine +{ + namespace Lua + { + + } +} \ No newline at end of file diff --git a/src/libjin-lua/common/l_shared.hpp b/src/libjin-lua/common/l_shared.hpp new file mode 100644 index 0000000..6a58ab3 --- /dev/null +++ b/src/libjin-lua/common/l_shared.hpp @@ -0,0 +1,84 @@ +#ifndef __JE_LUA_SHARED_H__ +#define __JE_LUA_SHARED_H__ + +#include +#include +#include + +#include "libjin/jin.h" + +namespace JinEngine +{ + namespace Lua + { + + class LuaObject; + + /// + /// Thread shared object wrapper. + /// + class Shared + { + public: + Shared(Object* obj) + : mCount(0) + , mObject(obj) + { + } + + inline Object* operator->() + { + return static_cast(mObject); + } + + inline Object* getObject() + { + return static_cast(mObject); + } + + template + inline T* getObject() + { + return static_cast(mObject); + } + + private: + friend class LuaObject; + + // Disable copy. + Shared(const Shared& shared); + + /// + /// Shared只能在堆 + /// + ~Shared() + { + delete mObject; + } + + /// + /// 在同一个线程的lua_State中,LuaObject和EngineObject应该是一一对应,由LuaObject(lua runtime)管理引用计数 + /// 和回收。Engine-side引用计数是为了维护不同线程的lua_State共享同一个EngineObject。每次由LuaObject绑定一个 + /// Shared时就增加一个引用计数,理论上在同一个线程中,一个EngineObject只能由一个LuaObject绑定,发生在new + /// instance过程中,那么mCount就表明EngineObject的共享线程数。 + /// + inline void Shared::retain() + { + ++mCount; + } + + inline void Shared::release() + { + if (--mCount <= 0) + delete this; + } + + Object* mObject; + int mCount; + + }; + + } // namespace Lua +} // namespace JinEngine + +#endif \ No newline at end of file diff --git a/src/libjin-lua/je_lua_jin.cpp b/src/libjin-lua/je_lua_jin.cpp deleted file mode 100644 index 256e081..0000000 --- a/src/libjin-lua/je_lua_jin.cpp +++ /dev/null @@ -1,187 +0,0 @@ -#include "common/je_lua.h" -#include "common/je_lua_common.h" -#include "modules/je_lua_modules.h" -//#include "je_lua_embed.h" -#include "je_lua_jin.h" - -namespace JinEngine -{ - namespace Lua - { - - LUA_IMPLEMENT int l_getversion(lua_State* L) - { - luax_pushstring(L, VERSION); - return 1; - } - - LUA_IMPLEMENT int l_getAuthor(lua_State* L) - { - luax_pushstring(L, AUTHOR); - return 1; - } - - LUA_IMPLEMENT int l_getOS(lua_State* L) - { - #ifdef _WIN32 - luax_pushstring(L, "windows"); - #elif defined __unix__ - luax_pushstring(L, "unix"); - #elif defined __APPLE__ - luax_pushstring(L, "macos"); - #endif - return 1; - } - - LUA_IMPLEMENT int l_revision(lua_State* L) - { - luax_pushnumber(L, REVISION); - return 1; - } - - // Register jin module, keep it on the top of stack. - // The reason why not using luaL_register is because we want register some variables into jin module. - LUA_EXPORT void open(lua_State* L) - { - jin_log_info("Openning jin library."); - - luax_globaltable(L, MODULE_NAME); - - const luax_Str s[] = { - { "version", VERSION }, - { "author", AUTHOR }, - { "codename", CODE_NAME }, - { 0, 0 } - }; - const luax_Num n[] = { - { "revision", REVISION }, - { 0, 0 } - }; - // Register values. - luax_setfieldstrings(L, s); - luax_setfieldnumbers(L, n); - - luax_Reg modules[] = { - { "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 }, - //{"ai", luaopen_ai }, - { 0, 0 } - }; - - // Register sub modules. - for (int i = 0; modules[i].name; ++i) - { - modules[i].func(L); - luax_setfield(L, -2, modules[i].name); - } - - // Pop jin table. - luax_pop(L, 1); - - jin_log_info("Done."); - } - - // Embed structure. - struct jin_Embed - { - const char* file; - const char* source; - }; - - // Embed scripts. - #include "scripts/ai/state_machine.lua.h" - #include "scripts/graphics/graphics.lua.h" - #include "scripts/keyboard/keyboard.lua.h" - #include "scripts/mouse/mouse.lua.h" - #include "scripts/path/path.lua.h" - #include "scripts/time/time.lua.h" - #include "scripts/utils/json.lua.h" - #include "scripts/utils/xml.lua.h" - #include "scripts/log.lua.h" - #include "scripts/tiledmap/tiledmap.lua.h" - #include "scripts/physics/physics.lua.h" - #include "scripts/audio/audio.lua.h" - - #include "scripts/app.lua.h" - - // In order. - static const jin_Embed modules[] = { - // ai - { "state_machine.lua", state_machine_lua }, - // keyboard - { "keyboard.lua", keyboard_lua }, - { "mouse.lua", mouse_lua }, - { "graphics.lua", graphics_lua }, - { "path.lua", path_lua }, - { "time.lua", time_lua }, - { "json.lua", json_lua }, - { "xml.lua", xml_lua }, - { "tiledmap.lua", tiledmap_lua }, - { "physics.lua", physics_lua }, - { "audio.lua", audio_lua }, - // - { "log.lua", log_lua }, - { 0, 0 } - }; - - static const jin_Embed bootscript = { "app.lua", app_lua }; - - static void embed(lua_State* L) - { - jin_log_info("Load embeded scripts."); - const char* file, *source; - for (int i = 0; modules[i].file != 0; ++i) - { - file = modules[i].file; - source = modules[i].source; - jin_log_info("Embed script \"%s\".", file); - luax_clearstack(L); - if (luax_loadbuffer(L, source, strlen(source), file) == 0) - { - luax_call(L, 0, 0); - } - else - { - jin_log_error("Embed script \"%s\" failed.", file); - } - } - } - - static void run(lua_State* L) - { - const char* file, *source; - file = bootscript.file; - source = bootscript.source; - jin_log_info("Run boot script \"%s\".", file); - luax_clearstack(L); - if (luax_loadbuffer(L, source, strlen(source), file) == 0) - { - luax_call(L, 0, 0); - } - } - - LUA_EXPORT void boot(lua_State* L, const char* cwd) - { - luax_clearstack(L); - luax_getglobal(L, MODULE_NAME); - luax_newtable(L); - luax_setfieldstring(L, "cwd", cwd); - luax_setfield(L, -2, "args"); - luax_clearstack(L); - embed(L); - run(L); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/je_lua_jin.h b/src/libjin-lua/je_lua_jin.h deleted file mode 100644 index 7b38ce7..0000000 --- a/src/libjin-lua/je_lua_jin.h +++ /dev/null @@ -1,36 +0,0 @@ -/** -* Copyright (C) 2016~2018 chai -*/ - -#ifndef __JIN_M_JIN_H__ -#define __JIN_M_JIN_H__ - -#include "common/je_lua.h" -#include "common/je_lua_common.h" - -#define MODULE_NAME "jin" -#define CODE_NAME "Side Part" -#define VERSION "0.1.1" -#define REVISION_S "101" -#define REVISION 101 -#define AUTHOR "chai" - -namespace JinEngine -{ - namespace Lua - { - - /// - /// open jin module. - /// - LUA_EXPORT void open(lua_State* L); - - /// - /// Boot jin. - /// - LUA_EXPORT void boot(lua_State* L, const char* cwd); - - } // namespace JinEngine -} // namespace Lua - -#endif // __JIN_M_JIN_H__ \ No newline at end of file diff --git a/src/libjin-lua/l_jin.cpp b/src/libjin-lua/l_jin.cpp new file mode 100644 index 0000000..6a0809a --- /dev/null +++ b/src/libjin-lua/l_jin.cpp @@ -0,0 +1,187 @@ +#include "common/je_lua.h" +#include "common/l_common.h" +#include "modules/l_modules.h" +//#include "l_embed.h" +#include "l_jin.h" + +namespace JinEngine +{ + namespace Lua + { + + LUA_IMPLEMENT int l_getversion(lua_State* L) + { + luax_pushstring(L, VERSION); + return 1; + } + + LUA_IMPLEMENT int l_getAuthor(lua_State* L) + { + luax_pushstring(L, AUTHOR); + return 1; + } + + LUA_IMPLEMENT int l_getOS(lua_State* L) + { + #ifdef _WIN32 + luax_pushstring(L, "windows"); + #elif defined __unix__ + luax_pushstring(L, "unix"); + #elif defined __APPLE__ + luax_pushstring(L, "macos"); + #endif + return 1; + } + + LUA_IMPLEMENT int l_revision(lua_State* L) + { + luax_pushnumber(L, REVISION); + return 1; + } + + // Register jin module, keep it on the top of stack. + // The reason why not using luaL_register is because we want register some variables into jin module. + LUA_EXPORT void open(lua_State* L) + { + jin_log_info("Openning jin library."); + + luax_globaltable(L, MODULE_NAME); + + const luax_Str s[] = { + { "version", VERSION }, + { "author", AUTHOR }, + { "codename", CODE_NAME }, + { 0, 0 } + }; + const luax_Num n[] = { + { "revision", REVISION }, + { 0, 0 } + }; + // Register values. + luax_setfieldstrings(L, s); + luax_setfieldnumbers(L, n); + + luax_Reg modules[] = { + { "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 }, + //{"ai", luaopen_ai }, + { 0, 0 } + }; + + // Register sub modules. + for (int i = 0; modules[i].name; ++i) + { + modules[i].func(L); + luax_setfield(L, -2, modules[i].name); + } + + // Pop jin table. + luax_pop(L, 1); + + jin_log_info("Done."); + } + + // Embed structure. + struct jin_Embed + { + const char* file; + const char* source; + }; + + // Embed scripts. + #include "scripts/ai/state_machine.lua.h" + #include "scripts/graphics/graphics.lua.h" + #include "scripts/keyboard/keyboard.lua.h" + #include "scripts/mouse/mouse.lua.h" + #include "scripts/path/path.lua.h" + #include "scripts/time/time.lua.h" + #include "scripts/utils/json.lua.h" + #include "scripts/utils/xml.lua.h" + #include "scripts/log.lua.h" + #include "scripts/tiledmap/tiledmap.lua.h" + #include "scripts/physics/physics.lua.h" + #include "scripts/audio/audio.lua.h" + + #include "scripts/app.lua.h" + + // In order. + static const jin_Embed modules[] = { + // ai + { "state_machine.lua", state_machine_lua }, + // keyboard + { "keyboard.lua", keyboard_lua }, + { "mouse.lua", mouse_lua }, + { "graphics.lua", graphics_lua }, + { "path.lua", path_lua }, + { "time.lua", time_lua }, + { "json.lua", json_lua }, + { "xml.lua", xml_lua }, + { "tiledmap.lua", tiledmap_lua }, + { "physics.lua", physics_lua }, + { "audio.lua", audio_lua }, + // + { "log.lua", log_lua }, + { 0, 0 } + }; + + static const jin_Embed bootscript = { "app.lua", app_lua }; + + static void embed(lua_State* L) + { + jin_log_info("Load embeded scripts."); + const char* file, *source; + for (int i = 0; modules[i].file != 0; ++i) + { + file = modules[i].file; + source = modules[i].source; + jin_log_info("Embed script \"%s\".", file); + luax_clearstack(L); + if (luax_loadbuffer(L, source, strlen(source), file) == 0) + { + luax_call(L, 0, 0); + } + else + { + jin_log_error("Embed script \"%s\" failed.", file); + } + } + } + + static void run(lua_State* L) + { + const char* file, *source; + file = bootscript.file; + source = bootscript.source; + jin_log_info("Run boot script \"%s\".", file); + luax_clearstack(L); + if (luax_loadbuffer(L, source, strlen(source), file) == 0) + { + luax_call(L, 0, 0); + } + } + + LUA_EXPORT void boot(lua_State* L, const char* cwd) + { + luax_clearstack(L); + luax_getglobal(L, MODULE_NAME); + luax_newtable(L); + luax_setfieldstring(L, "cwd", cwd); + luax_setfield(L, -2, "args"); + luax_clearstack(L); + embed(L); + run(L); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/l_jin.h b/src/libjin-lua/l_jin.h new file mode 100644 index 0000000..64db4c2 --- /dev/null +++ b/src/libjin-lua/l_jin.h @@ -0,0 +1,36 @@ +/** +* Copyright (C) 2016~2018 chai +*/ + +#ifndef __JIN_M_JIN_H__ +#define __JIN_M_JIN_H__ + +#include "common/je_lua.h" +#include "common/l_common.h" + +#define MODULE_NAME "jin" +#define CODE_NAME "Side Part" +#define VERSION "0.1.1" +#define REVISION_S "101" +#define REVISION 101 +#define AUTHOR "chai" + +namespace JinEngine +{ + namespace Lua + { + + /// + /// open jin module. + /// + LUA_EXPORT void open(lua_State* L); + + /// + /// Boot jin. + /// + LUA_EXPORT void boot(lua_State* L, const char* cwd); + + } // namespace JinEngine +} // namespace Lua + +#endif // __JIN_M_JIN_H__ \ No newline at end of file diff --git a/src/libjin-lua/modules/ai/je_lua_ai.cpp b/src/libjin-lua/modules/ai/je_lua_ai.cpp deleted file mode 100644 index 4afd625..0000000 --- a/src/libjin-lua/modules/ai/je_lua_ai.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "libjin/jin.h" - -using namespace JinEngine::AI; - -namespace JinEngine -{ - namespace Lua - { - - - - } -} \ No newline at end of file diff --git a/src/libjin-lua/modules/ai/je_lua_ai.h b/src/libjin-lua/modules/ai/je_lua_ai.h deleted file mode 100644 index 9e1a8ae..0000000 --- a/src/libjin-lua/modules/ai/je_lua_ai.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __JE_LUA_AI_H__ -#define __JE_LUA_AI_H__ - -#include "je_lua_behavior_tree.h" -#include "je_lua_state_machine.h" - -namespace JinEngine -{ - namespace Lua - { - - int luaopen_ai(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/ai/je_lua_behavior_tree.cpp b/src/libjin-lua/modules/ai/je_lua_behavior_tree.cpp deleted file mode 100644 index 20e8e55..0000000 --- a/src/libjin-lua/modules/ai/je_lua_behavior_tree.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "libjin/jin.h" - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_BehaviorTree = "Texture"; - - } -} \ No newline at end of file diff --git a/src/libjin-lua/modules/ai/je_lua_behavior_tree.h b/src/libjin-lua/modules/ai/je_lua_behavior_tree.h deleted file mode 100644 index 083d12b..0000000 --- a/src/libjin-lua/modules/ai/je_lua_behavior_tree.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __JE_LUA_BEHAVIOR_TREE_H__ -#define __JE_LUA_BEHAVIOR_TREE_H__ - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_BehaviorTree; - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/ai/je_lua_state_machine.cpp b/src/libjin-lua/modules/ai/je_lua_state_machine.cpp deleted file mode 100644 index 06338b8..0000000 --- a/src/libjin-lua/modules/ai/je_lua_state_machine.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "common/je_lua_common.h" -#include "libjin/jin.h" - -using namespace JinEngine::AI; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_StateMachine = "StateMachine"; - - LUA_IMPLEMENT int l_addEnterCallback(lua_State* L) - { - //StateMachine* sm; - //sm->addEnterListener("", [](void* p) -> void{ - - // - //}); - - return 0; - } - - } -} \ No newline at end of file diff --git a/src/libjin-lua/modules/ai/je_lua_state_machine.h b/src/libjin-lua/modules/ai/je_lua_state_machine.h deleted file mode 100644 index 3c78f75..0000000 --- a/src/libjin-lua/modules/ai/je_lua_state_machine.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __JE_LUA_STATE_MACHINE_H__ -#define __JE_LUA_STATE_MACHINE_H__ - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_StateMachine; - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/ai/l_ai.cpp b/src/libjin-lua/modules/ai/l_ai.cpp new file mode 100644 index 0000000..4afd625 --- /dev/null +++ b/src/libjin-lua/modules/ai/l_ai.cpp @@ -0,0 +1,13 @@ +#include "libjin/jin.h" + +using namespace JinEngine::AI; + +namespace JinEngine +{ + namespace Lua + { + + + + } +} \ No newline at end of file diff --git a/src/libjin-lua/modules/ai/l_ai.h b/src/libjin-lua/modules/ai/l_ai.h new file mode 100644 index 0000000..919c0a3 --- /dev/null +++ b/src/libjin-lua/modules/ai/l_ai.h @@ -0,0 +1,17 @@ +#ifndef __JE_LUA_AI_H__ +#define __JE_LUA_AI_H__ + +#include "l_behavior_tree.h" +#include "l_state_machine.h" + +namespace JinEngine +{ + namespace Lua + { + + int luaopen_ai(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/ai/l_behavior_tree.cpp b/src/libjin-lua/modules/ai/l_behavior_tree.cpp new file mode 100644 index 0000000..20e8e55 --- /dev/null +++ b/src/libjin-lua/modules/ai/l_behavior_tree.cpp @@ -0,0 +1,11 @@ +#include "libjin/jin.h" + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_BehaviorTree = "Texture"; + + } +} \ No newline at end of file diff --git a/src/libjin-lua/modules/ai/l_behavior_tree.h b/src/libjin-lua/modules/ai/l_behavior_tree.h new file mode 100644 index 0000000..083d12b --- /dev/null +++ b/src/libjin-lua/modules/ai/l_behavior_tree.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_BEHAVIOR_TREE_H__ +#define __JE_LUA_BEHAVIOR_TREE_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_BehaviorTree; + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/ai/l_state_machine.cpp b/src/libjin-lua/modules/ai/l_state_machine.cpp new file mode 100644 index 0000000..1825de5 --- /dev/null +++ b/src/libjin-lua/modules/ai/l_state_machine.cpp @@ -0,0 +1,25 @@ +#include "common/l_common.h" +#include "libjin/jin.h" + +using namespace JinEngine::AI; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_StateMachine = "StateMachine"; + + LUA_IMPLEMENT int l_addEnterCallback(lua_State* L) + { + //StateMachine* sm; + //sm->addEnterListener("", [](void* p) -> void{ + + // + //}); + + return 0; + } + + } +} \ No newline at end of file diff --git a/src/libjin-lua/modules/ai/l_state_machine.h b/src/libjin-lua/modules/ai/l_state_machine.h new file mode 100644 index 0000000..3c78f75 --- /dev/null +++ b/src/libjin-lua/modules/ai/l_state_machine.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_STATE_MACHINE_H__ +#define __JE_LUA_STATE_MACHINE_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_StateMachine; + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/audio/je_lua_audio.cpp b/src/libjin-lua/modules/audio/je_lua_audio.cpp deleted file mode 100644 index d5cfb43..0000000 --- a/src/libjin-lua/modules/audio/je_lua_audio.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "common/je_lua.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" -#include "je_lua_source.h" - -using namespace JinEngine::Audio; -using namespace JinEngine::Audio::SDL; -using namespace JinEngine::Filesystem; - -namespace JinEngine -{ - namespace Lua - { - - typedef SDLAudio Audio; - typedef SDLSource Source; - - struct - { - bool initialized = false; - } context; - - LUA_IMPLEMENT int l_init(lua_State* L) - { - if (context.initialized) - { - // Already initialized. - luax_pushboolean(L, true); - return 1; - } - Audio::Setting setting; - setting.samplerate = 44100; - setting.samples = 44100; - Audio* audio = Audio::get(); - context.initialized = audio->start(&setting); - if (!context.initialized) - { - luax_error(L, "could not init audio"); - luax_pushboolean(L, false); - return 1; - } - luax_pushboolean(L, true); - return 1; - } - - LUA_IMPLEMENT int l_play(lua_State* L) - { - Audio::get()->play(); - return 0; - } - - LUA_IMPLEMENT int l_stop(lua_State* L) - { - Audio::get()->stop(); - return 0; - } - - LUA_IMPLEMENT int l_pause(lua_State* L) - { - Audio::get()->pause(); - return 0; - } - - LUA_IMPLEMENT int l_resume(lua_State* L) - { - Audio::get()->resume(); - return 0; - } - - LUA_IMPLEMENT int l_setVolume(lua_State* L) - { - float volume = luax_checknumber(L, 1); - Audio::get()->setVolume(volume); - return 0; - } - - LUA_IMPLEMENT int l_newSource(lua_State* L) - { - AssetDatabase* fs = AssetDatabase::get(); - const char* f = luax_checkstring(L, 1); - Buffer b; - try - { - if (!fs->exists(f)) - throw Exception("No such source file %s.", f); - fs->read(f, b); - } - catch (Exception& e) - { - luax_errorf(L, "Failed to read source file %s", f); - luax_pushnil(L); - return 1; - } - Source* src = new SDLSource((void*)&b, b.size()); - if (src == nullptr) - { - luax_errorf(L, "Failed to decode source file %s", f); - luax_pushnil(L); - return 1; - } - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Source, new Shared(src)); - return 1; - } - - LUA_IMPLEMENT int l_destroy(lua_State* L) - { - Audio* audio = Audio::get(); - audio->quit(); - return 0; - } - - LUA_EXPORT int luaopen_audio(lua_State* L) - { - luaopen_Source(L); - - luaL_Reg methods[] = { - { "init", l_init }, - { "play", l_play }, - { "stop", l_stop }, - { "pause", l_pause }, - { "resume", l_resume }, - { "setVolume", l_setVolume }, - { "newSource", l_newSource }, - { "destroy", l_destroy }, - { 0, 0 } - }; - luax_newlib(L, methods); - return 1; - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/audio/je_lua_audio.h b/src/libjin-lua/modules/audio/je_lua_audio.h deleted file mode 100644 index 6b4669a..0000000 --- a/src/libjin-lua/modules/audio/je_lua_audio.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __JE_LUA_AUDIO_H__ -#define __JE_LUA_AUDIO_H__ - -#include "je_lua_audio.h" - -namespace JinEngine -{ - namespace Lua - { - - int luaopen_audio(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/audio/je_lua_source.cpp b/src/libjin-lua/modules/audio/je_lua_source.cpp deleted file mode 100644 index 8c9e247..0000000 --- a/src/libjin-lua/modules/audio/je_lua_source.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include "libjin/jin.h" -#include "common/je_lua.h" -#include "common/je_lua_common.h" - -using namespace JinEngine::Audio; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_Source = "Source"; - - LUA_IMPLEMENT inline Source* checkSource(lua_State* L) - { - LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Source); - Source* source = luaObj->getObject(); - return source; - } - - LUA_IMPLEMENT int l_play(lua_State* L) - { - Source* source = checkSource(L); - source->play(); - return 0; - } - - LUA_IMPLEMENT int l_stop(lua_State* L) - { - Source* source = checkSource(L); - source->stop(); - return 0; - } - - LUA_IMPLEMENT int l_pause(lua_State* L) - { - Source* source = checkSource(L); - source->pause(); - return 0; - } - - LUA_IMPLEMENT int l_rewind(lua_State* L) - { - Source* source = checkSource(L); - source->rewind(); - return 0; - } - - LUA_IMPLEMENT int l_resume(lua_State* L) - { - Source* source = checkSource(L); - source->resume(); - return 0; - } - - LUA_IMPLEMENT int l_isStop(lua_State* L) - { - Source* source = checkSource(L); - bool isStop = source->isStopped(); - luax_pushboolean(L, isStop); - return 1; - } - - LUA_IMPLEMENT int l_isPaused(lua_State* L) - { - Source* source = checkSource(L); - bool isPaused = source->isPaused(); - luax_pushboolean(L, isPaused); - return 1; - } - - LUA_IMPLEMENT int l_setVolume(lua_State* L) - { - Source* source = checkSource(L); - float volume = luax_checknumber(L, 2); - source->setVolume(volume); - return 0; - } - - LUA_IMPLEMENT int l_setLoop(lua_State* L) - { - Source* source = checkSource(L); - bool loop = luax_checkbool(L, 2); - source->setLoop(loop); - return 0; - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Source); - luaObj->release(); - return 0; - } - - LUA_EXPORT void luaopen_Source(lua_State* L) - { - luaL_Reg methods[] = { - { "__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 } - }; - luax_newtype(L, Jin_Lua_Source, methods); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/audio/je_lua_source.h b/src/libjin-lua/modules/audio/je_lua_source.h deleted file mode 100644 index f7e6b48..0000000 --- a/src/libjin-lua/modules/audio/je_lua_source.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __JE_LUA_SOURCE_H__ -#define __JE_LUA_SOURCE_H__ - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_Source; - - void luaopen_Source(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/audio/l_audio.cpp b/src/libjin-lua/modules/audio/l_audio.cpp new file mode 100644 index 0000000..9ad4228 --- /dev/null +++ b/src/libjin-lua/modules/audio/l_audio.cpp @@ -0,0 +1,132 @@ +#include "common/je_lua.h" +#include "common/l_common.h" +#include "libjin/jin.h" +#include "l_source.h" + +using namespace JinEngine::Audio; +using namespace JinEngine::Audio::SDL; +using namespace JinEngine::Filesystem; + +namespace JinEngine +{ + namespace Lua + { + + typedef SDLAudio Audio; + typedef SDLSource Source; + + struct + { + bool initialized = false; + } context; + + LUA_IMPLEMENT int l_init(lua_State* L) + { + if (context.initialized) + { + // Already initialized. + luax_pushboolean(L, true); + return 1; + } + Audio::Setting setting; + setting.samplerate = 44100; + setting.samples = 44100; + Audio* audio = Audio::get(); + context.initialized = audio->start(&setting); + if (!context.initialized) + { + luax_error(L, "could not init audio"); + luax_pushboolean(L, false); + return 1; + } + luax_pushboolean(L, true); + return 1; + } + + LUA_IMPLEMENT int l_play(lua_State* L) + { + Audio::get()->play(); + return 0; + } + + LUA_IMPLEMENT int l_stop(lua_State* L) + { + Audio::get()->stop(); + return 0; + } + + LUA_IMPLEMENT int l_pause(lua_State* L) + { + Audio::get()->pause(); + return 0; + } + + LUA_IMPLEMENT int l_resume(lua_State* L) + { + Audio::get()->resume(); + return 0; + } + + LUA_IMPLEMENT int l_setVolume(lua_State* L) + { + float volume = luax_checknumber(L, 1); + Audio::get()->setVolume(volume); + return 0; + } + + LUA_IMPLEMENT int l_newSource(lua_State* L) + { + AssetDatabase* fs = AssetDatabase::get(); + const char* f = luax_checkstring(L, 1); + Buffer b; + try + { + if (!fs->exists(f)) + throw Exception("No such source file %s.", f); + fs->read(f, b); + } + catch (Exception& e) + { + luax_errorf(L, "Failed to read source file %s", f); + luax_pushnil(L); + return 1; + } + Source* src = new SDLSource((void*)&b, b.size()); + if (src == nullptr) + { + luax_errorf(L, "Failed to decode source file %s", f); + luax_pushnil(L); + return 1; + } + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Source, new Shared(src)); + return 1; + } + + LUA_IMPLEMENT int l_destroy(lua_State* L) + { + Audio* audio = Audio::get(); + audio->quit(); + return 0; + } + + LUA_EXPORT int luaopen_audio(lua_State* L) + { + luaopen_Source(L); + + luaL_Reg methods[] = { + { "init", l_init }, + { "play", l_play }, + { "stop", l_stop }, + { "pause", l_pause }, + { "resume", l_resume }, + { "setVolume", l_setVolume }, + { "newSource", l_newSource }, + { "destroy", l_destroy }, + { 0, 0 } + }; + luax_newlib(L, methods); + return 1; + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/audio/l_audio.h b/src/libjin-lua/modules/audio/l_audio.h new file mode 100644 index 0000000..c025fdf --- /dev/null +++ b/src/libjin-lua/modules/audio/l_audio.h @@ -0,0 +1,16 @@ +#ifndef __JE_LUA_AUDIO_H__ +#define __JE_LUA_AUDIO_H__ + +#include "l_audio.h" + +namespace JinEngine +{ + namespace Lua + { + + int luaopen_audio(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/audio/l_source.cpp b/src/libjin-lua/modules/audio/l_source.cpp new file mode 100644 index 0000000..72af871 --- /dev/null +++ b/src/libjin-lua/modules/audio/l_source.cpp @@ -0,0 +1,114 @@ +#include "libjin/jin.h" +#include "common/je_lua.h" +#include "common/l_common.h" + +using namespace JinEngine::Audio; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_Source = "Source"; + + LUA_IMPLEMENT inline Source* checkSource(lua_State* L) + { + LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Source); + Source* source = luaObj->getObject(); + return source; + } + + LUA_IMPLEMENT int l_play(lua_State* L) + { + Source* source = checkSource(L); + source->play(); + return 0; + } + + LUA_IMPLEMENT int l_stop(lua_State* L) + { + Source* source = checkSource(L); + source->stop(); + return 0; + } + + LUA_IMPLEMENT int l_pause(lua_State* L) + { + Source* source = checkSource(L); + source->pause(); + return 0; + } + + LUA_IMPLEMENT int l_rewind(lua_State* L) + { + Source* source = checkSource(L); + source->rewind(); + return 0; + } + + LUA_IMPLEMENT int l_resume(lua_State* L) + { + Source* source = checkSource(L); + source->resume(); + return 0; + } + + LUA_IMPLEMENT int l_isStop(lua_State* L) + { + Source* source = checkSource(L); + bool isStop = source->isStopped(); + luax_pushboolean(L, isStop); + return 1; + } + + LUA_IMPLEMENT int l_isPaused(lua_State* L) + { + Source* source = checkSource(L); + bool isPaused = source->isPaused(); + luax_pushboolean(L, isPaused); + return 1; + } + + LUA_IMPLEMENT int l_setVolume(lua_State* L) + { + Source* source = checkSource(L); + float volume = luax_checknumber(L, 2); + source->setVolume(volume); + return 0; + } + + LUA_IMPLEMENT int l_setLoop(lua_State* L) + { + Source* source = checkSource(L); + bool loop = luax_checkbool(L, 2); + source->setLoop(loop); + return 0; + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Source); + luaObj->release(); + return 0; + } + + LUA_EXPORT void luaopen_Source(lua_State* L) + { + luaL_Reg methods[] = { + { "__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 } + }; + luax_newtype(L, Jin_Lua_Source, methods); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/audio/l_source.h b/src/libjin-lua/modules/audio/l_source.h new file mode 100644 index 0000000..f7e6b48 --- /dev/null +++ b/src/libjin-lua/modules/audio/l_source.h @@ -0,0 +1,16 @@ +#ifndef __JE_LUA_SOURCE_H__ +#define __JE_LUA_SOURCE_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Source; + + void luaopen_Source(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/bit/je_lua_bit.cpp b/src/libjin-lua/modules/bit/je_lua_bit.cpp deleted file mode 100644 index 9484743..0000000 --- a/src/libjin-lua/modules/bit/je_lua_bit.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "common/je_lua_common.h" -#include "common/je_lua.h" -#include "libjin/jin.h" - -#include - -namespace JinEngine -{ - namespace Lua - { - - LUA_IMPLEMENT int l_and(lua_State* L) - { - int a = luax_checkinteger(L, 1); - int b = luax_checkinteger(L, 2); - luax_pushinteger(L, a & b); - return 1; - } - - LUA_IMPLEMENT int l_or(lua_State* L) - { - int a = luax_checkinteger(L, 1); - int b = luax_checkinteger(L, 2); - luax_pushinteger(L, a | b); - return 1; - } - - LUA_IMPLEMENT int l_xor(lua_State* L) - { - int a = luax_checkinteger(L, 1); - int b = luax_checkinteger(L, 2); - luax_pushinteger(L, a ^ b); - return 1; - } - - LUA_IMPLEMENT int l_not(lua_State* L) - { - int n = luax_checkinteger(L, 1); - luax_pushinteger(L, ~n); - return 1; - } - - LUA_IMPLEMENT int l_lshift(lua_State* L) - { - int a = luax_checkinteger(L, 1); - int b = luax_checkinteger(L, 2); - luax_pushinteger(L, a << b); - return 1; - } - - LUA_IMPLEMENT int l_rshift(lua_State* L) - { - int a = luax_checkinteger(L, 1); - int b = luax_checkinteger(L, 2); - luax_pushinteger(L, a >> b); - return 1; - } - - LUA_IMPLEMENT int l_include(lua_State* L) - { - int a = luax_checkinteger(L, 1); - int b = luax_checkinteger(L, 2); - luax_pushboolean(L, (a & b) == b); - return 1; - } - - LUA_EXPORT int luaopen_bit(lua_State* L) - { - luaL_Reg methods[] = { - { "bAnd", l_and }, - { "bOr" , l_or }, - { "bXor", l_xor }, - { "bNot", l_not }, - { "bLs", l_lshift }, - { "bRs", l_rshift }, - { "bInc", l_include }, - { 0, 0 } - }; - - luax_newlib(L, methods); - - return 1; - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/bit/je_lua_bit.h b/src/libjin-lua/modules/bit/je_lua_bit.h deleted file mode 100644 index 21cf064..0000000 --- a/src/libjin-lua/modules/bit/je_lua_bit.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __JE_LUA_BIT_H__ -#define __JE_LUA_BIT_H__ - -namespace JinEngine -{ - namespace Lua - { - - int luaopen_bit(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/bit/l_bit.cpp b/src/libjin-lua/modules/bit/l_bit.cpp new file mode 100644 index 0000000..43be892 --- /dev/null +++ b/src/libjin-lua/modules/bit/l_bit.cpp @@ -0,0 +1,86 @@ +#include "common/l_common.h" +#include "common/je_lua.h" +#include "libjin/jin.h" + +#include + +namespace JinEngine +{ + namespace Lua + { + + LUA_IMPLEMENT int l_and(lua_State* L) + { + int a = luax_checkinteger(L, 1); + int b = luax_checkinteger(L, 2); + luax_pushinteger(L, a & b); + return 1; + } + + LUA_IMPLEMENT int l_or(lua_State* L) + { + int a = luax_checkinteger(L, 1); + int b = luax_checkinteger(L, 2); + luax_pushinteger(L, a | b); + return 1; + } + + LUA_IMPLEMENT int l_xor(lua_State* L) + { + int a = luax_checkinteger(L, 1); + int b = luax_checkinteger(L, 2); + luax_pushinteger(L, a ^ b); + return 1; + } + + LUA_IMPLEMENT int l_not(lua_State* L) + { + int n = luax_checkinteger(L, 1); + luax_pushinteger(L, ~n); + return 1; + } + + LUA_IMPLEMENT int l_lshift(lua_State* L) + { + int a = luax_checkinteger(L, 1); + int b = luax_checkinteger(L, 2); + luax_pushinteger(L, a << b); + return 1; + } + + LUA_IMPLEMENT int l_rshift(lua_State* L) + { + int a = luax_checkinteger(L, 1); + int b = luax_checkinteger(L, 2); + luax_pushinteger(L, a >> b); + return 1; + } + + LUA_IMPLEMENT int l_include(lua_State* L) + { + int a = luax_checkinteger(L, 1); + int b = luax_checkinteger(L, 2); + luax_pushboolean(L, (a & b) == b); + return 1; + } + + LUA_EXPORT int luaopen_bit(lua_State* L) + { + luaL_Reg methods[] = { + { "bAnd", l_and }, + { "bOr" , l_or }, + { "bXor", l_xor }, + { "bNot", l_not }, + { "bLs", l_lshift }, + { "bRs", l_rshift }, + { "bInc", l_include }, + { 0, 0 } + }; + + luax_newlib(L, methods); + + return 1; + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/bit/l_bit.h b/src/libjin-lua/modules/bit/l_bit.h new file mode 100644 index 0000000..21cf064 --- /dev/null +++ b/src/libjin-lua/modules/bit/l_bit.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_BIT_H__ +#define __JE_LUA_BIT_H__ + +namespace JinEngine +{ + namespace Lua + { + + int luaopen_bit(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/core/je_lua_core.cpp b/src/libjin-lua/modules/core/je_lua_core.cpp deleted file mode 100644 index 956ffbe..0000000 --- a/src/libjin-lua/modules/core/je_lua_core.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "common/je_lua_common.h" -#include "common/je_lua.h" -#include "libjin/jin.h" - -using namespace JinEngine::Game; - -namespace JinEngine -{ - namespace Lua - { - - LUA_IMPLEMENT int l_running(lua_State* L) - { - static Application* app = Application::get(); - bool running = app->running(); - luax_pushboolean(L, running); - return 1; - } - - LUA_IMPLEMENT int l_stop(lua_State* L) - { - Application::get()->stop(); - return 0; - } - - LUA_IMPLEMENT int l_quit(lua_State* L) - { - Application::get()->quit(); - return 0; - } - - LUA_EXPORT int luaopen_core(lua_State* L) - { - luaL_Reg methods[] = { - { "running", l_running }, - { "stop", l_stop }, - { "quit", l_quit }, - { 0, 0 } - }; - luax_newlib(L, methods); - - return 1; - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/core/je_lua_core.h b/src/libjin-lua/modules/core/je_lua_core.h deleted file mode 100644 index 037ac4b..0000000 --- a/src/libjin-lua/modules/core/je_lua_core.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __JE_LUA_CORE_H__ -#define __JE_LUA_CORE_H__ - -namespace JinEngine -{ - namespace Lua - { - - int luaopen_core(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/core/l_core.cpp b/src/libjin-lua/modules/core/l_core.cpp new file mode 100644 index 0000000..68b8156 --- /dev/null +++ b/src/libjin-lua/modules/core/l_core.cpp @@ -0,0 +1,46 @@ +#include "common/l_common.h" +#include "common/je_lua.h" +#include "libjin/jin.h" + +using namespace JinEngine::Game; + +namespace JinEngine +{ + namespace Lua + { + + LUA_IMPLEMENT int l_running(lua_State* L) + { + static Application* app = Application::get(); + bool running = app->running(); + luax_pushboolean(L, running); + return 1; + } + + LUA_IMPLEMENT int l_stop(lua_State* L) + { + Application::get()->stop(); + return 0; + } + + LUA_IMPLEMENT int l_quit(lua_State* L) + { + Application::get()->quit(); + return 0; + } + + LUA_EXPORT int luaopen_core(lua_State* L) + { + luaL_Reg methods[] = { + { "running", l_running }, + { "stop", l_stop }, + { "quit", l_quit }, + { 0, 0 } + }; + luax_newlib(L, methods); + + return 1; + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/core/l_core.h b/src/libjin-lua/modules/core/l_core.h new file mode 100644 index 0000000..037ac4b --- /dev/null +++ b/src/libjin-lua/modules/core/l_core.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_CORE_H__ +#define __JE_LUA_CORE_H__ + +namespace JinEngine +{ + namespace Lua + { + + int luaopen_core(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/event/je_lua_event.cpp b/src/libjin-lua/modules/event/je_lua_event.cpp deleted file mode 100644 index 8a550d6..0000000 --- a/src/libjin-lua/modules/event/je_lua_event.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/** -* Event module -*/ -#include "common/je_lua_common.h" -#include "common/je_lua.h" -#include "libjin/jin.h" - -using namespace JinEngine; -using namespace JinEngine::Input; - -namespace JinEngine -{ - namespace Lua - { - - /** - * Load event poll, return a iterator(a table). - */ - LUA_IMPLEMENT int l_event_poll(lua_State *L) - { - /* table to store events */ - luax_newtable(L); - static Event e; - int i = 1; - poll: - while (pollEvent(&e)) - { - /** - * TODO: 窗口大小改变时要更改transform - * - */ - luax_newtable(L); - switch (e.type) - { - case EventType::QUIT: - luax_setfieldstring(L, "type", "Quit"); - break; - - case EventType::KEY_DOWN: - case EventType::KEY_UP: - luax_setfieldstring(L, "type", e.type == EventType::KEY_DOWN ? "KeyDown" : "KeyUp"); - luax_setfieldstring(L, "key", getKeyName(e.key.keysym.sym)); - break; - - case EventType::MOUSE_MOTION: - luax_setfieldstring(L, "type", "MouseMotion"); - luax_setfieldnumber(L, "x", e.motion.x); - luax_setfieldnumber(L, "y", e.motion.y); - break; - - case EventType::MOUSE_BUTTON_DOWN: - case EventType::MOUSE_BUTTON_UP: - luax_setfieldstring(L, "type", e.type == EventType::MOUSE_BUTTON_DOWN ? "MouseButtonDown" : "MouseButtonUp"); - luax_setfieldstring(L, "button", getButtonName(e.button.button)); - luax_setfieldnumber(L, "x", e.button.x); - luax_setfieldnumber(L, "y", e.button.y); - break; - - case EventType::MOUSE_WHEEL: - luax_setfieldstring(L, "type", "Wheel"); - if(e.wheel.x == -1) - luax_setfieldstring(L, "x", "Left"); - else if(e.wheel.x == 1) - luax_setfieldstring(L, "x", "Right"); - else - luax_setfieldstring(L, "x", "None"); - if (e.wheel.y == -1) - luax_setfieldstring(L, "y", "Near"); - else if (e.wheel.y == 1) - luax_setfieldstring(L, "y", "Far"); - else - luax_setfieldstring(L, "y", "None"); - break; - - case EventType::JOYBUTTONDOWN: - case EventType::JOYBUTTONUP: - luax_setfieldstring(L, "type", e.type == EventType::JOYBUTTONDOWN ? "JoyButtonDown" : "JoyButtonUp"); - luax_setfieldinteger(L, "which", e.jbutton.which); - luax_setfieldstring(L, "button", Input::getJoyButtonName(e.jbutton.button)); - break; - - case EventType::JOYAXISMOTION: - luax_setfieldstring(L, "type", "JoyAxisMotion"); - luax_setfieldinteger(L, "which", e.jaxis.which); - luax_setfieldfstring(L, "axis", Input::getJoyAxisName(e.jaxis.axis)); - break; - - case EventType::JOYBALLMOTION: - case EventType::JOYHATMOTION: - - case EventType::JOYDEVICEADDED: - case EventType::JOYDEVICEREMOVED: - luax_setfieldfstring(L, "type", e.type == EventType::JOYDEVICEADDED ? "JoyDeviceAdded" : "JoyDeviceRemoved"); - luax_setfieldinteger(L, "which", e.jdevice.which); - break; - - //https://stackoverflow.com/questions/50022316/what-is-sdl-joystick-and-what-is-sdl-gamecontroller-what-are-the-relationships - case EventType::CONTROLLERBUTTONDOWN: - case EventType::CONTROLLERBUTTONUP: - - - case EventType::CONTROLLERAXISMOTION: - - default: - // Ignore oter events and pop up the event table. - luax_pop(L, 1); - goto poll; - break; - } - luax_rawseti(L, -2, i++); - } - return 1; - } - - /** - * load event module - */ - LUA_EXPORT int luaopen_event(lua_State* L) - { - luaL_Reg methods[] = { - { "poll", l_event_poll }, - { 0, 0 } - }; - luax_newlib(L, methods); - - return 1; - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/event/je_lua_event.h b/src/libjin-lua/modules/event/je_lua_event.h deleted file mode 100644 index 7a75459..0000000 --- a/src/libjin-lua/modules/event/je_lua_event.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __JE_LUA_EVENT_H__ -#define __JE_LUA_EVENT_H__ - -namespace JinEngine -{ - namespace Lua - { - - int luaopen_event(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/event/l_event.cpp b/src/libjin-lua/modules/event/l_event.cpp new file mode 100644 index 0000000..8287238 --- /dev/null +++ b/src/libjin-lua/modules/event/l_event.cpp @@ -0,0 +1,130 @@ +/** +* Event module +*/ +#include "common/l_common.h" +#include "common/je_lua.h" +#include "libjin/jin.h" + +using namespace JinEngine; +using namespace JinEngine::Input; + +namespace JinEngine +{ + namespace Lua + { + + /** + * Load event poll, return a iterator(a table). + */ + LUA_IMPLEMENT int l_event_poll(lua_State *L) + { + /* table to store events */ + luax_newtable(L); + static Event e; + int i = 1; + poll: + while (pollEvent(&e)) + { + /** + * TODO: 窗口大小改变时要更改transform + * + */ + luax_newtable(L); + switch (e.type) + { + case EventType::QUIT: + luax_setfieldstring(L, "type", "Quit"); + break; + + case EventType::KEY_DOWN: + case EventType::KEY_UP: + luax_setfieldstring(L, "type", e.type == EventType::KEY_DOWN ? "KeyDown" : "KeyUp"); + luax_setfieldstring(L, "key", getKeyName(e.key.keysym.sym)); + break; + + case EventType::MOUSE_MOTION: + luax_setfieldstring(L, "type", "MouseMotion"); + luax_setfieldnumber(L, "x", e.motion.x); + luax_setfieldnumber(L, "y", e.motion.y); + break; + + case EventType::MOUSE_BUTTON_DOWN: + case EventType::MOUSE_BUTTON_UP: + luax_setfieldstring(L, "type", e.type == EventType::MOUSE_BUTTON_DOWN ? "MouseButtonDown" : "MouseButtonUp"); + luax_setfieldstring(L, "button", getButtonName(e.button.button)); + luax_setfieldnumber(L, "x", e.button.x); + luax_setfieldnumber(L, "y", e.button.y); + break; + + case EventType::MOUSE_WHEEL: + luax_setfieldstring(L, "type", "Wheel"); + if(e.wheel.x == -1) + luax_setfieldstring(L, "x", "Left"); + else if(e.wheel.x == 1) + luax_setfieldstring(L, "x", "Right"); + else + luax_setfieldstring(L, "x", "None"); + if (e.wheel.y == -1) + luax_setfieldstring(L, "y", "Near"); + else if (e.wheel.y == 1) + luax_setfieldstring(L, "y", "Far"); + else + luax_setfieldstring(L, "y", "None"); + break; + + case EventType::JOYBUTTONDOWN: + case EventType::JOYBUTTONUP: + luax_setfieldstring(L, "type", e.type == EventType::JOYBUTTONDOWN ? "JoyButtonDown" : "JoyButtonUp"); + luax_setfieldinteger(L, "which", e.jbutton.which); + luax_setfieldstring(L, "button", Input::getJoyButtonName(e.jbutton.button)); + break; + + case EventType::JOYAXISMOTION: + luax_setfieldstring(L, "type", "JoyAxisMotion"); + luax_setfieldinteger(L, "which", e.jaxis.which); + luax_setfieldfstring(L, "axis", Input::getJoyAxisName(e.jaxis.axis)); + break; + + case EventType::JOYBALLMOTION: + case EventType::JOYHATMOTION: + + case EventType::JOYDEVICEADDED: + case EventType::JOYDEVICEREMOVED: + luax_setfieldfstring(L, "type", e.type == EventType::JOYDEVICEADDED ? "JoyDeviceAdded" : "JoyDeviceRemoved"); + luax_setfieldinteger(L, "which", e.jdevice.which); + break; + + //https://stackoverflow.com/questions/50022316/what-is-sdl-joystick-and-what-is-sdl-gamecontroller-what-are-the-relationships + case EventType::CONTROLLERBUTTONDOWN: + case EventType::CONTROLLERBUTTONUP: + + + case EventType::CONTROLLERAXISMOTION: + + default: + // Ignore oter events and pop up the event table. + luax_pop(L, 1); + goto poll; + break; + } + luax_rawseti(L, -2, i++); + } + return 1; + } + + /** + * load event module + */ + LUA_EXPORT int luaopen_event(lua_State* L) + { + luaL_Reg methods[] = { + { "poll", l_event_poll }, + { 0, 0 } + }; + luax_newlib(L, methods); + + return 1; + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/event/l_event.h b/src/libjin-lua/modules/event/l_event.h new file mode 100644 index 0000000..7a75459 --- /dev/null +++ b/src/libjin-lua/modules/event/l_event.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_EVENT_H__ +#define __JE_LUA_EVENT_H__ + +namespace JinEngine +{ + namespace Lua + { + + int luaopen_event(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/filesystem/je_lua_filesystem.cpp b/src/libjin-lua/modules/filesystem/je_lua_filesystem.cpp deleted file mode 100644 index e73d1ad..0000000 --- a/src/libjin-lua/modules/filesystem/je_lua_filesystem.cpp +++ /dev/null @@ -1,140 +0,0 @@ -#include "common/je_lua_common.h" -#include "common/je_lua.h" -#include "libjin/jin.h" -#include - -using namespace JinEngine::Filesystem; - -namespace JinEngine -{ - namespace Lua - { - - LUA_IMPLEMENT struct - { - AssetDatabase* fs; - } context; - - LUA_IMPLEMENT int l_init(lua_State* L) - { - context.fs = AssetDatabase::get(); - return 0; - } - - LUA_IMPLEMENT int l_mount(lua_State* L) - { - const char* path = luax_checkstring(L, 1); - context.fs->mount(path); - return 0; - } - - LUA_IMPLEMENT int l_exist(lua_State * L) - { - const char* path = luax_checkstring(L, 1); - int r = context.fs->exists(path); - luax_pushboolean(L, r); - return 1; - } - - LUA_IMPLEMENT int l_isDir(lua_State* L) - { - const char* path = luax_checkstring(L, 1); - int r = context.fs->isDir(path); - luax_pushboolean(L, r); - return 1; - } - - LUA_IMPLEMENT int l_isFile(lua_State* L) - { - const char* path = luax_checkstring(L, 1); - int r = context.fs->isFile(path); - luax_pushboolean(L, r); - return 1; - } - - LUA_IMPLEMENT int loadbuffer(lua_State* L) - { - const char* filename = lua_tostring(L, -1); - Buffer bf; - context.fs->read(filename, bf); - luax_loadbuffer(L, (const char*)&bf, bf.size(), filename); - return 1; - } - - LUA_IMPLEMENT int loader(lua_State* L) - { - const char * filename = lua_tostring(L, -1); - - std::string tmp(filename); - tmp += ".lua"; - - int size = tmp.size(); - - for (int i = 0; iexists(tmp.c_str())) - { - lua_pop(L, 1); - lua_pushstring(L, tmp.c_str()); - return loadbuffer(L); - } - - tmp = filename; - size = tmp.size(); - for (int i = 0; iisDir(tmp.c_str())) - { - tmp += "/init.lua"; - if (context.fs->exists(tmp.c_str())) - { - lua_pop(L, 1); - lua_pushstring(L, tmp.c_str()); - return loadbuffer(L); - } - } - - lua_pushfstring(L, "\n\tno file \"%s\" in jin game directories.\n", (tmp + ".lua").c_str()); - return 1; - } - - LUA_IMPLEMENT int l_read(lua_State* L) - { - AssetDatabase* fs = context.fs; - const char* file = luax_checkstring(L, 1); - unsigned int len; - Buffer buffer; - fs->read(file, buffer); - luax_pushstring(L, (char*)&buffer); - luax_pushinteger(L, buffer.size()); - return 2; - } - - LUA_EXPORT int luaopen_filesystem(lua_State* L) - { - luaL_Reg methods[] = { - { "init", l_init }, - { "mount", l_mount }, - { "isDirectory", l_isDir }, - { "isFile", l_isFile }, - { "exist", l_exist }, - { "read", l_read }, - { 0, 0 } - }; - luax_newlib(L, methods); - luax_registersearcher(L, loader, 1); - return 0; - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/filesystem/je_lua_filesystem.h b/src/libjin-lua/modules/filesystem/je_lua_filesystem.h deleted file mode 100644 index 1e1ff23..0000000 --- a/src/libjin-lua/modules/filesystem/je_lua_filesystem.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __JE_LUA_FILESYSTEM_H__ -#define __JE_LUA_FILESYSTEM_H__ - -namespace JinEngine -{ - namespace Lua - { - - int luaopen_filesystem(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/filesystem/l_filesystem.cpp b/src/libjin-lua/modules/filesystem/l_filesystem.cpp new file mode 100644 index 0000000..b297c8d --- /dev/null +++ b/src/libjin-lua/modules/filesystem/l_filesystem.cpp @@ -0,0 +1,140 @@ +#include "common/l_common.h" +#include "common/je_lua.h" +#include "libjin/jin.h" +#include + +using namespace JinEngine::Filesystem; + +namespace JinEngine +{ + namespace Lua + { + + LUA_IMPLEMENT struct + { + AssetDatabase* fs; + } context; + + LUA_IMPLEMENT int l_init(lua_State* L) + { + context.fs = AssetDatabase::get(); + return 0; + } + + LUA_IMPLEMENT int l_mount(lua_State* L) + { + const char* path = luax_checkstring(L, 1); + context.fs->mount(path); + return 0; + } + + LUA_IMPLEMENT int l_exist(lua_State * L) + { + const char* path = luax_checkstring(L, 1); + int r = context.fs->exists(path); + luax_pushboolean(L, r); + return 1; + } + + LUA_IMPLEMENT int l_isDir(lua_State* L) + { + const char* path = luax_checkstring(L, 1); + int r = context.fs->isDir(path); + luax_pushboolean(L, r); + return 1; + } + + LUA_IMPLEMENT int l_isFile(lua_State* L) + { + const char* path = luax_checkstring(L, 1); + int r = context.fs->isFile(path); + luax_pushboolean(L, r); + return 1; + } + + LUA_IMPLEMENT int loadbuffer(lua_State* L) + { + const char* filename = lua_tostring(L, -1); + Buffer bf; + context.fs->read(filename, bf); + luax_loadbuffer(L, (const char*)&bf, bf.size(), filename); + return 1; + } + + LUA_IMPLEMENT int loader(lua_State* L) + { + const char * filename = lua_tostring(L, -1); + + std::string tmp(filename); + tmp += ".lua"; + + int size = tmp.size(); + + for (int i = 0; iexists(tmp.c_str())) + { + lua_pop(L, 1); + lua_pushstring(L, tmp.c_str()); + return loadbuffer(L); + } + + tmp = filename; + size = tmp.size(); + for (int i = 0; iisDir(tmp.c_str())) + { + tmp += "/init.lua"; + if (context.fs->exists(tmp.c_str())) + { + lua_pop(L, 1); + lua_pushstring(L, tmp.c_str()); + return loadbuffer(L); + } + } + + lua_pushfstring(L, "\n\tno file \"%s\" in jin game directories.\n", (tmp + ".lua").c_str()); + return 1; + } + + LUA_IMPLEMENT int l_read(lua_State* L) + { + AssetDatabase* fs = context.fs; + const char* file = luax_checkstring(L, 1); + unsigned int len; + Buffer buffer; + fs->read(file, buffer); + luax_pushstring(L, (char*)&buffer); + luax_pushinteger(L, buffer.size()); + return 2; + } + + LUA_EXPORT int luaopen_filesystem(lua_State* L) + { + luaL_Reg methods[] = { + { "init", l_init }, + { "mount", l_mount }, + { "isDirectory", l_isDir }, + { "isFile", l_isFile }, + { "exist", l_exist }, + { "read", l_read }, + { 0, 0 } + }; + luax_newlib(L, methods); + luax_registersearcher(L, loader, 1); + return 0; + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/filesystem/l_filesystem.h b/src/libjin-lua/modules/filesystem/l_filesystem.h new file mode 100644 index 0000000..1e1ff23 --- /dev/null +++ b/src/libjin-lua/modules/filesystem/l_filesystem.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_FILESYSTEM_H__ +#define __JE_LUA_FILESYSTEM_H__ + +namespace JinEngine +{ + namespace Lua + { + + int luaopen_filesystem(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_animation.cpp b/src/libjin-lua/modules/graphics/je_lua_animation.cpp deleted file mode 100644 index 5cd3b1f..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_animation.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include "libjin/jin.h" - -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" - -#include "je_lua_sprite.h" -#include "je_lua_canvas.h" -#include "je_lua_texture.h" -#include "je_lua_shader.h" -#include "je_lua_animation.h" - -using namespace JinEngine::Math; -using namespace JinEngine::Graphics; -using namespace JinEngine::Graphics::Shaders; -using namespace JinEngine::Graphics::Animations; - -namespace JinEngine -{ - namespace Lua - { - const char* Jin_Lua_Animation = "Animation"; - - LUA_IMPLEMENT inline Animation* checkAnimation(lua_State* L) - { - LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Animation); - return luaObj->getObject(); - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - p->release(); - return 0; - } - - // addFrame(frame) - LUA_IMPLEMENT int l_addFrame(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - Animation* animation = luaObj->getObject(); - LuaObject* luaSprite = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Sprite); - Sprite* sprite = luaSprite->getObject(); - animation->addFrame(sprite); - int i = animation->getFrameCount() - 1; - luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + i, luaSprite); - return 0; - } - - // addFrames(frames table) - LUA_IMPLEMENT int l_addFrames(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - Animation* shrAnimation = luaObj->getObject(); - if (!luax_istable(L, 2)) - { - luax_typerror(L, 2, "sprites table"); - return 1; - } - int n = luax_tableidxlen(L, 2); - for (int i = 1; i <= n; ++i) - { - luax_rawgeti(L, 2, i); - LuaObject* luaSprite = (LuaObject*)luax_checktype(L, -1, Jin_Lua_Sprite); - Sprite* sprite = luaSprite->getObject(); - shrAnimation->addFrame(sprite); - int index = shrAnimation->getFrameCount() - 1; - luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + index, luaSprite); - } - return 0; - } - - LUA_IMPLEMENT int l_isLoop(lua_State* L) - { - Animation* shrAnimation = checkAnimation(L); - bool loop = shrAnimation->isLoop(); - luax_pushboolean(L, loop); - return 1; - } - - LUA_IMPLEMENT int l_getSpeed(lua_State* L) - { - Animation* shrAnimation = checkAnimation(L); - float speed = shrAnimation->getSpeed(); - luax_pushnumber(L, speed); - return 1; - } - - LUA_IMPLEMENT int l_getFrame(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - Animation* shrAnimation = luaObj->getObject(); - int i = luax_checkinteger(L, 2); - LuaObject* frame = luaObj->getDependency((int)AnimationDependency::DEP_SPRITES + i); - luax_getobject(L, frame); - return 1; - } - - LUA_IMPLEMENT int getFrameCount(lua_State* L) - { - Animation* shrAnimation = checkAnimation(L); - int n = shrAnimation->getFrameCount(); - luax_pushinteger(L, n); - return 1; - } - - LUA_EXPORT void luaopen_Animation(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "addFrame", l_addFrame }, - { "addFrames", l_addFrames }, - { "isLoop", l_isLoop }, - { "getSpeed", l_getSpeed }, - { "getFrameCount", getFrameCount }, - { "getFrame", l_getFrame }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Animation, methods); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_animation.h b/src/libjin-lua/modules/graphics/je_lua_animation.h deleted file mode 100644 index 1b32ec3..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_animation.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef __JE_LUA_ANIMATION_H__ -#define __JE_LUA_ANIMATION_H__ - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_Animation; - - /// - /// - /// - enum class AnimationDependency - { - DEP_SPRITES = 1 ///< Index from 1 - }; - - void luaopen_Animation(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_animator.cpp b/src/libjin-lua/modules/graphics/je_lua_animator.cpp deleted file mode 100644 index 94c61b5..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_animator.cpp +++ /dev/null @@ -1,163 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" - -#include "je_lua_sprite.h" -#include "je_lua_canvas.h" -#include "je_lua_texture.h" -#include "je_lua_shader.h" -#include "je_lua_animator.h" -#include "je_lua_animation.h" - -using namespace JinEngine::Math; -using namespace JinEngine::Graphics; -using namespace JinEngine::Graphics::Shaders; -using namespace JinEngine::Graphics::Animations; - -namespace JinEngine -{ - namespace Lua - { - const char* Jin_Lua_Animator = "Animator"; - - LUA_IMPLEMENT inline Animator* checkAnimator(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animator); - return luaObj->getObject(); - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* obj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - obj->release(); - return 0; - } - - LUA_IMPLEMENT int l_update(lua_State* L) - { - Animator* animator = checkAnimator(L); - float dt = luax_checknumber(L, 2); - animator->update(dt); - return 0; - } - - LUA_IMPLEMENT int l_play(lua_State* L) - { - Animator* animator = checkAnimator(L); - animator->play(); - return 0; - } - - LUA_IMPLEMENT int l_pause(lua_State* L) - { - Animator* animator = checkAnimator(L); - animator->pause(); - return 0; - } - - LUA_IMPLEMENT int l_resume(lua_State* L) - { - Animator* animator = checkAnimator(L); - animator->resume(); - return 0; - } - - LUA_IMPLEMENT int l_rewind(lua_State* L) - { - Animator* animator = checkAnimator(L); - animator->rewind(); - return 0; - } - - LUA_IMPLEMENT int l_render(lua_State* L) - { - Animator* animator = checkAnimator(L); - float x = luax_checknumber(L, 2); - float y = luax_checknumber(L, 3); - float sx = luax_checknumber(L, 4); - float sy = luax_checknumber(L, 5); - float r = luax_checknumber(L, 6); - animator->render(x, y, sx, sy, r); - return 0; - } - - LUA_IMPLEMENT int l_setAnimation(lua_State* L) - { - LuaObject* luaAnimator = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animator); - Animator* animator = luaAnimator->getObject(); - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, luaObj); - animator->setAnimation(luaObj->getObject()); - return 0; - } - - LUA_IMPLEMENT int l_forceToFrame(lua_State* L) - { - Animator* shrAnimator = checkAnimator(L); - int index = luax_checkinteger(L, 2); - shrAnimator->forceToFrame(index); - return 0; - } - - LUA_IMPLEMENT int l_setSpeed(lua_State* L) - { - Animator* shrAnimator = checkAnimator(L); - float fps = luax_checknumber(L, 2); - shrAnimator->setSpeed(fps); - return 0; - } - - LUA_IMPLEMENT int l_setDefaultSpeed(lua_State* L) - { - Animator* shrAnimator = checkAnimator(L); - shrAnimator->setDefaultSpeed(); - return 0; - } - - LUA_IMPLEMENT int l_setLoop(lua_State* L) - { - Animator* shrAnimator = checkAnimator(L); - bool loop = luax_checkbool(L, 2); - shrAnimator->setLoop(loop); - return 0; - } - - LUA_IMPLEMENT int l_setDefaultLoop(lua_State* L) - { - Animator* shrAnimator = checkAnimator(L); - shrAnimator->setDefaultLoop(); - return 0; - } - - LUA_IMPLEMENT int l_getSpeed(lua_State* L) - { - Animator* shrAnimator = checkAnimator(L); - float speed = shrAnimator->getSpeed(); - luax_pushnumber(L, speed); - return 1; - } - - LUA_EXPORT void luaopen_Animator(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "update", l_update }, - { "play", l_play }, - { "pause", l_pause }, - { "resume", l_resume }, - { "rewind", l_rewind }, - { "render", l_render }, - { "setAnimation", l_setAnimation }, - { "forceToFrame", l_forceToFrame }, - { "setSpeed", l_setSpeed }, - { "setDefaultSpeed", l_setDefaultSpeed }, - { "setLoop", l_setLoop }, - { "setDefaultLoop", l_setDefaultLoop }, - { "getSpeed", l_getSpeed }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Animator, methods); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_animator.h b/src/libjin-lua/modules/graphics/je_lua_animator.h deleted file mode 100644 index 0292a77..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_animator.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __JE_LUA_ANIMATOR_H__ -#define __JE_LUA_ANIMATOR_H__ - -#include "libjin/jin.h" - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_Animator; - - enum class AnimatorDependency - { - DEP_ANIMATION = 1 - }; - - void luaopen_Animator(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_bitmap.cpp b/src/libjin-lua/modules/graphics/je_lua_bitmap.cpp deleted file mode 100644 index 553c786..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_bitmap.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include "common/je_lua_common.h" -#include "common/je_lua_object.h" - -#include "libjin/jin.h" -#include "je_lua_bitmap.h" - -using namespace JinEngine::Graphics; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_Bitmap = "Bitmap"; - - LUA_IMPLEMENT inline Bitmap* checkBitmap(lua_State* L) - { - LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Bitmap); - return luaObj->getObject(); - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap); - luaObj->release(); - return 0; - } - - LUA_IMPLEMENT int l_getWidth(lua_State* L) - { - Bitmap* bitmap = checkBitmap(L); - int w = bitmap->getWidth(); - luax_pushinteger(L, w); - return 1; - } - - LUA_IMPLEMENT int l_getHeight(lua_State* L) - { - Bitmap* bitmap = checkBitmap(L); - int h = bitmap->getHeight(); - luax_pushinteger(L, h); - return 1; - } - - LUA_IMPLEMENT int l_getSize(lua_State* L) - { - Bitmap* bitmap = checkBitmap(L); - int w = bitmap->getWidth(); - int h = bitmap->getHeight(); - luax_pushinteger(L, w); - luax_pushinteger(L, h); - return 2; - } - - LUA_IMPLEMENT int l_getPixel(lua_State* L) - { - Bitmap* bitmap = checkBitmap(L); - int x = luax_checkinteger(L, 2); - int y = luax_checkinteger(L, 3); - Color col = bitmap->getPixel(x, y); - luax_pushinteger(L, col.r); - luax_pushinteger(L, col.g); - luax_pushinteger(L, col.b); - luax_pushinteger(L, col.a); - return 4; - } - - LUA_IMPLEMENT int l_setPixel(lua_State* L) - { - Bitmap* bitmap = checkBitmap(L); - int x = luax_checkinteger(L, 2); - int y = luax_checkinteger(L, 3); - if (!luax_istable(L, 4)) - { - luax_typerror(L, 4, "table"); - return 1; - } - unsigned int r = luax_rawgetnumber(L, 4, 1); - unsigned int g = luax_rawgetnumber(L, 4, 2); - unsigned int b = luax_rawgetnumber(L, 4, 3); - unsigned int a = luax_rawgetnumber(L, 4, 4); - bitmap->setPixel(Color(r, g, b, a), x, y); - return 0; - } - - LUA_IMPLEMENT int l_clone(lua_State* L) - { - Bitmap* bitmap = checkBitmap(L); - Bitmap* b = bitmap->clone(); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(b)); - return 1; - } - - LUA_EXPORT void luaopen_Bitmap(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "getWidth", l_getWidth }, - { "getHeight", l_getHeight }, - { "getSize", l_getSize }, - { "getPixel", l_getPixel }, - { "setPixel", l_setPixel }, - { "clone", l_clone }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Bitmap, methods); - } - - } // namespace Graphics -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_bitmap.h b/src/libjin-lua/modules/graphics/je_lua_bitmap.h deleted file mode 100644 index b463d83..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_bitmap.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __JE_LUA_BITMAP_H__ -#define __JE_LUA_BITMAP_H__ - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_Bitmap; - - void luaopen_Bitmap(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_canvas.cpp b/src/libjin-lua/modules/graphics/je_lua_canvas.cpp deleted file mode 100644 index 97b3c96..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_canvas.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" -#include "je_lua_canvas.h" - -using namespace JinEngine::Graphics; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_Canvas = "Canvas"; - - LUA_IMPLEMENT inline Canvas* checkCanvas(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Canvas); - return luaObj->getObject(); - } - - LUA_IMPLEMENT int l_getWidth(lua_State* L) - { - Canvas* canvas = checkCanvas(L); - luax_pushnumber(L, canvas->getWidth()); - return 1; - } - - LUA_IMPLEMENT int l_getHeight(lua_State* L) - { - Canvas* canvas = checkCanvas(L); - luax_pushnumber(L, canvas->getHeight()); - return 1; - } - - LUA_IMPLEMENT int l_getSize(lua_State* L) - { - Canvas* canvas = checkCanvas(L); - luax_pushnumber(L, canvas->getWidth()); - luax_pushnumber(L, canvas->getHeight()); - return 2; - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Canvas); - luaObj->release(); - return 0; - } - - LUA_EXPORT void luaopen_Canvas(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "getWidth", l_getWidth }, - { "getHeight", l_getHeight }, - { "getSize", l_getSize }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Canvas, methods); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_canvas.h b/src/libjin-lua/modules/graphics/je_lua_canvas.h deleted file mode 100644 index d1fa885..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_canvas.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __JE_LUA_CANVAS_H__ -#define __JE_LUA_CANVAS_H__ - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_Canvas; - - void luaopen_Canvas(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_graphics.cpp b/src/libjin-lua/modules/graphics/je_lua_graphics.cpp deleted file mode 100644 index 96577f5..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_graphics.cpp +++ /dev/null @@ -1,1112 +0,0 @@ -#include -#include - -#include "libjin/jin.h" -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" - -#include "je_lua_canvas.h" -#include "je_lua_sprite.h" -#include "je_lua_spritesheet.h" -#include "je_lua_bitmap.h" -#include "je_lua_mesh.h" -#include "je_lua_ttf.h" -#include "je_lua_ttf_data.h" -#include "je_lua_texture.h" -#include "je_lua_shader.h" -#include "je_lua_text.h" -#include "je_lua_texture_font.h" -#include "je_lua_page.h" -#include "je_lua_sprite.h" -#include "je_lua_animation.h" -#include "je_lua_animator.h" -#include "je_lua_particle_system.h" - -using namespace std; -using namespace JinEngine; -using namespace JinEngine::Math; -using namespace JinEngine::Graphics; -using namespace JinEngine::Graphics::Fonts; -using namespace JinEngine::Graphics::Shaders; -using namespace JinEngine::Graphics::Animations; -using namespace JinEngine::Graphics::Particles; -using namespace JinEngine::Filesystem; - -namespace JinEngine -{ - namespace Lua - { - - #include "../../resources/font.ttf.h" - - static struct - { - Color curRenderColor; - Color curClearColor; - Font* defaultFont = nullptr; - bool initialized = false; - } context; - - LUA_IMPLEMENT int l_init(lua_State* L) - { - if (context.initialized) - { - luax_pushboolean(L, true); - return 1; - } - - Window* wnd = Window::get(); - Window::Setting setting; - setting.width = luax_getfieldinteger(L, 1, "width"); - setting.height = luax_getfieldinteger(L, 1, "height"); - setting.title = luax_getfieldstring(L, 1, "title"); - setting.icon = luax_getfieldstring(L, 1, "icon"); - setting.vsync = luax_getfieldbool(L, 1, "vsync"); - setting.fullscreen = luax_getfieldbool(L, 1, "fullscreen"); - setting.resizable = luax_getfieldbool(L, 1, "resizable"); - context.initialized = wnd->start(&setting); - if (!context.initialized) - { - luax_pushboolean(L, context.initialized); - return 1; - } - - /* load default font */ - Bitmap* bitmap = new Bitmap(default_font_bitmap, sizeof(default_font_bitmap)); - TextureFont* tf = new TextureFont(bitmap, Text(Encode::UTF8, default_charset), default_font_split, bitmap->getHeight()); - delete bitmap; - context.defaultFont = tf; - gl.setFont(tf); - - luax_pushboolean(L, context.initialized); - return 1; - } - - LUA_IMPLEMENT int l_setTitle(lua_State* L) - { - Window* wnd = Window::get(); - const char* title = luax_checkstring(L, 1); - wnd->setTitle(title); - return 0; - } - - LUA_IMPLEMENT int l_destroy(lua_State* L) - { - Window* wnd = Window::get(); - wnd->quit(); - return 0; - } - - LUA_IMPLEMENT int l_showWindow(lua_State* L) - { - Window* wnd = Window::get(); - wnd->show(); - return 0; - } - - LUA_IMPLEMENT int l_hideWindow(lua_State* L) - { - Window* wnd = Window::get(); - wnd->hide(); - return 0; - } - - LUA_IMPLEMENT int l_getSize(lua_State* L) - { - Window* wnd = Window::get(); - luax_pushnumber(L, wnd->getW()); - luax_pushnumber(L, wnd->getH()); - return 2; - } - - LUA_IMPLEMENT int l_getWidth(lua_State* L) - { - Window* wnd = Window::get(); - luax_pushnumber(L, wnd->getW()); - return 1; - } - - LUA_IMPLEMENT int l_getHeight(lua_State* L) - { - Window* wnd = Window::get(); - luax_pushnumber(L, wnd->getH()); - return 1; - } - - LUA_IMPLEMENT int l_newBitmap(lua_State* L) - { - Bitmap* bitmap = nullptr; - if (luax_gettop(L) == 2) - { - int w = luax_checkinteger(L, 1); - int h = luax_checkinteger(L, 2); - bitmap = new Bitmap(w, h); - } - else if (luax_gettop(L) == 3) - { - int w = luax_checkinteger(L, 1); - int h = luax_checkinteger(L, 2); - if (luax_istable(L, 3)) - { - 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 = new Bitmap(w, h, Color(r, g, b, a)); - } - else if (luax_isfunction(L, 3)) - { - std::function 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 = new Bitmap(w, h, drawer); - } - else - { - luax_typerror(L, 3, "color table or color setter"); - return 1; - } - } - else - { - const char* f = luax_checkstring(L, 1); - AssetDatabase* fs = AssetDatabase::get(); - Buffer b; - try - { - if (!fs->exists(f)) - throw Exception("No such image file %s.", f); - fs->read(f, b); - } - catch (Exception& e) - { - luax_errorf(L, "Failed to read image %s", f); - luax_pushnil(L); - return 1; - } - bitmap = new Bitmap(&b, b.size()); - if (bitmap == nullptr) - { - luax_errorf(L, "Failed to decode image file %s", f); - luax_pushnil(L); - return 1; - } - } - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(bitmap)); - return 1; - } - - /* jin.graphics.newTexture(bitmap) */ - LUA_IMPLEMENT int l_newTexture(lua_State* L) - { - Texture* texture = nullptr; - if (luax_istype(L, 1, Jin_Lua_Bitmap)) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap); - Bitmap* bitmap = luaObj->getObject(); - texture = new Texture(bitmap); - } - else if (luax_isstring(L, 1)) - { - const char* path = luax_checkstring(L, 1); - texture = new Texture(path); - } - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Texture, new Shared(texture)); - return 1; - } - - // See embed graphics.lua. - LUA_IMPLEMENT int l_newShader(lua_State* L) - { - const char* program = luax_checkstring(L, 1); - Shader* jsl = nullptr; - try - { - jsl = new Shader(program); - } - catch (JinEngine::Exception& e) - { - //luax_errorf(L, "Failed to compile shader"); - luax_pushnil(L); - return 1; - } - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared(jsl)); - return 1; - } - - // See embed graphics.lua - LUA_IMPLEMENT int l_newShaderf(lua_State* L) - { - const char* path = luax_checkstring(L, 1); - AssetDatabase* fs = AssetDatabase::get(); - if (!fs->exists(path)) - { - //luax_errorf(L, "No such shader file \"%s\"", path); - luax_pushnil(L); - return 1; - } - Buffer b; - fs->read(path, b); - Shader* jsl = nullptr; - try - { - jsl = new Shader((char*)&b); - } - catch (JinEngine::Exception& e) - { - //luax_errorf(L, "Failed to compile shader"); - luax_pushnil(L); - return 1; - } - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared(jsl)); - return 1; - } - - LUA_IMPLEMENT int l_newCanvas(lua_State* L) - { - int w = luax_checknumber(L, 1); - int h = luax_checknumber(L, 2); - Canvas* cvs = new Canvas(w, h); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Canvas, new Shared(cvs)); - return 1; - } - - LUA_IMPLEMENT int l_clear(lua_State* L) - { - glClear(GL_COLOR_BUFFER_BIT); - return 0; - } - - LUA_IMPLEMENT int l_setClearColor(lua_State* L) - { - if (luax_gettop(L) == 0) - { - glClearColor(0, 0, 0, 1); - return 0; - } - - context.curClearColor.r = luax_checknumber(L, 1); - context.curClearColor.g = luax_checknumber(L, 2); - context.curClearColor.b = luax_checknumber(L, 3); - context.curClearColor.a = luax_checknumber(L, 4); - - gl.setClearColor(context.curClearColor.r, - context.curClearColor.g, - context.curClearColor.b, - context.curClearColor.a); - return 0; - } - - LUA_IMPLEMENT int l_present(lua_State* L) - { - Window::get()->present(); - return 0; - } - - LUA_IMPLEMENT void l_draw_texture(lua_State* L) - { - if (!luax_istype(L, 1, Jin_Lua_Texture)) - return; - int x = luax_optnumber(L, 2, 0); - int y = luax_optnumber(L, 3, 0); - float sx = luax_optnumber(L, 4, 1); - float sy = luax_optnumber(L, 5, 1); - float r = luax_optnumber(L, 6, 0); - float ox = luax_optnumber(L, 7, 0); - float oy = luax_optnumber(L, 8, 0); - LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1); - Texture* tex = luaObj->getObject(); - tex->render(x, y, sx, sy, r, ox, oy); - } - - LUA_IMPLEMENT void l_draw_canvas(lua_State* L) - { - if (!luax_istype(L, 1, Jin_Lua_Canvas)) - return; - int x = luax_optnumber(L, 2, 0); - int y = luax_optnumber(L, 3, 0); - float sx = luax_optnumber(L, 4, 1); - float sy = luax_optnumber(L, 5, 1); - float r = luax_optnumber(L, 6, 0); - float ox = luax_optnumber(L, 7, 0); - float oy = luax_optnumber(L, 8, 0); - LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1); - Canvas* canvas = luaObj->getObject(); - canvas->render(x, y, sx, sy, r, ox, oy); - } - - /* jin.graphics.draw(text, font, x, y) */ - LUA_IMPLEMENT void l_draw_text(lua_State* L) - { - if (!luax_istype(L, 1, Jin_Lua_Text)) - return; - LuaObject* p = (LuaObject*)luax_toudata(L, 1); - Text* text = p->getObject(); - int x = luax_optnumber(L, 3, 0); - int y = luax_optnumber(L, 4, 0); - int spacing = luax_optnumber(L, 6, 0); - Font* font = nullptr; - LuaObject* p2 = (LuaObject*)luax_toudata(L, 2); - if (luax_istype(L, 2, Jin_Lua_TextureFont)) - { - TextureFont* tf = p2->getObject(); - font = tf; - } - else if (luax_istype(L, 2, Jin_Lua_TTF)) - { - TTF* ttf = p2->getObject(); - font = ttf; - } - else - { - font = context.defaultFont; - } - int lineheight = luax_optnumber(L, 5, font->getFontSize()); - font->render(*text, x, y, lineheight, spacing); - } - - /* jin.graphics.draw(page, x, y) */ - LUA_IMPLEMENT void l_draw_page(lua_State* L) - { - if (!luax_istype(L, 1, Jin_Lua_Page)) - return; - int x = luax_optnumber(L, 2, 0); - int y = luax_optnumber(L, 3, 0); - LuaObject* p = (LuaObject*)luax_toudata(L, 1); - Page* page = p->getObject(); - Font* font = page->font; - font->render(page, x, y); - } - - LUA_IMPLEMENT void l_draw_sprite(lua_State* L) - { - if (!luax_istype(L, 1, Jin_Lua_Sprite)) - return; - LuaObject* luaSprite = (LuaObject*)luax_toudata(L, 1); - Sprite* sprite = luaSprite->getObject(); - float x = luax_checknumber(L, 2); - float y = luax_checknumber(L, 3); - float sx = luax_checknumber(L, 4); - float sy = luax_checknumber(L, 5); - float r = luax_checknumber(L, 6); - sprite->render(x, y, sx, sy, r); - } - - LUA_IMPLEMENT void l_draw_mesh(lua_State* L) - { - if (!luax_istype(L, 1, Jin_Lua_Mesh)) - return; - LuaObject* obj= (LuaObject*)luax_toudata(L, 1); - Mesh* mesh = obj->getObject(); - int x = luax_optnumber(L, 2, 0); - int y = luax_optnumber(L, 3, 0); - float sx = luax_optnumber(L, 4, 1); - float sy = luax_optnumber(L, 5, 1); - float r = luax_optnumber(L, 6, 0); - float ox = luax_optnumber(L, 7, 0); - float oy = luax_optnumber(L, 8, 0); - mesh->render(x, y, sx, sy, r, ox, oy); - } - - LUA_IMPLEMENT int l_draw(lua_State* L) - { - if (luax_istype(L, 1, Jin_Lua_Texture)) - l_draw_texture(L); - else if (luax_istype(L, 1, Jin_Lua_Canvas)) - l_draw_canvas(L); - else if (luax_istype(L, 1, Jin_Lua_Text)) - l_draw_text(L); - else if (luax_istype(L, 1, Jin_Lua_Page)) - l_draw_page(L); - else if (luax_istype(L, 1, Jin_Lua_Sprite)) - l_draw_sprite(L); - else if (luax_istype(L, 1, Jin_Lua_Mesh)) - l_draw_mesh(L); - else - { - luax_typerror(L, 1, "texture or canvas"); - return 1; - } - return 0; - } - - // draw(tex, quad, x, y, sx, sy, r, ax, ay) - LUA_IMPLEMENT int l_drawq(lua_State* L) - { - if (!luax_istable(L, 2)) - { - luax_typerror(L, 2, "table"); - return 1; - } - Math::Quad q; - q.x = luax_rawgetnumber(L, 2, 1); - q.y = luax_rawgetnumber(L, 2, 2); - q.w = luax_rawgetnumber(L, 2, 3); - q.h = luax_rawgetnumber(L, 2, 4); - luax_pop(L, 4); - int x = luax_optnumber(L, 3, 0); - int y = luax_optnumber(L, 4, 0); - float sx = luax_optnumber(L, 5, 1); - float sy = luax_optnumber(L, 6, 1); - float r = luax_optnumber(L, 7, 0); - float ox = luax_optnumber(L, 8, 0); - float oy = luax_optnumber(L, 9, 0); - - if (luax_istype(L, 1, Jin_Lua_Texture)) - { - LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1); - Texture* tex = luaObj->getObject(); - tex->render(q, x, y, sx, sy, r, ox, oy); - } - else if (luax_istype(L, 1, Jin_Lua_Canvas)) - { - LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1); - Canvas* canvas = luaObj->getObject(); - canvas->render(q, x, y, sx, sy, r, ox, oy); - } - else - { - luax_typerror(L, 1, "texture or canvas"); - return 1; - } - return 0; - } - - /* print(string, x, y, lineheight, spacing) */ - /* need set font */ - LUA_IMPLEMENT int l_print(lua_State* L) - { - Font* font = gl.getFont(); - if (font == nullptr) - return 0; - unsigned length; - const char* str = luax_checklstring(L, 1, &length); - Text text(Encode::UTF8, str, length); - int x = luax_optnumber(L, 2, 0); - int y = luax_optnumber(L, 3, 0); - int lineheight = luax_optnumber(L, 4, font->getFontSize()); - int spacing = luax_optnumber(L, 5, 0); - font->render(text, x, y, lineheight, spacing); - return 0; - } - - LUA_IMPLEMENT int l_setColor(lua_State* L) - { - if (luax_gettop(L) == 0) - { - gl.setColor(Color(255, 255, 255, 255)); - return 0; - } - - context.curRenderColor.r = luax_checknumber(L, 1); - context.curRenderColor.g = luax_checknumber(L, 2); - context.curRenderColor.b = luax_checknumber(L, 3); - if (luax_gettop(L) == 4) - context.curRenderColor.a = luax_checknumber(L, 4); - else - context.curRenderColor.a = 255; - gl.setColor(context.curRenderColor); - return 0; - } - - LUA_IMPLEMENT int l_getColor(lua_State * L) - { - luax_pushnumber(L, context.curRenderColor.r); - luax_pushnumber(L, context.curRenderColor.g); - luax_pushnumber(L, context.curRenderColor.b); - luax_pushnumber(L, context.curRenderColor.a); - return 4; - } - - LUA_IMPLEMENT int l_bindCanvas(lua_State* L) - { - if (luax_gettop(L) == 0) - { - // bind to default canvas - gl.unbindCanvas(); - return 0; - } - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Canvas); - Canvas* canvas = luaObj->getObject(); - gl.bindCanvas(canvas); - return 0; - } - - LUA_IMPLEMENT int l_unbindCanvas(lua_State* L) - { - gl.unbindCanvas(); - return 0; - } - - LUA_IMPLEMENT int l_useShader(lua_State* L) - { - if (luax_gettop(L) == 0) - { - gl.unuseShader(); - return 0; - } - if (luax_istype(L, 1, Jin_Lua_Shader)) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Shader); - Shader* shader = luaObj->getObject(); - gl.useShader(shader); - } - else - { - luax_typerror(L, 1, "JSL shader"); - } - return 0; - } - - LUA_IMPLEMENT int l_setBlendMode(lua_State* L) - { - int mode = luax_checkinteger(L, 1); - gl.setBlendMode(static_cast(mode)); - return 0; - } - - LUA_IMPLEMENT int l_getBlendMode(lua_State* L) - { - int mode = static_cast(gl.getBlendMode()); - luax_pushinteger(L, mode); - return 1; - } - - LUA_IMPLEMENT int l_point(lua_State* L) - { - int x = luax_checknumber(L, 1); - int y = luax_checknumber(L, 2); - JinEngine::Graphics::point(x, y); - - return 0; - } - - LUA_IMPLEMENT int l_line(lua_State* L) - { - int x1 = luax_checknumber(L, 1); - int y1 = luax_checknumber(L, 2); - int x2 = luax_checknumber(L, 3); - int y2 = luax_checknumber(L, 4); - JinEngine::Graphics::line(x1, y1, x2, y2); - - return 0; - } - - LUA_IMPLEMENT int l_rect(lua_State* L) - { - RenderMode mode = static_cast(luax_checkinteger(L, 1)); - if (mode != RenderMode::NONE) - { - int x = luax_checknumber(L, 2); - int y = luax_checknumber(L, 3); - int w = luax_checknumber(L, 4); - int h = luax_checknumber(L, 5); - rect(mode, x, y, w, h); - } - else - { - luax_typerror(L, 1, "'fill' or 'line'"); - return 1; - } - - return 0; - } - - LUA_IMPLEMENT int l_circle(lua_State* L) - { - RenderMode mode = static_cast(luax_checkinteger(L, 1)); - if (mode != RenderMode::NONE) - { - int x = luax_checknumber(L, 2); - int y = luax_checknumber(L, 3); - float r = luax_checknumber(L, 4); - circle(mode, x, y, r); - } - else - { - luax_typerror(L, 1, "'fill' or 'line'"); - return 1; - } - - return 0; - } - - LUA_IMPLEMENT int l_triangle(lua_State* L) - { - RenderMode mode = static_cast(luax_checkinteger(L, 1)); - if (mode != RenderMode::NONE) - { - int x = luax_checknumber(L, 2); - int y = luax_checknumber(L, 3); - - int x2 = luax_checknumber(L, 3); - int y2 = luax_checknumber(L, 4); - - int x3 = luax_checknumber(L, 5); - int y3 = luax_checknumber(L, 6); - - triangle(mode, x, y, x2, y2, x3, y3); - } - else - { - luax_typerror(L, 1, "'fill' or 'line'"); - return 1; - } - - return 0; - } - - LUA_IMPLEMENT int l_polygon(lua_State* L) - { - RenderMode mode = static_cast(luax_checkinteger(L, 1)); - int n = luax_checknumber(L, 2); - if (mode != RenderMode::NONE) - { - if (!luax_istable(L, 3)) - { - luax_typerror(L, 3, "table"); - return 1; - } - int tn = luax_tableidxlen(L, 3); - if (tn != n * 2) - { - 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); - return 1; - } - float* p = (float*)alloca(2 * n * sizeof(float)); - for (int i = 1; i <= 2 * n; ++i) - p[i - 1] = luax_rawgetnumber(L, 3, i); - polygon(mode, p, n); - } - else - { - luax_typerror(L, 1, "'fill' or 'line'"); - return 1; - } - - return 0; - } - - LUA_IMPLEMENT int l_newTTFData(lua_State* L) - { - TTFData* fd = nullptr; - { - const char* path = luax_checkstring(L, 1); - AssetDatabase* fs = AssetDatabase::get(); - if (!fs->exists(path)) - { - luax_errorf(L, "No such font \"%s\"", path); - luax_pushnil(L); - return 1; - } - Buffer b; - fs->read(path, b); - fd = new TTFData(&b, b.size()); - } - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TTFData, new Shared(fd)); - return 1; - } - - /* newText(str[, encode]) */ - LUA_IMPLEMENT int l_newText(lua_State* L) - { - Encode encode = Encode::UTF8; - if (luax_gettop(L) == 2) - { - const char* e = luax_checkstring(L, 2); - if (strcmp(e, "UTF8") == 0) encode = Encode::UTF8; - //else if (strcmp(e, "UTF16") == 0) encode = Encode::UTF16; - else if (strcmp(e, "ASCII") == 0) encode = Encode::ASCII; - else - { - luax_error(L, "wrong text encode %s", e); - return 0; - } - } - unsigned length; - const char* data = luax_checklstring(L, 1, &length); - Text* text = new Text(encode, data, length); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Text, new Shared(text)); - return 1; - } - - // newSprite(Texture tex, Quad quad, Origin origin) - // newSprite(Texture tex, Quad quad, Number ox, Number oy) - // newSprite(Texture tex, Origin origin) - // newSprite(Texture tex, Number ox, Number oy) - LUA_IMPLEMENT int l_newSprite(lua_State* L) - { - int n = luax_gettop(L); - LuaObject* objGraphic = nullptr; - if (luax_istype(L, 1, Jin_Lua_Texture)) - objGraphic = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Texture); - else if (luax_istype(L, 1, Jin_Lua_Canvas)) - objGraphic = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Canvas); - Graphic* graphic = objGraphic->getObject(); - if (objGraphic != nullptr) - { - if (n == 3 && luax_istable(L, 2)) - { - Quad quad; - quad.x = luax_rawgetnumberthenpop(L, 2, 1); - quad.y = luax_rawgetnumberthenpop(L, 2, 2); - quad.w = luax_rawgetnumberthenpop(L, 2, 3); - quad.h = luax_rawgetnumberthenpop(L, 2, 4); - int o = luax_checkinteger(L, 3); - Origin origin = static_cast(o); - LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, quad, origin))); - p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic); - } - else if (n == 4) - { - Quad quad; - quad.x = luax_rawgetnumberthenpop(L, 2, 1); - quad.y = luax_rawgetnumberthenpop(L, 2, 2); - quad.w = luax_rawgetnumberthenpop(L, 2, 3); - quad.h = luax_rawgetnumberthenpop(L, 2, 4); - int ox = luax_checkinteger(L, 3); - int oy = luax_checkinteger(L, 4); - LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, quad, ox, oy))); - p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic); - } - else if (n == 2) - { - int o = luax_checkinteger(L, 2); - Origin origin = static_cast(o); - LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, origin))); - p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic); - } - else if (n == 3) - { - int ox = luax_checkinteger(L, 2); - int oy = luax_checkinteger(L, 3); - LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, ox, oy))); - p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic); - } - else - { - luax_error(L, "No matched overloaded functions."); - return 1; - } - } - - return 1; - } - - LUA_IMPLEMENT int l_newSpriteSheet(lua_State* L) - { - LuaObject* objGraphic = nullptr; - if (luax_istype(L, 1, Jin_Lua_Texture)) - objGraphic = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Texture); - else if(luax_istype(L, 1, Jin_Lua_Canvas)) - objGraphic = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Canvas); - if (objGraphic != nullptr) - { - Graphic* graphic = objGraphic->getObject(); - Shared* shrSSheet = new Shared(new SpriteSheet(graphic)); - LuaObject* luaSSheet = luax_newinstance(L, Jin_Lua_SpriteSheet, shrSSheet); - luaSSheet->setDependency((int)SpriteSheetDependency::DEP_GRAPHIC, objGraphic); - return 1; - } - else - return 0; - } - - // newAnimation([frames table, loop, speed]) - LUA_IMPLEMENT int l_newAnimation(lua_State* L) - { - int argc = luax_gettop(L); - Animation* animation = new Animation(); - Shared* shrAnimation = new Shared(animation); - LuaObject* luaAnimation = luax_newinstance(L, Jin_Lua_Animation, shrAnimation); - if (argc >= 3) - { - if (!luax_istable(L, 1)) - { - luax_typerror(L, 1, "frames table"); - return 1; - } - bool loop = luax_checkbool(L, 2); - float speed = luax_checknumber(L, 3); - int n = luax_tableidxlen(L, 1); - for (int i = 1; i <= n; ++i) - { - luax_rawgeti(L, 1, i); - LuaObject* luaSprite = (LuaObject*)luax_checktype(L, -1, Jin_Lua_Sprite); - animation->addFrame(luaSprite->getObject()); - int index = animation->getFrameCount() - 1; - luaAnimation->setDependency((int)AnimationDependency::DEP_SPRITES + index, luaSprite); - } - animation->setLoop(loop); - animation->setSpeed(speed); - } - luax_pushvalue(L, argc + 1); - return 1; - } - - // newAnimator([animation]) - LUA_IMPLEMENT int l_newAnimator(lua_State* L) - { - int argc = luax_gettop(L); - Animator* animator = new Animator(); - Shared* shrAniamtor = new Shared(animator); - if (argc >= 1) - { - LuaObject* animation = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - animator->setAnimation(animation->getObject()); - LuaObject* luaAnimator = luax_newinstance(L, Jin_Lua_Animator, shrAniamtor); - luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, animation); - return 1; - } - LuaObject* luaAnimator = luax_newinstance(L, Jin_Lua_Animator, shrAniamtor); - return 1; - } - - /* newTextureFont(bitmap, text, color | cellw, cellh) */ - LUA_IMPLEMENT int l_newTextureFont(lua_State* L) - { - LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap); - Bitmap* bitmap = p->getObject(); - Text* text; - if (luax_istype(L, 2, Jin_Lua_Text)) - { - LuaObject* pt = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Text); - text = pt->getObject(); - } - else if (luax_isstring(L, 2)) - { - unsigned len; - const char* str = luax_checklstring(L, 2, &len); - text = new Text(Encode::UTF8, str, len); - } - else - { - luax_typerror(L, 2, "Text or string"); - return 1; - } - float cellh = luax_checknumber(L, 4); - TextureFont* textureFont = nullptr; - if (luax_istable(L, 3)) - { - 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); - textureFont = new TextureFont(bitmap, *text, Color(r, g, b, a), cellh); - } - else if (luax_isnumber(L, 3)) - { - float cellw = luax_checknumber(L, 3); - textureFont = new TextureFont(bitmap, *text, cellw, cellh); - } - else - { - luax_error(L, "bad arguments #3 to 'newTextureFont', need to be table or number"); - return 0; - } - if (luax_isstring(L, 2)) - { - // Delete temporary text. - delete text; - } - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TextureFont, new Shared(textureFont)); - return 1; - } - - LUA_IMPLEMENT int l_newParticleSystem(lua_State* L) - { - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_ParticleSystem, new Shared(new ParticleSystem())); - return 1; - } - - LUA_IMPLEMENT int l_newMesh(lua_State* L) - { - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Mesh, new Shared(new Mesh())); - return 1; - } - - /* setFont(font) */ - LUA_IMPLEMENT int l_setFont(lua_State* L) - { - if (luax_istype(L, 1, Jin_Lua_TTF)) - { - LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TTF); - TTF* ttf = p->getObject(); - gl.setFont(ttf); - } - else if (luax_istype(L, 1, Jin_Lua_TextureFont)) - { - LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TextureFont); - TextureFont* tf = p->getObject(); - gl.setFont(tf); - } - return 0; - } - - LUA_IMPLEMENT int l_unsetFont(lua_State* L) - { - gl.setFont(context.defaultFont); - return 0; - } - - LUA_IMPLEMENT int l_clearMatrix(lua_State* L) - { - gl.clearMatrix(); - return 0; - } - - LUA_IMPLEMENT int l_pushMatrix(lua_State* L) - { - gl.pushMatrix(); - return 0; - } - - LUA_IMPLEMENT int l_popMatrix(lua_State* L) - { - gl.popMatrix(); - return 0; - } - - LUA_IMPLEMENT int l_scale(lua_State* L) - { - float sx = luax_checknumber(L, 1); - float sy = luax_checknumber(L, 2); - gl.scale(sx, sy); - return 0; - } - - LUA_IMPLEMENT int l_translate(lua_State* L) - { - float x = luax_checknumber(L, 1); - float y = luax_checknumber(L, 2); - gl.translate(x, y); - return 0; - } - - LUA_IMPLEMENT int l_rotate(lua_State* L) - { - float r = luax_checknumber(L, 1); - gl.rotate(r); - return 0; - } - - LUA_IMPLEMENT int l_getStats(lua_State* L) - { - OpenGL::Stats stats = gl.getStats(); - luax_newtable(L); - luax_setfieldinteger(L, "drawCalls", stats.drawCalls); - luax_setfieldinteger(L, "canvasSwitches", stats.canvasSwitches); - luax_setfieldinteger(L, "shaderSwitches", stats.shaderSwitches); - luax_setfieldinteger(L, "fontSwitches", stats.fontSwitches); - luax_setfieldinteger(L, "textures", stats.textures); - luax_setfieldinteger(L, "canvases", stats.canvases); - luax_setfieldinteger(L, "fonts", stats.fonts); - return 1; - } - - LUA_EXPORT int luaopen_graphics(lua_State* L) - { - 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); - luaopen_Animation(L); - luaopen_Animator(L); - luaopen_ParticleSystem(L); - luaopen_Mesh(L); - - luaL_Reg methods[] = { - { "getStats", l_getStats }, - /* window */ - { "init", l_init }, - { "setTitle", l_setTitle }, - { "getSize", l_getSize }, - { "getWidth", l_getWidth }, - { "getHeight", l_getHeight }, - { "destroy", l_destroy }, - { "hideWindow", l_hideWindow }, - { "showWindow", l_showWindow }, - /* creators */ - { "newBitmap", l_newBitmap }, - { "newTexture", l_newTexture }, - { "newShader", l_newShader }, - { "newShaderf", l_newShaderf }, - { "newCanvas", l_newCanvas }, - { "newTTFData", l_newTTFData }, - { "newText", l_newText }, - { "newTextureFont", l_newTextureFont }, - { "newSprite", l_newSprite }, - { "newSpriteSheet", l_newSpriteSheet }, - { "newAnimation", l_newAnimation }, - { "newAnimator", l_newAnimator }, - { "newParticleSystem", l_newParticleSystem }, - { "newMesh", l_newMesh }, - /* render */ - { "setClearColor", l_setClearColor }, - { "clear", l_clear }, - { "draw", l_draw }, - { "print", l_print }, - { "drawq", l_drawq }, - { "setColor", l_setColor }, - { "getColor", l_getColor }, - { "present", l_present }, - { "setBlendMode", l_setBlendMode }, - { "getBlendMode", l_getBlendMode }, - /* canvas */ - { "bindCanvas", l_bindCanvas }, - { "unbindCanvas", l_unbindCanvas }, - /* shader */ - { "useShader", l_useShader }, - /* shapes */ - { "point", l_point }, - { "line", l_line }, - { "rect", l_rect }, - { "circle", l_circle }, - { "triangle", l_triangle }, - { "polygon", l_polygon }, - /* font */ - { "setFont", l_setFont }, - { "unsetFont", l_unsetFont }, - /* transform */ - { "pushMatrix", l_pushMatrix }, - { "clearMatrix", l_clearMatrix }, - { "popMatrix", l_popMatrix }, - { "translate", l_translate }, - { "rotate", l_rotate }, - { "scale", l_scale }, - { 0, 0 } - }; - // Load whole lib. - luax_newlib(L, methods); - return 1; - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_graphics.h b/src/libjin-lua/modules/graphics/je_lua_graphics.h deleted file mode 100644 index 02a2c63..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_graphics.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __JE_LUA_GRAPHICS_H__ -#define __JE_LUA_GRAPHICS_H__ - -namespace JinEngine -{ - namespace Lua - { - - int luaopen_graphics(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_mesh.cpp b/src/libjin-lua/modules/graphics/je_lua_mesh.cpp deleted file mode 100644 index fc42096..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_mesh.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" -#include "je_lua_mesh.h" -#include "je_lua_texture.h" - -using namespace JinEngine::Math; -using namespace JinEngine::Graphics; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_Mesh = "Mesh"; - - LUA_IMPLEMENT inline Mesh* checkMesh(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); - return luaObj->getObject(); - } - - LUA_IMPLEMENT int l_getBound(lua_State* L) - { - Mesh* mesh = checkMesh(L); - BBox bbox = mesh->getBound(); - luax_pushnumber(L, bbox.l); - luax_pushnumber(L, bbox.r); - luax_pushnumber(L, bbox.t); - luax_pushnumber(L, bbox.b); - return 4; - } - - LUA_IMPLEMENT int l_setGraphic(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); - Mesh* mesh = luaObj->getObject(); - luaObj->removeDependency((int)MeshDependency::DEP_GRAPHIC); - LuaObject* obj = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Texture); - mesh->setGraphic(obj->getObject()); - luaObj->setDependency((int)MeshDependency::DEP_GRAPHIC, obj); - return 0; - } - - // x, y, u, v, color_table - LUA_IMPLEMENT int l_pushVertex(lua_State* L) - { - Mesh* mesh = checkMesh(L); - float x = luax_checknumber(L, 2); - float y = luax_checknumber(L, 3); - float u = luax_checknumber(L, 4); - float v = luax_checknumber(L, 5); - if (!luax_istable(L, 6)) - { - luax_typerror(L, 6, "color table"); - return 1; - } - 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); - mesh->pushVertex(x, y, u, v, c); - return 0; - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); - luaObj->release(); - return 0; - } - - LUA_EXPORT void luaopen_Mesh(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "getBound", l_getBound }, - { "setGraphic", l_setGraphic }, - { "pushVertex", l_pushVertex }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Mesh, methods); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_mesh.h b/src/libjin-lua/modules/graphics/je_lua_mesh.h deleted file mode 100644 index b3fa00e..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_mesh.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __JE_LUA_MESH_H__ -#define __JE_LUA_MESH_H__ - -namespace JinEngine -{ - namespace Lua - { - - enum class MeshDependency - { - DEP_GRAPHIC = 1, - }; - - extern const char* Jin_Lua_Mesh; - - void luaopen_Mesh(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_page.cpp b/src/libjin-lua/modules/graphics/je_lua_page.cpp deleted file mode 100644 index 8b4043e..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_page.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include - -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" - -using namespace JinEngine::Graphics; -using namespace JinEngine::Graphics::Fonts; -using namespace JinEngine::Graphics::Shaders; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_Page = "Page"; - - Page* getPage(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Page); - return luaObj->getObject(); - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Page); - luaObj->release(); - return 0; - } - - LUA_IMPLEMENT int l_getSize(lua_State* L) - { - Page* page = getPage(L); - luax_pushinteger(L, page->size.w()); - luax_pushinteger(L, page->size.h()); - return 2; - } - - LUA_IMPLEMENT int l_getWidth(lua_State* L) - { - Page* page = getPage(L); - luax_pushinteger(L, page->size.w()); - return 1; - } - - LUA_IMPLEMENT int l_getHeight(lua_State* L) - { - Page* page = getPage(L); - luax_pushinteger(L, page->size.h()); - return 1; - } - - LUA_EXPORT void luaopen_Page(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "getSize", l_getSize }, - { "getWidth", l_getWidth }, - { "getHeight", l_getHeight }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Page, methods); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_page.h b/src/libjin-lua/modules/graphics/je_lua_page.h deleted file mode 100644 index e4a21a3..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_page.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef __JE_LUA_PAGE_H__ -#define __JE_LUA_PAGE_H__ - -namespace JinEngine -{ - namespace Lua - { - - enum class PageDependency - { - DEP_TTF = 1, - DEP_TEXTURE_FONT = 2, - }; - - extern const char* Jin_Lua_Page; - - void luaopen_Page(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_particle_system.cpp b/src/libjin-lua/modules/graphics/je_lua_particle_system.cpp deleted file mode 100644 index 70511f7..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_particle_system.cpp +++ /dev/null @@ -1,422 +0,0 @@ -#include - -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" - -#include "je_lua_sprite.h" -#include "je_lua_particle_system.h" - -using namespace std; -using namespace JinEngine::Math; -using namespace JinEngine::Graphics; -using namespace JinEngine::Graphics::Particles; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_ParticleSystem = "ParticleSystem"; - - LUA_IMPLEMENT inline ParticleSystem* checkPS(lua_State* L) - { - LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem); - return luaObj->getObject(); - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem); - luaObj->release(); - return 0; - } - - LUA_IMPLEMENT int l_update(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - float dt = luax_checknumber(L, 2); - ps->update(dt); - return 0; - } - - LUA_IMPLEMENT int l_render(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - ps->render(); - return 0; - } - - LUA_IMPLEMENT int l_setPosition(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - float x = luax_checknumber(L, 2); - float y = luax_checknumber(L, 3); - ps->setPosition(x, y); - return 0; - } - - LUA_IMPLEMENT int l_setScale(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - float sx = luax_checknumber(L, 2); - float sy = luax_checknumber(L, 3); - //ps->setScale(sx, sy); - return 0; - } - - LUA_IMPLEMENT int l_pause(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - bool b = luax_checkbool(L, 2); - //ps->pause(b); - return 0; - } - - LUA_IMPLEMENT int l_clear(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - //ps->clear(); - return 0; - } - - LUA_IMPLEMENT int l_setEmitRate(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - if (luax_gettop(L) >= 3) - { - float floor = luax_checknumber(L, 2); - float ceil = luax_checknumber(L, 3); - ps->setEmitRate(floor, ceil); - } - else if (luax_gettop(L) >= 2) - { - float n = luax_checknumber(L, 2); - ps->setEmitRate(n); - } - return 0; - } - - LUA_IMPLEMENT int l_setEmitForce(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - if (luax_gettop(L) >= 3) - { - float floor = luax_checknumber(L, 2); - float ceil = luax_checknumber(L, 3); - ps->setEmitForce(floor, ceil); - } - else if (luax_gettop(L) >= 2) - { - float n = luax_checknumber(L, 2); - ps->setEmitForce(n); - } - return 0; - } - - LUA_IMPLEMENT int l_setEmitDirection(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - if (luax_gettop(L) >= 3) - { - float floor = luax_checknumber(L, 2); - float ceil = luax_checknumber(L, 3); - ps->setEmitDirection(floor, ceil); - } - else if (luax_gettop(L) >= 2) - { - float n = luax_checknumber(L, 2); - ps->setEmitDirection(n); - } - return 0; - } - - LUA_IMPLEMENT int l_setEmitPosition(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - if (luax_gettop(L) >= 3) - { - if (!luax_istable(L, 2)) - { - luax_typerror(L, 2, "table"); - return 1; - } - if (!luax_istable(L, 3)) - { - luax_typerror(L, 3, "table"); - return 1; - } - Vector2 floor, ceil; - floor.x() = luax_rawgetnumber(L, 2, 1); - floor.y() = luax_rawgetnumber(L, 2, 2); - ceil.x() = luax_rawgetnumber(L, 3, 1); - ceil.y() = luax_rawgetnumber(L, 3, 2); - ps->setEmitPosition(floor, ceil); - } - else if (luax_gettop(L) >= 2) - { - if (!luax_istable(L, 2)) - { - luax_typerror(L, 2, "table"); - return 1; - } - Vector2 pos; - pos.x() = luax_rawgetnumber(L, 2, 1); - pos.y() = luax_rawgetnumber(L, 2, 2); - ps->setEmitPosition(pos); - } - return 0; - } - - LUA_IMPLEMENT int l_setParticleLife(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - if (luax_gettop(L) >= 3) - { - float floor = luax_checknumber(L, 2); - float ceil = luax_checknumber(L, 3); - ps->setParticleLife(floor, ceil); - } - else if (luax_gettop(L) >= 2) - { - float n = luax_checknumber(L, 2); - ps->setParticleLife(n); - } - return 0; - } - - LUA_IMPLEMENT int l_setParticleLinearAccelaration(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - if (!luax_istable(L, 2)) - { - luax_typerror(L, 2, "table"); - return 1; - } - Vector2 ac; - ac.x() = luax_rawgetnumber(L, 2, 1); - ac.y() = luax_rawgetnumber(L, 2, 2); - ps->setParticleLinearAccelaration(ac); - return 0; - } - - LUA_IMPLEMENT int l_setParticleRadialAccelaration(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - float ra = luax_checknumber(L, 2); - ps->setParticleRadialAccelaration(ra); - return 0; - } - - LUA_IMPLEMENT int l_setParticleAngularSpeed(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - if (luax_gettop(L) >= 3) - { - float floor = luax_checknumber(L, 2); - float ceil = luax_checknumber(L, 3); - ps->setParticleAngularSpeed(floor, ceil); - } - else if (luax_gettop(L) >= 2) - { - float n = luax_checknumber(L, 2); - ps->setParticleAngularSpeed(n); - } - return 0; - } - - LUA_IMPLEMENT int l_setParticleSpritesMode(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - int n = luax_checkinteger(L, 2); - SpriteMode mode = static_cast(n); - ps->setParticleSpritesMode(mode); - return 0; - } - - LUA_IMPLEMENT int l_addParticleSprite(lua_State* L) - { - LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem); - ParticleSystem* ps = obj->getObject(); - LuaObject* objSpr = luax_checkobject(L, 2, Jin_Lua_Sprite); - Sprite* spr = objSpr->getObject(); - ps->addParticleSprite(spr); - int depn = (*obj).getDependenciesCount(); - (*obj).setDependency((int)ParticleSystemDependency::DEP_SPRITES + depn, objSpr); - return 0; - } - - LUA_IMPLEMENT int l_addParticleSprites(lua_State* L) - { - LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem); - ParticleSystem* ps = obj->getObject(); - if (!luax_istable(L, 2)) - { - luax_typerror(L, 2, "sprites table"); - return 1; - } - int n = luax_tableidxlen(L, 2); - int depn = (*obj).getDependenciesCount(); - for (int i = 1; i <= n; ++i) - { - luax_rawgeti(L, 2, i); - LuaObject* objSpr = luax_checkobject(L, -1, Jin_Lua_Sprite); - luax_pop(L, 1); - Sprite* spr = objSpr->getObject(); - ps->addParticleSprite(spr); - (*obj).setDependency((int)ParticleSystemDependency::DEP_SPRITES + depn + i - 1, objSpr); - } - return 0; - } - - // From 0 - LUA_IMPLEMENT int l_removeParticleSprite(lua_State* L) - { - LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem); - ParticleSystem* ps = obj->getObject(); - int n = luax_checkinteger(L, 2); - ps->removeParticleSprite(n); - (*obj).removeDependency((int)ParticleSystemDependency::DEP_SPRITES + n); - return 0; - } - - LUA_IMPLEMENT int l_enableParticleBlendAdditive(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - bool enable = luax_checkbool(L, 2); - ps->enableParticleBlendAdditive(enable); - return 0; - } - - LUA_IMPLEMENT int l_setParticleScale(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - float scale = luax_checknumber(L, 2); - ps->setParticleScale(scale); - return 0; - } - - LUA_IMPLEMENT int l_addParticleScalePoint(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - float scale = luax_checknumber(L, 2); - float t = luax_checknumber(L, 3); - ps->addParticleScalePoint(scale, t); - return 0; - } - - LUA_IMPLEMENT int l_removeParticleScalePoint(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - int i = luax_checkinteger(L, 2); - ps->removeParticleScalePoint(i); - return 0; - } - - LUA_IMPLEMENT int l_setParticleColor(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - if (!luax_istable(L, 2)) - { - luax_typerror(L, 2, "color table"); - return 1; - } - Color c; - c.r = luax_rawgetnumber(L, 2, 1); - c.g = luax_rawgetnumber(L, 2, 2); - c.b = luax_rawgetnumber(L, 2, 3); - c.a = luax_rawgetnumber(L, 2, 4); - ps->setParticleColor(c); - return 0; - } - - LUA_IMPLEMENT int l_addParticleColorPoint(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - if (!luax_istable(L, 2)) - { - luax_typerror(L, 2, "color table"); - return 1; - } - Color c; - c.r = luax_rawgetnumber(L, 2, 1); - c.g = luax_rawgetnumber(L, 2, 2); - c.b = luax_rawgetnumber(L, 2, 3); - c.a = luax_rawgetnumber(L, 2, 4); - float t = luax_checknumber(L, 3); - ps->addParticleColorPoint(c, t); - return 0; - } - - LUA_IMPLEMENT int l_removeParticleColorPoint(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - int i = luax_checkinteger(L, 2); - ps->removeParticleColorPoint(i); - return 0; - } - - LUA_IMPLEMENT int l_setParticleTransparency(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - float transparency = luax_checknumber(L, 2); - ps->setParticleTransparency(transparency); - return 0; - } - - LUA_IMPLEMENT int l_addParticleTransparencyPoint(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - float transparency = luax_checknumber(L, 2); - float t = luax_checknumber(L, 3); - ps->addParticleTransparencyPoint(transparency, t); - return 0; - } - - LUA_IMPLEMENT int l_removeParticleTransparencyPoint(lua_State* L) - { - ParticleSystem* ps = checkPS(L); - int i = luax_checkinteger(L, 2); - ps->removeParticleTransparencyPoint(i); - return 0; - } - - LUA_EXPORT void luaopen_ParticleSystem(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "update", l_update }, - { "render", l_render }, - { "setPosition", l_setPosition }, - { "setScale", l_setScale }, - { "pause", l_pause }, - { "clear", l_clear }, - { "setEmitRate", l_setEmitRate }, - { "setEmitForce", l_setEmitForce }, - { "setEmitDirection", l_setEmitDirection }, - { "setEmitPosition", l_setEmitPosition }, - { "setParticleLife", l_setParticleLife }, - { "setParticleLinearAccelaration", l_setParticleLinearAccelaration }, - { "setParticleRadialAccelaration", l_setParticleRadialAccelaration }, - { "setParticleAngularSpeed", l_setParticleAngularSpeed }, - { "setParticleSpritesMode", l_setParticleSpritesMode }, - { "addParticleSprite", l_addParticleSprite }, - { "addParticleSprites", l_addParticleSprites }, - { "removeParticleSprite", l_removeParticleSprite }, - { "enableParticleBlendAdditive", l_enableParticleBlendAdditive }, - { "setParticleScale", l_setParticleScale }, - { "addParticleScalePoint", l_addParticleScalePoint }, - { "removeParticleScalePoint", l_removeParticleScalePoint }, - { "setParticleColor", l_setParticleColor }, - { "addParticleColorPoint", l_addParticleColorPoint }, - { "removeParticleColorPoint", l_removeParticleColorPoint }, - { "setParticleTransparency", l_setParticleTransparency }, - { "addParticleTransparencyPoint", l_addParticleTransparencyPoint }, - { "removeParticleTransparencyPoint", l_removeParticleTransparencyPoint }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_ParticleSystem, methods); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_particle_system.h b/src/libjin-lua/modules/graphics/je_lua_particle_system.h deleted file mode 100644 index b75b569..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_particle_system.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __JE_LUA_PARTICLESYSTEM_H__ -#define __JE_LUA_PARTICLESYSTEM_H__ - -namespace JinEngine -{ - namespace Lua - { - - enum class ParticleSystemDependency - { - DEP_SPRITES = 1, - }; - - extern const char* Jin_Lua_ParticleSystem; - - void luaopen_ParticleSystem(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_shader.cpp b/src/libjin-lua/modules/graphics/je_lua_shader.cpp deleted file mode 100644 index 9505444..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_shader.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" - -#include "je_lua_shader.h" -#include "je_lua_canvas.h" -#include "je_lua_texture.h" - -using namespace JinEngine::Graphics; -using namespace JinEngine::Graphics::Shaders; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_Shader = "Shader"; - - static inline Shader* checkShader(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Shader); - return luaObj->getObject(); - } - - /** - * jsl:sendNumber("variable", 0.1) - */ - LUA_IMPLEMENT int l_sendNumber(lua_State* L) - { - Shader* shader = checkShader(L); - const char* variable = luax_checkstring(L, 2); - float number = luax_checknumber(L, 3); - shader->sendFloat(variable, number); - return 0; - } - - LUA_IMPLEMENT int l_sendTexture(lua_State* L) - { - Shader* shader = checkShader(L); - const char* variable = luax_checkstring(L, 2); - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 3, Jin_Lua_Texture); - shader->sendTexture(variable, luaObj->getObject()); - return 0; - } - - LUA_IMPLEMENT int l_sendCanvas(lua_State* L) - { - Shader* shader = checkShader(L); - const char* variable = luax_checkstring(L, 2); - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 3, Jin_Lua_Canvas); - shader->sendCanvas(variable, luaObj->getObject()); - return 0; - } - - LUA_IMPLEMENT int l_sendVec2(lua_State* L) - { - Shader* shader = checkShader(L); - const char* variable = luax_checkstring(L, 2); - if (!luax_istable(L, 3)) - { - luax_typerror(L, 3, "table"); - return 1; - } - float x = luax_rawgetnumber(L, 3, 1); - float y = luax_rawgetnumber(L, 3, 2); - shader->sendVec2(variable, x, y); - return 0; - } - - LUA_IMPLEMENT int l_sendVec3(lua_State* L) - { - Shader* shader = checkShader(L); - const char* variable = luax_checkstring(L, 2); - if (!luax_istable(L, 3)) - { - luax_typerror(L, 3, "table"); - return 1; - } - float x = luax_rawgetnumber(L, 3, 1); - float y = luax_rawgetnumber(L, 3, 2); - float z = luax_rawgetnumber(L, 3, 3); - shader->sendVec3(variable, x, y, z); - return 0; - } - - LUA_IMPLEMENT int l_sendVec4(lua_State* L) - { - Shader* shader = checkShader(L); - const char* variable = luax_checkstring(L, 2); - if (!luax_istable(L, 3)) - { - luax_typerror(L, 3, "table"); - return 1; - } - float x = luax_rawgetnumber(L, 3, 1); - float y = luax_rawgetnumber(L, 3, 2); - float z = luax_rawgetnumber(L, 3, 3); - float w = luax_rawgetnumber(L, 3, 4); - shader->sendVec4(variable, x, y, z, w); - return 0; - } - - LUA_IMPLEMENT int l_sendColor(lua_State* L) - { - return l_sendVec4(L); - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Shader); - luaObj->release(); - return 0; - } - - LUA_EXPORT void luaopen_Shader(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "sendNumber", l_sendNumber }, - { "sendTexture", l_sendTexture }, - { "sendCanvas", l_sendCanvas }, - { "sendVec2", l_sendVec2 }, - { "sendVec3", l_sendVec3 }, - { "sendVec4", l_sendVec4 }, - { "sendColor", l_sendColor }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Shader, methods); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_shader.h b/src/libjin-lua/modules/graphics/je_lua_shader.h deleted file mode 100644 index 5a84372..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_shader.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __JE_LUA_SHDER_H__ -#define __JE_LUA_SHDER_H__ - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_Shader; - - void luaopen_Shader(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_sprite.cpp b/src/libjin-lua/modules/graphics/je_lua_sprite.cpp deleted file mode 100644 index f48e32d..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_sprite.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" - -#include "je_lua_sprite.h" -#include "je_lua_canvas.h" -#include "je_lua_texture.h" -#include "je_lua_shader.h" - -using namespace JinEngine::Math; -using namespace JinEngine::Graphics; -using namespace JinEngine::Graphics::Shaders; - -namespace JinEngine -{ - namespace Lua - { - const char* Jin_Lua_Sprite = "Sprite"; - - LUA_IMPLEMENT inline Sprite* checkSprite(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Sprite); - return luaObj->getObject(); - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Sprite); - p->release(); - return 0; - } - - LUA_IMPLEMENT int l_render(lua_State* L) - { - Sprite* sprite = checkSprite(L); - float x = luax_checknumber(L, 2); - float y = luax_checknumber(L, 3); - float sx = luax_checknumber(L, 4); - float sy = luax_checknumber(L, 5); - float r = luax_checknumber(L, 6); - sprite->render(x, y, sx, sy, r); - return 0; - } - - LUA_IMPLEMENT int l_getSize(lua_State* L) - { - Sprite* sprite = checkSprite(L); - Vector2 size = sprite->getSize(); - luax_pushinteger(L, size.x()); - luax_pushinteger(L, size.y()); - return 1; - } - - LUA_EXPORT void luaopen_Sprite(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "render", l_render }, - { "getSize", l_getSize }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Sprite, methods); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_sprite.h b/src/libjin-lua/modules/graphics/je_lua_sprite.h deleted file mode 100644 index 02c44bf..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_sprite.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef __JE_LUA_SPRITE_H__ -#define __JE_LUA_SPRITE_H__ - -namespace JinEngine -{ - namespace Lua - { - - // Sprite dependency slots. - enum class SpriteDependency - { - DEP_GRAPHIC = 1, - DEP_SHADER = 2, - DEP_SPRITESHEET = 3 - }; - - extern const char* Jin_Lua_Sprite; - - void luaopen_Sprite(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_spritesheet.cpp b/src/libjin-lua/modules/graphics/je_lua_spritesheet.cpp deleted file mode 100644 index a1a2c59..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_spritesheet.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include - -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" -#include "je_lua_sprite.h" -#include "je_lua_spritesheet.h" - -using namespace std; -using namespace JinEngine::Math; -using namespace JinEngine::Graphics; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_SpriteSheet = "SpriteSheet"; - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaSSheet = (LuaObject*)luax_checktype(L, 1, Jin_Lua_SpriteSheet); - luaSSheet->release(); - return 0; - } - - LUA_IMPLEMENT int l_newSprite(lua_State* L) - { - LuaObject* luaSSheet = (LuaObject*)luax_checktype(L, 1, Jin_Lua_SpriteSheet); - SpriteSheet* sheet = luaSSheet->getObject(); - Quad quad; - quad.x = luax_rawgetnumberthenpop(L, 2, 1); - quad.y = luax_rawgetnumberthenpop(L, 2, 2); - quad.w = luax_rawgetnumberthenpop(L, 2, 3); - quad.h = luax_rawgetnumberthenpop(L, 2, 4); - Sprite* spr = nullptr; - if (luax_gettop(L) >= 4) - { - float ox = luax_checknumber(L, 3); - float oy = luax_checknumber(L, 4); - spr = sheet->createSprite(quad, ox, oy); - } - else if (luax_gettop(L) == 3) - { - int o = luax_checkinteger(L, 3); - Origin origin; - origin = static_cast(o); - spr = sheet->createSprite(quad, origin); - } - Shared* shrSprite = new Shared(spr); - LuaObject* luaSprite = luax_newinstance(L, Jin_Lua_Sprite, shrSprite); - luaSprite->setDependency((int)SpriteDependency::DEP_SPRITESHEET, luaSSheet); - return 1; - } - - // {} = newSprites - LUA_IMPLEMENT int l_newSprites(lua_State* L) - { - LuaObject* luaSS = (LuaObject*)luax_checktype(L, 1, Jin_Lua_SpriteSheet); - SpriteSheet* ss = luaSS->getObject(); - int count = luax_checkinteger(L, 2); - int r = luax_checkinteger(L, 3); - int c = luax_checkinteger(L, 4); - int w = luax_checkinteger(L, 5); - int h = luax_checkinteger(L, 6); - vector sprs; - int argc = luax_gettop(L); - if (argc == 6) - { - sprs = ss->createSprites(count, r, c, w, h, Origin::TOPLEFT); - } - else if (argc >= 8) - { - int ox = luax_checkinteger(L, 7); - int oy = luax_checkinteger(L, 8); - int offx = luax_optinteger(L, 9, 0); - int offy = luax_optinteger(L, 10, 0); - sprs = ss->createSprites(count, r, c, w, h, ox, oy, offx, offy); - } - else if (argc >= 7) - { - int o = luax_checkinteger(L, 7); - Origin origin = static_cast(o); - int offx = luax_optinteger(L, 8, 0); - int offy = luax_optinteger(L, 9, 0); - sprs = ss->createSprites(count, r, c, w, h, origin, offx, offy); - } - else - { - luax_error(L, "No matched override function."); - return 1; - } - luax_newtable(L); - LuaObject* graphic = luaSS->getDependency((int)SpriteSheetDependency::DEP_GRAPHIC); - for (int i = 0; i < sprs.size(); ++i) - { - Sprite* spr = sprs[i]; - Shared* shrSpr = new Shared(spr); - LuaObject* luaSpr = (LuaObject*)luax_newinstance(L, Jin_Lua_Sprite, shrSpr); - luaSpr->setDependency((int)SpriteDependency::DEP_GRAPHIC, graphic); - luax_rawseti(L, -2, i + 1); - } - return 1; - } - - LUA_EXPORT void luaopen_SpriteSheet(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "newSprite", l_newSprite }, - { "newSprites", l_newSprites }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_SpriteSheet, methods); - } - - } -} \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_spritesheet.h b/src/libjin-lua/modules/graphics/je_lua_spritesheet.h deleted file mode 100644 index bcae60b..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_spritesheet.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __JE_LUA_SPRITE_SHEET_H__ -#define __JE_LUA_SPRITE_SHEET_H__ - -namespace JinEngine -{ - namespace Lua - { - - enum class SpriteSheetDependency - { - DEP_GRAPHIC = 1 - }; - - extern const char* Jin_Lua_SpriteSheet; - - void luaopen_SpriteSheet(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_text.cpp b/src/libjin-lua/modules/graphics/je_lua_text.cpp deleted file mode 100644 index 0afbceb..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_text.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" - -using namespace JinEngine::Graphics; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_Text = "Text"; - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Text); - p->release(); - return 0; - } - - LUA_EXPORT void luaopen_Text(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Text, methods); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_text.h b/src/libjin-lua/modules/graphics/je_lua_text.h deleted file mode 100644 index dfcc9cc..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_text.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __JE_LUA_TEXT_H__ -#define __JE_LUA_TEXT_H__ - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_Text; - - void luaopen_Text(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_texture.cpp b/src/libjin-lua/modules/graphics/je_lua_texture.cpp deleted file mode 100644 index b03b999..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_texture.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" -#include "je_lua_texture.h" - -using namespace JinEngine::Graphics; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_Texture = "Texture"; - - LUA_IMPLEMENT inline Texture* checkTexture(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Texture); - return luaObj->getObject(); - } - - LUA_IMPLEMENT int l_getWidth(lua_State* L) - { - Texture* shared = checkTexture(L); - luax_pushnumber(L, shared->getWidth()); - return 1; - } - - LUA_IMPLEMENT int l_getHeight(lua_State *L) - { - Texture* shared = checkTexture(L); - luax_pushnumber(L, shared->getHeight()); - return 1; - } - - LUA_IMPLEMENT int l_getSize(lua_State* L) - { - Texture* shared = checkTexture(L); - luax_pushnumber(L, shared->getWidth()); - luax_pushnumber(L, shared->getHeight()); - return 2; - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Texture); - luaObj->release(); - return 0; - } - - LUA_EXPORT void luaopen_Texture(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "getWidth", l_getWidth }, - { "getHeight", l_getHeight }, - { "getSize", l_getSize }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Texture, methods); - } - - }// namespace Lua -}// namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_texture.h b/src/libjin-lua/modules/graphics/je_lua_texture.h deleted file mode 100644 index c8bb71c..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_texture.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __JE_LUA_TEXTURE_H__ -#define __JE_LUA_TEXTURE_H__ - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_Texture; - - void luaopen_Texture(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_texture_font.cpp b/src/libjin-lua/modules/graphics/je_lua_texture_font.cpp deleted file mode 100644 index 6cbf7ca..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_texture_font.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" - -#include "je_lua_page.h" -#include "je_lua_text.h" - -using namespace JinEngine::Graphics; -using namespace JinEngine::Graphics::Fonts; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_TextureFont = "TextureFont"; - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TextureFont); - luaObj->release(); - return 0; - } - - /* typeset(Text | string, lineheight, spacing) */ - LUA_IMPLEMENT int l_typeset(lua_State* L) - { - LuaObject* luaTexFont = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TextureFont); - TextureFont* tf = luaTexFont->getObject(); - int lineheight = luax_checkinteger(L, 3); - int spacing = luax_optnumber(L, 4, 0); - Page* page = nullptr; - if (luax_isstring(L, 2)) - { - unsigned length; - const char* str = luax_checklstring(L, 2, &length); - Text text(Encode::UTF8, str, length); - page = tf->typeset(text, lineheight, spacing); - } - else if (luax_istype(L, 2, Jin_Lua_Text)) - { - LuaObject* p2 = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Text); - Text* text = p2->getObject(); - page = tf->typeset(*text, lineheight, spacing); - } - Shared* shrPage = new Shared(page); - LuaObject* luaPage = luax_newinstance(L, Jin_Lua_Page, shrPage); - luaPage->setDependency((int)PageDependency::DEP_TEXTURE_FONT, luaTexFont); - return 1; - } - - LUA_EXPORT void luaopen_TextureFont(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "typeset", l_typeset }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_TextureFont, methods); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_texture_font.h b/src/libjin-lua/modules/graphics/je_lua_texture_font.h deleted file mode 100644 index d1fffe5..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_texture_font.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __JE_LUA_TEXTURE_FONT_H__ -#define __JE_LUA_TEXTURE_FONT_H__ - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_TextureFont; - - void luaopen_TextureFont(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_ttf.cpp b/src/libjin-lua/modules/graphics/je_lua_ttf.cpp deleted file mode 100644 index ead46de..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_ttf.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" - -#include "je_lua_page.h" -#include "je_lua_text.h" - -using namespace JinEngine::Graphics; -using namespace JinEngine::Graphics::Fonts; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_TTF = "TTF"; - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TTF); - luaObj->release(); - return 0; - } - - /* typeset(Text | string, lineheight, spacing) */ - LUA_IMPLEMENT int l_typeset(lua_State* L) - { - LuaObject* luaTTF = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TTF); - TTF* ttf = luaTTF->getObject(); - int lineheight = luax_optnumber(L, 3, ttf->getFontSize()); - int spacing = luax_optnumber(L, 4, 0); - Page* page = nullptr; - if (luax_isstring(L, 2)) - { - unsigned length; - const char* str = luax_checklstring(L, 2, &length); - Text text(Encode::UTF8, str, length); - page = ttf->typeset(text, lineheight, spacing); - } - else if (luax_istype(L, 2, Jin_Lua_Text)) - { - LuaObject* luaText = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Text); - Text* text = luaText->getObject(); - page = ttf->typeset(*text, lineheight, spacing); - } - Shared* refPage = new Shared(page); - LuaObject* luaPage = luax_newinstance(L, Jin_Lua_Page, refPage); - luaPage->setDependency((int)PageDependency::DEP_TTF, luaTTF); - return 1; - } - - LUA_EXPORT void luaopen_TTF(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "typeset", l_typeset }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_TTF, methods); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_ttf.h b/src/libjin-lua/modules/graphics/je_lua_ttf.h deleted file mode 100644 index bfe503d..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_ttf.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __JE_LUA_TTF_H__ -#define __JE_LUA_TTF_H__ - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_TTF; - - void luaopen_TTF(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_ttf_data.cpp b/src/libjin-lua/modules/graphics/je_lua_ttf_data.cpp deleted file mode 100644 index e251ac8..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_ttf_data.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" - -#include "je_lua_ttf.h" -#include "je_lua_ttf_data.h" - -using namespace JinEngine::Graphics; -using namespace JinEngine::Graphics::Fonts; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_TTFData = "TTFData"; - - LUA_IMPLEMENT int l_newTTF(lua_State* L) - { - LuaObject* luaTTFData = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TTFData); - int fontsize = luax_checkinteger(L, 2); - TTFData* fontData = luaTTFData->getObject(); - TTF* font = fontData->createTTF(fontsize); - Shared* shrTTF = new Shared(font); - LuaObject* luaTTF = luax_newinstance(L, Jin_Lua_TTF, shrTTF); - luaTTF->setDependency((int)TTFDependency::DEP_TTFDATA, luaTTFData); - return 1; - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TTFData); - p->release(); - return 0; - } - - LUA_EXPORT void luaopen_TTFData(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "newTTF", l_newTTF }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_TTFData, methods); - - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/je_lua_ttf_data.h b/src/libjin-lua/modules/graphics/je_lua_ttf_data.h deleted file mode 100644 index 1fd832d..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_ttf_data.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __JE_LUA_TTFDATA_H__ -#define __JE_LUA_TTFDATA_H__ - -namespace JinEngine -{ - namespace Lua - { - - enum class TTFDependency - { - DEP_TTFDATA = 1, - }; - - extern const char* Jin_Lua_TTFData; - - void luaopen_TTFData(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_animation.cpp b/src/libjin-lua/modules/graphics/l_animation.cpp new file mode 100644 index 0000000..0bf133f --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_animation.cpp @@ -0,0 +1,122 @@ +#include "libjin/jin.h" + +#include "common/l_object.h" +#include "common/l_common.h" + +#include "l_sprite.h" +#include "l_canvas.h" +#include "l_texture.h" +#include "l_shader.h" +#include "l_animation.h" + +using namespace JinEngine::Math; +using namespace JinEngine::Graphics; +using namespace JinEngine::Graphics::Shaders; +using namespace JinEngine::Graphics::Animations; + +namespace JinEngine +{ + namespace Lua + { + const char* Jin_Lua_Animation = "Animation"; + + LUA_IMPLEMENT inline Animation* checkAnimation(lua_State* L) + { + LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Animation); + return luaObj->getObject(); + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); + p->release(); + return 0; + } + + // addFrame(frame) + LUA_IMPLEMENT int l_addFrame(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); + Animation* animation = luaObj->getObject(); + LuaObject* luaSprite = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Sprite); + Sprite* sprite = luaSprite->getObject(); + animation->addFrame(sprite); + int i = animation->getFrameCount() - 1; + luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + i, luaSprite); + return 0; + } + + // addFrames(frames table) + LUA_IMPLEMENT int l_addFrames(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); + Animation* shrAnimation = luaObj->getObject(); + if (!luax_istable(L, 2)) + { + luax_typerror(L, 2, "sprites table"); + return 1; + } + int n = luax_tableidxlen(L, 2); + for (int i = 1; i <= n; ++i) + { + luax_rawgeti(L, 2, i); + LuaObject* luaSprite = (LuaObject*)luax_checktype(L, -1, Jin_Lua_Sprite); + Sprite* sprite = luaSprite->getObject(); + shrAnimation->addFrame(sprite); + int index = shrAnimation->getFrameCount() - 1; + luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + index, luaSprite); + } + return 0; + } + + LUA_IMPLEMENT int l_isLoop(lua_State* L) + { + Animation* shrAnimation = checkAnimation(L); + bool loop = shrAnimation->isLoop(); + luax_pushboolean(L, loop); + return 1; + } + + LUA_IMPLEMENT int l_getSpeed(lua_State* L) + { + Animation* shrAnimation = checkAnimation(L); + float speed = shrAnimation->getSpeed(); + luax_pushnumber(L, speed); + return 1; + } + + LUA_IMPLEMENT int l_getFrame(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); + Animation* shrAnimation = luaObj->getObject(); + int i = luax_checkinteger(L, 2); + LuaObject* frame = luaObj->getDependency((int)AnimationDependency::DEP_SPRITES + i); + luax_getobject(L, frame); + return 1; + } + + LUA_IMPLEMENT int getFrameCount(lua_State* L) + { + Animation* shrAnimation = checkAnimation(L); + int n = shrAnimation->getFrameCount(); + luax_pushinteger(L, n); + return 1; + } + + LUA_EXPORT void luaopen_Animation(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "addFrame", l_addFrame }, + { "addFrames", l_addFrames }, + { "isLoop", l_isLoop }, + { "getSpeed", l_getSpeed }, + { "getFrameCount", getFrameCount }, + { "getFrame", l_getFrame }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Animation, methods); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_animation.h b/src/libjin-lua/modules/graphics/l_animation.h new file mode 100644 index 0000000..1b32ec3 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_animation.h @@ -0,0 +1,24 @@ +#ifndef __JE_LUA_ANIMATION_H__ +#define __JE_LUA_ANIMATION_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Animation; + + /// + /// + /// + enum class AnimationDependency + { + DEP_SPRITES = 1 ///< Index from 1 + }; + + void luaopen_Animation(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_animator.cpp b/src/libjin-lua/modules/graphics/l_animator.cpp new file mode 100644 index 0000000..7927ca4 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_animator.cpp @@ -0,0 +1,163 @@ +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" + +#include "l_sprite.h" +#include "l_canvas.h" +#include "l_texture.h" +#include "l_shader.h" +#include "l_animator.h" +#include "l_animation.h" + +using namespace JinEngine::Math; +using namespace JinEngine::Graphics; +using namespace JinEngine::Graphics::Shaders; +using namespace JinEngine::Graphics::Animations; + +namespace JinEngine +{ + namespace Lua + { + const char* Jin_Lua_Animator = "Animator"; + + LUA_IMPLEMENT inline Animator* checkAnimator(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animator); + return luaObj->getObject(); + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* obj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); + obj->release(); + return 0; + } + + LUA_IMPLEMENT int l_update(lua_State* L) + { + Animator* animator = checkAnimator(L); + float dt = luax_checknumber(L, 2); + animator->update(dt); + return 0; + } + + LUA_IMPLEMENT int l_play(lua_State* L) + { + Animator* animator = checkAnimator(L); + animator->play(); + return 0; + } + + LUA_IMPLEMENT int l_pause(lua_State* L) + { + Animator* animator = checkAnimator(L); + animator->pause(); + return 0; + } + + LUA_IMPLEMENT int l_resume(lua_State* L) + { + Animator* animator = checkAnimator(L); + animator->resume(); + return 0; + } + + LUA_IMPLEMENT int l_rewind(lua_State* L) + { + Animator* animator = checkAnimator(L); + animator->rewind(); + return 0; + } + + LUA_IMPLEMENT int l_render(lua_State* L) + { + Animator* animator = checkAnimator(L); + float x = luax_checknumber(L, 2); + float y = luax_checknumber(L, 3); + float sx = luax_checknumber(L, 4); + float sy = luax_checknumber(L, 5); + float r = luax_checknumber(L, 6); + animator->render(x, y, sx, sy, r); + return 0; + } + + LUA_IMPLEMENT int l_setAnimation(lua_State* L) + { + LuaObject* luaAnimator = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animator); + Animator* animator = luaAnimator->getObject(); + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); + luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, luaObj); + animator->setAnimation(luaObj->getObject()); + return 0; + } + + LUA_IMPLEMENT int l_forceToFrame(lua_State* L) + { + Animator* shrAnimator = checkAnimator(L); + int index = luax_checkinteger(L, 2); + shrAnimator->forceToFrame(index); + return 0; + } + + LUA_IMPLEMENT int l_setSpeed(lua_State* L) + { + Animator* shrAnimator = checkAnimator(L); + float fps = luax_checknumber(L, 2); + shrAnimator->setSpeed(fps); + return 0; + } + + LUA_IMPLEMENT int l_setDefaultSpeed(lua_State* L) + { + Animator* shrAnimator = checkAnimator(L); + shrAnimator->setDefaultSpeed(); + return 0; + } + + LUA_IMPLEMENT int l_setLoop(lua_State* L) + { + Animator* shrAnimator = checkAnimator(L); + bool loop = luax_checkbool(L, 2); + shrAnimator->setLoop(loop); + return 0; + } + + LUA_IMPLEMENT int l_setDefaultLoop(lua_State* L) + { + Animator* shrAnimator = checkAnimator(L); + shrAnimator->setDefaultLoop(); + return 0; + } + + LUA_IMPLEMENT int l_getSpeed(lua_State* L) + { + Animator* shrAnimator = checkAnimator(L); + float speed = shrAnimator->getSpeed(); + luax_pushnumber(L, speed); + return 1; + } + + LUA_EXPORT void luaopen_Animator(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "update", l_update }, + { "play", l_play }, + { "pause", l_pause }, + { "resume", l_resume }, + { "rewind", l_rewind }, + { "render", l_render }, + { "setAnimation", l_setAnimation }, + { "forceToFrame", l_forceToFrame }, + { "setSpeed", l_setSpeed }, + { "setDefaultSpeed", l_setDefaultSpeed }, + { "setLoop", l_setLoop }, + { "setDefaultLoop", l_setDefaultLoop }, + { "getSpeed", l_getSpeed }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Animator, methods); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_animator.h b/src/libjin-lua/modules/graphics/l_animator.h new file mode 100644 index 0000000..0292a77 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_animator.h @@ -0,0 +1,23 @@ +#ifndef __JE_LUA_ANIMATOR_H__ +#define __JE_LUA_ANIMATOR_H__ + +#include "libjin/jin.h" + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Animator; + + enum class AnimatorDependency + { + DEP_ANIMATION = 1 + }; + + void luaopen_Animator(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_bitmap.cpp b/src/libjin-lua/modules/graphics/l_bitmap.cpp new file mode 100644 index 0000000..c081cef --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_bitmap.cpp @@ -0,0 +1,110 @@ +#include "common/l_common.h" +#include "common/l_object.h" + +#include "libjin/jin.h" +#include "l_bitmap.h" + +using namespace JinEngine::Graphics; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_Bitmap = "Bitmap"; + + LUA_IMPLEMENT inline Bitmap* checkBitmap(lua_State* L) + { + LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Bitmap); + return luaObj->getObject(); + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap); + luaObj->release(); + return 0; + } + + LUA_IMPLEMENT int l_getWidth(lua_State* L) + { + Bitmap* bitmap = checkBitmap(L); + int w = bitmap->getWidth(); + luax_pushinteger(L, w); + return 1; + } + + LUA_IMPLEMENT int l_getHeight(lua_State* L) + { + Bitmap* bitmap = checkBitmap(L); + int h = bitmap->getHeight(); + luax_pushinteger(L, h); + return 1; + } + + LUA_IMPLEMENT int l_getSize(lua_State* L) + { + Bitmap* bitmap = checkBitmap(L); + int w = bitmap->getWidth(); + int h = bitmap->getHeight(); + luax_pushinteger(L, w); + luax_pushinteger(L, h); + return 2; + } + + LUA_IMPLEMENT int l_getPixel(lua_State* L) + { + Bitmap* bitmap = checkBitmap(L); + int x = luax_checkinteger(L, 2); + int y = luax_checkinteger(L, 3); + Color col = bitmap->getPixel(x, y); + luax_pushinteger(L, col.r); + luax_pushinteger(L, col.g); + luax_pushinteger(L, col.b); + luax_pushinteger(L, col.a); + return 4; + } + + LUA_IMPLEMENT int l_setPixel(lua_State* L) + { + Bitmap* bitmap = checkBitmap(L); + int x = luax_checkinteger(L, 2); + int y = luax_checkinteger(L, 3); + if (!luax_istable(L, 4)) + { + luax_typerror(L, 4, "table"); + return 1; + } + unsigned int r = luax_rawgetnumber(L, 4, 1); + unsigned int g = luax_rawgetnumber(L, 4, 2); + unsigned int b = luax_rawgetnumber(L, 4, 3); + unsigned int a = luax_rawgetnumber(L, 4, 4); + bitmap->setPixel(Color(r, g, b, a), x, y); + return 0; + } + + LUA_IMPLEMENT int l_clone(lua_State* L) + { + Bitmap* bitmap = checkBitmap(L); + Bitmap* b = bitmap->clone(); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(b)); + return 1; + } + + LUA_EXPORT void luaopen_Bitmap(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "getWidth", l_getWidth }, + { "getHeight", l_getHeight }, + { "getSize", l_getSize }, + { "getPixel", l_getPixel }, + { "setPixel", l_setPixel }, + { "clone", l_clone }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Bitmap, methods); + } + + } // namespace Graphics +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_bitmap.h b/src/libjin-lua/modules/graphics/l_bitmap.h new file mode 100644 index 0000000..b463d83 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_bitmap.h @@ -0,0 +1,16 @@ +#ifndef __JE_LUA_BITMAP_H__ +#define __JE_LUA_BITMAP_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Bitmap; + + void luaopen_Bitmap(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_canvas.cpp b/src/libjin-lua/modules/graphics/l_canvas.cpp new file mode 100644 index 0000000..3979085 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_canvas.cpp @@ -0,0 +1,63 @@ +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" +#include "l_canvas.h" + +using namespace JinEngine::Graphics; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_Canvas = "Canvas"; + + LUA_IMPLEMENT inline Canvas* checkCanvas(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Canvas); + return luaObj->getObject(); + } + + LUA_IMPLEMENT int l_getWidth(lua_State* L) + { + Canvas* canvas = checkCanvas(L); + luax_pushnumber(L, canvas->getWidth()); + return 1; + } + + LUA_IMPLEMENT int l_getHeight(lua_State* L) + { + Canvas* canvas = checkCanvas(L); + luax_pushnumber(L, canvas->getHeight()); + return 1; + } + + LUA_IMPLEMENT int l_getSize(lua_State* L) + { + Canvas* canvas = checkCanvas(L); + luax_pushnumber(L, canvas->getWidth()); + luax_pushnumber(L, canvas->getHeight()); + return 2; + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Canvas); + luaObj->release(); + return 0; + } + + LUA_EXPORT void luaopen_Canvas(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "getWidth", l_getWidth }, + { "getHeight", l_getHeight }, + { "getSize", l_getSize }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Canvas, methods); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_canvas.h b/src/libjin-lua/modules/graphics/l_canvas.h new file mode 100644 index 0000000..d1fa885 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_canvas.h @@ -0,0 +1,16 @@ +#ifndef __JE_LUA_CANVAS_H__ +#define __JE_LUA_CANVAS_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Canvas; + + void luaopen_Canvas(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_graphics.cpp b/src/libjin-lua/modules/graphics/l_graphics.cpp new file mode 100644 index 0000000..950554a --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_graphics.cpp @@ -0,0 +1,1112 @@ +#include +#include + +#include "libjin/jin.h" +#include "common/l_object.h" +#include "common/l_common.h" + +#include "l_canvas.h" +#include "l_sprite.h" +#include "l_spritesheet.h" +#include "l_bitmap.h" +#include "l_mesh.h" +#include "l_ttf.h" +#include "l_ttf_data.h" +#include "l_texture.h" +#include "l_shader.h" +#include "l_text.h" +#include "l_texture_font.h" +#include "l_page.h" +#include "l_sprite.h" +#include "l_animation.h" +#include "l_animator.h" +#include "l_particle_system.h" + +using namespace std; +using namespace JinEngine; +using namespace JinEngine::Math; +using namespace JinEngine::Graphics; +using namespace JinEngine::Graphics::Fonts; +using namespace JinEngine::Graphics::Shaders; +using namespace JinEngine::Graphics::Animations; +using namespace JinEngine::Graphics::Particles; +using namespace JinEngine::Filesystem; + +namespace JinEngine +{ + namespace Lua + { + + #include "../../resources/font.ttf.h" + + static struct + { + Color curRenderColor; + Color curClearColor; + Font* defaultFont = nullptr; + bool initialized = false; + } context; + + LUA_IMPLEMENT int l_init(lua_State* L) + { + if (context.initialized) + { + luax_pushboolean(L, true); + return 1; + } + + Window* wnd = Window::get(); + Window::Setting setting; + setting.width = luax_getfieldinteger(L, 1, "width"); + setting.height = luax_getfieldinteger(L, 1, "height"); + setting.title = luax_getfieldstring(L, 1, "title"); + setting.icon = luax_getfieldstring(L, 1, "icon"); + setting.vsync = luax_getfieldbool(L, 1, "vsync"); + setting.fullscreen = luax_getfieldbool(L, 1, "fullscreen"); + setting.resizable = luax_getfieldbool(L, 1, "resizable"); + context.initialized = wnd->start(&setting); + if (!context.initialized) + { + luax_pushboolean(L, context.initialized); + return 1; + } + + /* load default font */ + Bitmap* bitmap = new Bitmap(default_font_bitmap, sizeof(default_font_bitmap)); + TextureFont* tf = new TextureFont(bitmap, Text(Encode::UTF8, default_charset), default_font_split, bitmap->getHeight()); + delete bitmap; + context.defaultFont = tf; + gl.setFont(tf); + + luax_pushboolean(L, context.initialized); + return 1; + } + + LUA_IMPLEMENT int l_setTitle(lua_State* L) + { + Window* wnd = Window::get(); + const char* title = luax_checkstring(L, 1); + wnd->setTitle(title); + return 0; + } + + LUA_IMPLEMENT int l_destroy(lua_State* L) + { + Window* wnd = Window::get(); + wnd->quit(); + return 0; + } + + LUA_IMPLEMENT int l_showWindow(lua_State* L) + { + Window* wnd = Window::get(); + wnd->show(); + return 0; + } + + LUA_IMPLEMENT int l_hideWindow(lua_State* L) + { + Window* wnd = Window::get(); + wnd->hide(); + return 0; + } + + LUA_IMPLEMENT int l_getSize(lua_State* L) + { + Window* wnd = Window::get(); + luax_pushnumber(L, wnd->getW()); + luax_pushnumber(L, wnd->getH()); + return 2; + } + + LUA_IMPLEMENT int l_getWidth(lua_State* L) + { + Window* wnd = Window::get(); + luax_pushnumber(L, wnd->getW()); + return 1; + } + + LUA_IMPLEMENT int l_getHeight(lua_State* L) + { + Window* wnd = Window::get(); + luax_pushnumber(L, wnd->getH()); + return 1; + } + + LUA_IMPLEMENT int l_newBitmap(lua_State* L) + { + Bitmap* bitmap = nullptr; + if (luax_gettop(L) == 2) + { + int w = luax_checkinteger(L, 1); + int h = luax_checkinteger(L, 2); + bitmap = new Bitmap(w, h); + } + else if (luax_gettop(L) == 3) + { + int w = luax_checkinteger(L, 1); + int h = luax_checkinteger(L, 2); + if (luax_istable(L, 3)) + { + 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 = new Bitmap(w, h, Color(r, g, b, a)); + } + else if (luax_isfunction(L, 3)) + { + std::function 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 = new Bitmap(w, h, drawer); + } + else + { + luax_typerror(L, 3, "color table or color setter"); + return 1; + } + } + else + { + const char* f = luax_checkstring(L, 1); + AssetDatabase* fs = AssetDatabase::get(); + Buffer b; + try + { + if (!fs->exists(f)) + throw Exception("No such image file %s.", f); + fs->read(f, b); + } + catch (Exception& e) + { + luax_errorf(L, "Failed to read image %s", f); + luax_pushnil(L); + return 1; + } + bitmap = new Bitmap(&b, b.size()); + if (bitmap == nullptr) + { + luax_errorf(L, "Failed to decode image file %s", f); + luax_pushnil(L); + return 1; + } + } + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(bitmap)); + return 1; + } + + /* jin.graphics.newTexture(bitmap) */ + LUA_IMPLEMENT int l_newTexture(lua_State* L) + { + Texture* texture = nullptr; + if (luax_istype(L, 1, Jin_Lua_Bitmap)) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap); + Bitmap* bitmap = luaObj->getObject(); + texture = new Texture(bitmap); + } + else if (luax_isstring(L, 1)) + { + const char* path = luax_checkstring(L, 1); + texture = new Texture(path); + } + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Texture, new Shared(texture)); + return 1; + } + + // See embed graphics.lua. + LUA_IMPLEMENT int l_newShader(lua_State* L) + { + const char* program = luax_checkstring(L, 1); + Shader* jsl = nullptr; + try + { + jsl = new Shader(program); + } + catch (JinEngine::Exception& e) + { + //luax_errorf(L, "Failed to compile shader"); + luax_pushnil(L); + return 1; + } + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared(jsl)); + return 1; + } + + // See embed graphics.lua + LUA_IMPLEMENT int l_newShaderf(lua_State* L) + { + const char* path = luax_checkstring(L, 1); + AssetDatabase* fs = AssetDatabase::get(); + if (!fs->exists(path)) + { + //luax_errorf(L, "No such shader file \"%s\"", path); + luax_pushnil(L); + return 1; + } + Buffer b; + fs->read(path, b); + Shader* jsl = nullptr; + try + { + jsl = new Shader((char*)&b); + } + catch (JinEngine::Exception& e) + { + //luax_errorf(L, "Failed to compile shader"); + luax_pushnil(L); + return 1; + } + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared(jsl)); + return 1; + } + + LUA_IMPLEMENT int l_newCanvas(lua_State* L) + { + int w = luax_checknumber(L, 1); + int h = luax_checknumber(L, 2); + Canvas* cvs = new Canvas(w, h); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Canvas, new Shared(cvs)); + return 1; + } + + LUA_IMPLEMENT int l_clear(lua_State* L) + { + glClear(GL_COLOR_BUFFER_BIT); + return 0; + } + + LUA_IMPLEMENT int l_setClearColor(lua_State* L) + { + if (luax_gettop(L) == 0) + { + glClearColor(0, 0, 0, 1); + return 0; + } + + context.curClearColor.r = luax_checknumber(L, 1); + context.curClearColor.g = luax_checknumber(L, 2); + context.curClearColor.b = luax_checknumber(L, 3); + context.curClearColor.a = luax_checknumber(L, 4); + + gl.setClearColor(context.curClearColor.r, + context.curClearColor.g, + context.curClearColor.b, + context.curClearColor.a); + return 0; + } + + LUA_IMPLEMENT int l_present(lua_State* L) + { + Window::get()->present(); + return 0; + } + + LUA_IMPLEMENT void l_draw_texture(lua_State* L) + { + if (!luax_istype(L, 1, Jin_Lua_Texture)) + return; + int x = luax_optnumber(L, 2, 0); + int y = luax_optnumber(L, 3, 0); + float sx = luax_optnumber(L, 4, 1); + float sy = luax_optnumber(L, 5, 1); + float r = luax_optnumber(L, 6, 0); + float ox = luax_optnumber(L, 7, 0); + float oy = luax_optnumber(L, 8, 0); + LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1); + Texture* tex = luaObj->getObject(); + tex->render(x, y, sx, sy, r, ox, oy); + } + + LUA_IMPLEMENT void l_draw_canvas(lua_State* L) + { + if (!luax_istype(L, 1, Jin_Lua_Canvas)) + return; + int x = luax_optnumber(L, 2, 0); + int y = luax_optnumber(L, 3, 0); + float sx = luax_optnumber(L, 4, 1); + float sy = luax_optnumber(L, 5, 1); + float r = luax_optnumber(L, 6, 0); + float ox = luax_optnumber(L, 7, 0); + float oy = luax_optnumber(L, 8, 0); + LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1); + Canvas* canvas = luaObj->getObject(); + canvas->render(x, y, sx, sy, r, ox, oy); + } + + /* jin.graphics.draw(text, font, x, y) */ + LUA_IMPLEMENT void l_draw_text(lua_State* L) + { + if (!luax_istype(L, 1, Jin_Lua_Text)) + return; + LuaObject* p = (LuaObject*)luax_toudata(L, 1); + Text* text = p->getObject(); + int x = luax_optnumber(L, 3, 0); + int y = luax_optnumber(L, 4, 0); + int spacing = luax_optnumber(L, 6, 0); + Font* font = nullptr; + LuaObject* p2 = (LuaObject*)luax_toudata(L, 2); + if (luax_istype(L, 2, Jin_Lua_TextureFont)) + { + TextureFont* tf = p2->getObject(); + font = tf; + } + else if (luax_istype(L, 2, Jin_Lua_TTF)) + { + TTF* ttf = p2->getObject(); + font = ttf; + } + else + { + font = context.defaultFont; + } + int lineheight = luax_optnumber(L, 5, font->getFontSize()); + font->render(*text, x, y, lineheight, spacing); + } + + /* jin.graphics.draw(page, x, y) */ + LUA_IMPLEMENT void l_draw_page(lua_State* L) + { + if (!luax_istype(L, 1, Jin_Lua_Page)) + return; + int x = luax_optnumber(L, 2, 0); + int y = luax_optnumber(L, 3, 0); + LuaObject* p = (LuaObject*)luax_toudata(L, 1); + Page* page = p->getObject(); + Font* font = page->font; + font->render(page, x, y); + } + + LUA_IMPLEMENT void l_draw_sprite(lua_State* L) + { + if (!luax_istype(L, 1, Jin_Lua_Sprite)) + return; + LuaObject* luaSprite = (LuaObject*)luax_toudata(L, 1); + Sprite* sprite = luaSprite->getObject(); + float x = luax_checknumber(L, 2); + float y = luax_checknumber(L, 3); + float sx = luax_checknumber(L, 4); + float sy = luax_checknumber(L, 5); + float r = luax_checknumber(L, 6); + sprite->render(x, y, sx, sy, r); + } + + LUA_IMPLEMENT void l_draw_mesh(lua_State* L) + { + if (!luax_istype(L, 1, Jin_Lua_Mesh)) + return; + LuaObject* obj= (LuaObject*)luax_toudata(L, 1); + Mesh* mesh = obj->getObject(); + int x = luax_optnumber(L, 2, 0); + int y = luax_optnumber(L, 3, 0); + float sx = luax_optnumber(L, 4, 1); + float sy = luax_optnumber(L, 5, 1); + float r = luax_optnumber(L, 6, 0); + float ox = luax_optnumber(L, 7, 0); + float oy = luax_optnumber(L, 8, 0); + mesh->render(x, y, sx, sy, r, ox, oy); + } + + LUA_IMPLEMENT int l_draw(lua_State* L) + { + if (luax_istype(L, 1, Jin_Lua_Texture)) + l_draw_texture(L); + else if (luax_istype(L, 1, Jin_Lua_Canvas)) + l_draw_canvas(L); + else if (luax_istype(L, 1, Jin_Lua_Text)) + l_draw_text(L); + else if (luax_istype(L, 1, Jin_Lua_Page)) + l_draw_page(L); + else if (luax_istype(L, 1, Jin_Lua_Sprite)) + l_draw_sprite(L); + else if (luax_istype(L, 1, Jin_Lua_Mesh)) + l_draw_mesh(L); + else + { + luax_typerror(L, 1, "texture or canvas"); + return 1; + } + return 0; + } + + // draw(tex, quad, x, y, sx, sy, r, ax, ay) + LUA_IMPLEMENT int l_drawq(lua_State* L) + { + if (!luax_istable(L, 2)) + { + luax_typerror(L, 2, "table"); + return 1; + } + Math::Quad q; + q.x = luax_rawgetnumber(L, 2, 1); + q.y = luax_rawgetnumber(L, 2, 2); + q.w = luax_rawgetnumber(L, 2, 3); + q.h = luax_rawgetnumber(L, 2, 4); + luax_pop(L, 4); + int x = luax_optnumber(L, 3, 0); + int y = luax_optnumber(L, 4, 0); + float sx = luax_optnumber(L, 5, 1); + float sy = luax_optnumber(L, 6, 1); + float r = luax_optnumber(L, 7, 0); + float ox = luax_optnumber(L, 8, 0); + float oy = luax_optnumber(L, 9, 0); + + if (luax_istype(L, 1, Jin_Lua_Texture)) + { + LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1); + Texture* tex = luaObj->getObject(); + tex->render(q, x, y, sx, sy, r, ox, oy); + } + else if (luax_istype(L, 1, Jin_Lua_Canvas)) + { + LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1); + Canvas* canvas = luaObj->getObject(); + canvas->render(q, x, y, sx, sy, r, ox, oy); + } + else + { + luax_typerror(L, 1, "texture or canvas"); + return 1; + } + return 0; + } + + /* print(string, x, y, lineheight, spacing) */ + /* need set font */ + LUA_IMPLEMENT int l_print(lua_State* L) + { + Font* font = gl.getFont(); + if (font == nullptr) + return 0; + unsigned length; + const char* str = luax_checklstring(L, 1, &length); + Text text(Encode::UTF8, str, length); + int x = luax_optnumber(L, 2, 0); + int y = luax_optnumber(L, 3, 0); + int lineheight = luax_optnumber(L, 4, font->getFontSize()); + int spacing = luax_optnumber(L, 5, 0); + font->render(text, x, y, lineheight, spacing); + return 0; + } + + LUA_IMPLEMENT int l_setColor(lua_State* L) + { + if (luax_gettop(L) == 0) + { + gl.setColor(Color(255, 255, 255, 255)); + return 0; + } + + context.curRenderColor.r = luax_checknumber(L, 1); + context.curRenderColor.g = luax_checknumber(L, 2); + context.curRenderColor.b = luax_checknumber(L, 3); + if (luax_gettop(L) == 4) + context.curRenderColor.a = luax_checknumber(L, 4); + else + context.curRenderColor.a = 255; + gl.setColor(context.curRenderColor); + return 0; + } + + LUA_IMPLEMENT int l_getColor(lua_State * L) + { + luax_pushnumber(L, context.curRenderColor.r); + luax_pushnumber(L, context.curRenderColor.g); + luax_pushnumber(L, context.curRenderColor.b); + luax_pushnumber(L, context.curRenderColor.a); + return 4; + } + + LUA_IMPLEMENT int l_bindCanvas(lua_State* L) + { + if (luax_gettop(L) == 0) + { + // bind to default canvas + gl.unbindCanvas(); + return 0; + } + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Canvas); + Canvas* canvas = luaObj->getObject(); + gl.bindCanvas(canvas); + return 0; + } + + LUA_IMPLEMENT int l_unbindCanvas(lua_State* L) + { + gl.unbindCanvas(); + return 0; + } + + LUA_IMPLEMENT int l_useShader(lua_State* L) + { + if (luax_gettop(L) == 0) + { + gl.unuseShader(); + return 0; + } + if (luax_istype(L, 1, Jin_Lua_Shader)) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Shader); + Shader* shader = luaObj->getObject(); + gl.useShader(shader); + } + else + { + luax_typerror(L, 1, "JSL shader"); + } + return 0; + } + + LUA_IMPLEMENT int l_setBlendMode(lua_State* L) + { + int mode = luax_checkinteger(L, 1); + gl.setBlendMode(static_cast(mode)); + return 0; + } + + LUA_IMPLEMENT int l_getBlendMode(lua_State* L) + { + int mode = static_cast(gl.getBlendMode()); + luax_pushinteger(L, mode); + return 1; + } + + LUA_IMPLEMENT int l_point(lua_State* L) + { + int x = luax_checknumber(L, 1); + int y = luax_checknumber(L, 2); + JinEngine::Graphics::point(x, y); + + return 0; + } + + LUA_IMPLEMENT int l_line(lua_State* L) + { + int x1 = luax_checknumber(L, 1); + int y1 = luax_checknumber(L, 2); + int x2 = luax_checknumber(L, 3); + int y2 = luax_checknumber(L, 4); + JinEngine::Graphics::line(x1, y1, x2, y2); + + return 0; + } + + LUA_IMPLEMENT int l_rect(lua_State* L) + { + RenderMode mode = static_cast(luax_checkinteger(L, 1)); + if (mode != RenderMode::NONE) + { + int x = luax_checknumber(L, 2); + int y = luax_checknumber(L, 3); + int w = luax_checknumber(L, 4); + int h = luax_checknumber(L, 5); + rect(mode, x, y, w, h); + } + else + { + luax_typerror(L, 1, "'fill' or 'line'"); + return 1; + } + + return 0; + } + + LUA_IMPLEMENT int l_circle(lua_State* L) + { + RenderMode mode = static_cast(luax_checkinteger(L, 1)); + if (mode != RenderMode::NONE) + { + int x = luax_checknumber(L, 2); + int y = luax_checknumber(L, 3); + float r = luax_checknumber(L, 4); + circle(mode, x, y, r); + } + else + { + luax_typerror(L, 1, "'fill' or 'line'"); + return 1; + } + + return 0; + } + + LUA_IMPLEMENT int l_triangle(lua_State* L) + { + RenderMode mode = static_cast(luax_checkinteger(L, 1)); + if (mode != RenderMode::NONE) + { + int x = luax_checknumber(L, 2); + int y = luax_checknumber(L, 3); + + int x2 = luax_checknumber(L, 3); + int y2 = luax_checknumber(L, 4); + + int x3 = luax_checknumber(L, 5); + int y3 = luax_checknumber(L, 6); + + triangle(mode, x, y, x2, y2, x3, y3); + } + else + { + luax_typerror(L, 1, "'fill' or 'line'"); + return 1; + } + + return 0; + } + + LUA_IMPLEMENT int l_polygon(lua_State* L) + { + RenderMode mode = static_cast(luax_checkinteger(L, 1)); + int n = luax_checknumber(L, 2); + if (mode != RenderMode::NONE) + { + if (!luax_istable(L, 3)) + { + luax_typerror(L, 3, "table"); + return 1; + } + int tn = luax_tableidxlen(L, 3); + if (tn != n * 2) + { + 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); + return 1; + } + float* p = (float*)alloca(2 * n * sizeof(float)); + for (int i = 1; i <= 2 * n; ++i) + p[i - 1] = luax_rawgetnumber(L, 3, i); + polygon(mode, p, n); + } + else + { + luax_typerror(L, 1, "'fill' or 'line'"); + return 1; + } + + return 0; + } + + LUA_IMPLEMENT int l_newTTFData(lua_State* L) + { + TTFData* fd = nullptr; + { + const char* path = luax_checkstring(L, 1); + AssetDatabase* fs = AssetDatabase::get(); + if (!fs->exists(path)) + { + luax_errorf(L, "No such font \"%s\"", path); + luax_pushnil(L); + return 1; + } + Buffer b; + fs->read(path, b); + fd = new TTFData(&b, b.size()); + } + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TTFData, new Shared(fd)); + return 1; + } + + /* newText(str[, encode]) */ + LUA_IMPLEMENT int l_newText(lua_State* L) + { + Encode encode = Encode::UTF8; + if (luax_gettop(L) == 2) + { + const char* e = luax_checkstring(L, 2); + if (strcmp(e, "UTF8") == 0) encode = Encode::UTF8; + //else if (strcmp(e, "UTF16") == 0) encode = Encode::UTF16; + else if (strcmp(e, "ASCII") == 0) encode = Encode::ASCII; + else + { + luax_error(L, "wrong text encode %s", e); + return 0; + } + } + unsigned length; + const char* data = luax_checklstring(L, 1, &length); + Text* text = new Text(encode, data, length); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Text, new Shared(text)); + return 1; + } + + // newSprite(Texture tex, Quad quad, Origin origin) + // newSprite(Texture tex, Quad quad, Number ox, Number oy) + // newSprite(Texture tex, Origin origin) + // newSprite(Texture tex, Number ox, Number oy) + LUA_IMPLEMENT int l_newSprite(lua_State* L) + { + int n = luax_gettop(L); + LuaObject* objGraphic = nullptr; + if (luax_istype(L, 1, Jin_Lua_Texture)) + objGraphic = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Texture); + else if (luax_istype(L, 1, Jin_Lua_Canvas)) + objGraphic = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Canvas); + Graphic* graphic = objGraphic->getObject(); + if (objGraphic != nullptr) + { + if (n == 3 && luax_istable(L, 2)) + { + Quad quad; + quad.x = luax_rawgetnumberthenpop(L, 2, 1); + quad.y = luax_rawgetnumberthenpop(L, 2, 2); + quad.w = luax_rawgetnumberthenpop(L, 2, 3); + quad.h = luax_rawgetnumberthenpop(L, 2, 4); + int o = luax_checkinteger(L, 3); + Origin origin = static_cast(o); + LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, quad, origin))); + p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic); + } + else if (n == 4) + { + Quad quad; + quad.x = luax_rawgetnumberthenpop(L, 2, 1); + quad.y = luax_rawgetnumberthenpop(L, 2, 2); + quad.w = luax_rawgetnumberthenpop(L, 2, 3); + quad.h = luax_rawgetnumberthenpop(L, 2, 4); + int ox = luax_checkinteger(L, 3); + int oy = luax_checkinteger(L, 4); + LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, quad, ox, oy))); + p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic); + } + else if (n == 2) + { + int o = luax_checkinteger(L, 2); + Origin origin = static_cast(o); + LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, origin))); + p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic); + } + else if (n == 3) + { + int ox = luax_checkinteger(L, 2); + int oy = luax_checkinteger(L, 3); + LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, ox, oy))); + p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic); + } + else + { + luax_error(L, "No matched overloaded functions."); + return 1; + } + } + + return 1; + } + + LUA_IMPLEMENT int l_newSpriteSheet(lua_State* L) + { + LuaObject* objGraphic = nullptr; + if (luax_istype(L, 1, Jin_Lua_Texture)) + objGraphic = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Texture); + else if(luax_istype(L, 1, Jin_Lua_Canvas)) + objGraphic = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Canvas); + if (objGraphic != nullptr) + { + Graphic* graphic = objGraphic->getObject(); + Shared* shrSSheet = new Shared(new SpriteSheet(graphic)); + LuaObject* luaSSheet = luax_newinstance(L, Jin_Lua_SpriteSheet, shrSSheet); + luaSSheet->setDependency((int)SpriteSheetDependency::DEP_GRAPHIC, objGraphic); + return 1; + } + else + return 0; + } + + // newAnimation([frames table, loop, speed]) + LUA_IMPLEMENT int l_newAnimation(lua_State* L) + { + int argc = luax_gettop(L); + Animation* animation = new Animation(); + Shared* shrAnimation = new Shared(animation); + LuaObject* luaAnimation = luax_newinstance(L, Jin_Lua_Animation, shrAnimation); + if (argc >= 3) + { + if (!luax_istable(L, 1)) + { + luax_typerror(L, 1, "frames table"); + return 1; + } + bool loop = luax_checkbool(L, 2); + float speed = luax_checknumber(L, 3); + int n = luax_tableidxlen(L, 1); + for (int i = 1; i <= n; ++i) + { + luax_rawgeti(L, 1, i); + LuaObject* luaSprite = (LuaObject*)luax_checktype(L, -1, Jin_Lua_Sprite); + animation->addFrame(luaSprite->getObject()); + int index = animation->getFrameCount() - 1; + luaAnimation->setDependency((int)AnimationDependency::DEP_SPRITES + index, luaSprite); + } + animation->setLoop(loop); + animation->setSpeed(speed); + } + luax_pushvalue(L, argc + 1); + return 1; + } + + // newAnimator([animation]) + LUA_IMPLEMENT int l_newAnimator(lua_State* L) + { + int argc = luax_gettop(L); + Animator* animator = new Animator(); + Shared* shrAniamtor = new Shared(animator); + if (argc >= 1) + { + LuaObject* animation = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); + animator->setAnimation(animation->getObject()); + LuaObject* luaAnimator = luax_newinstance(L, Jin_Lua_Animator, shrAniamtor); + luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, animation); + return 1; + } + LuaObject* luaAnimator = luax_newinstance(L, Jin_Lua_Animator, shrAniamtor); + return 1; + } + + /* newTextureFont(bitmap, text, color | cellw, cellh) */ + LUA_IMPLEMENT int l_newTextureFont(lua_State* L) + { + LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap); + Bitmap* bitmap = p->getObject(); + Text* text; + if (luax_istype(L, 2, Jin_Lua_Text)) + { + LuaObject* pt = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Text); + text = pt->getObject(); + } + else if (luax_isstring(L, 2)) + { + unsigned len; + const char* str = luax_checklstring(L, 2, &len); + text = new Text(Encode::UTF8, str, len); + } + else + { + luax_typerror(L, 2, "Text or string"); + return 1; + } + float cellh = luax_checknumber(L, 4); + TextureFont* textureFont = nullptr; + if (luax_istable(L, 3)) + { + 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); + textureFont = new TextureFont(bitmap, *text, Color(r, g, b, a), cellh); + } + else if (luax_isnumber(L, 3)) + { + float cellw = luax_checknumber(L, 3); + textureFont = new TextureFont(bitmap, *text, cellw, cellh); + } + else + { + luax_error(L, "bad arguments #3 to 'newTextureFont', need to be table or number"); + return 0; + } + if (luax_isstring(L, 2)) + { + // Delete temporary text. + delete text; + } + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TextureFont, new Shared(textureFont)); + return 1; + } + + LUA_IMPLEMENT int l_newParticleSystem(lua_State* L) + { + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_ParticleSystem, new Shared(new ParticleSystem())); + return 1; + } + + LUA_IMPLEMENT int l_newMesh(lua_State* L) + { + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Mesh, new Shared(new Mesh())); + return 1; + } + + /* setFont(font) */ + LUA_IMPLEMENT int l_setFont(lua_State* L) + { + if (luax_istype(L, 1, Jin_Lua_TTF)) + { + LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TTF); + TTF* ttf = p->getObject(); + gl.setFont(ttf); + } + else if (luax_istype(L, 1, Jin_Lua_TextureFont)) + { + LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TextureFont); + TextureFont* tf = p->getObject(); + gl.setFont(tf); + } + return 0; + } + + LUA_IMPLEMENT int l_unsetFont(lua_State* L) + { + gl.setFont(context.defaultFont); + return 0; + } + + LUA_IMPLEMENT int l_clearMatrix(lua_State* L) + { + gl.clearMatrix(); + return 0; + } + + LUA_IMPLEMENT int l_pushMatrix(lua_State* L) + { + gl.pushMatrix(); + return 0; + } + + LUA_IMPLEMENT int l_popMatrix(lua_State* L) + { + gl.popMatrix(); + return 0; + } + + LUA_IMPLEMENT int l_scale(lua_State* L) + { + float sx = luax_checknumber(L, 1); + float sy = luax_checknumber(L, 2); + gl.scale(sx, sy); + return 0; + } + + LUA_IMPLEMENT int l_translate(lua_State* L) + { + float x = luax_checknumber(L, 1); + float y = luax_checknumber(L, 2); + gl.translate(x, y); + return 0; + } + + LUA_IMPLEMENT int l_rotate(lua_State* L) + { + float r = luax_checknumber(L, 1); + gl.rotate(r); + return 0; + } + + LUA_IMPLEMENT int l_getStats(lua_State* L) + { + OpenGL::Stats stats = gl.getStats(); + luax_newtable(L); + luax_setfieldinteger(L, "drawCalls", stats.drawCalls); + luax_setfieldinteger(L, "canvasSwitches", stats.canvasSwitches); + luax_setfieldinteger(L, "shaderSwitches", stats.shaderSwitches); + luax_setfieldinteger(L, "fontSwitches", stats.fontSwitches); + luax_setfieldinteger(L, "textures", stats.textures); + luax_setfieldinteger(L, "canvases", stats.canvases); + luax_setfieldinteger(L, "fonts", stats.fonts); + return 1; + } + + LUA_EXPORT int luaopen_graphics(lua_State* L) + { + 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); + luaopen_Animation(L); + luaopen_Animator(L); + luaopen_ParticleSystem(L); + luaopen_Mesh(L); + + luaL_Reg methods[] = { + { "getStats", l_getStats }, + /* window */ + { "init", l_init }, + { "setTitle", l_setTitle }, + { "getSize", l_getSize }, + { "getWidth", l_getWidth }, + { "getHeight", l_getHeight }, + { "destroy", l_destroy }, + { "hideWindow", l_hideWindow }, + { "showWindow", l_showWindow }, + /* creators */ + { "newBitmap", l_newBitmap }, + { "newTexture", l_newTexture }, + { "newShader", l_newShader }, + { "newShaderf", l_newShaderf }, + { "newCanvas", l_newCanvas }, + { "newTTFData", l_newTTFData }, + { "newText", l_newText }, + { "newTextureFont", l_newTextureFont }, + { "newSprite", l_newSprite }, + { "newSpriteSheet", l_newSpriteSheet }, + { "newAnimation", l_newAnimation }, + { "newAnimator", l_newAnimator }, + { "newParticleSystem", l_newParticleSystem }, + { "newMesh", l_newMesh }, + /* render */ + { "setClearColor", l_setClearColor }, + { "clear", l_clear }, + { "draw", l_draw }, + { "print", l_print }, + { "drawq", l_drawq }, + { "setColor", l_setColor }, + { "getColor", l_getColor }, + { "present", l_present }, + { "setBlendMode", l_setBlendMode }, + { "getBlendMode", l_getBlendMode }, + /* canvas */ + { "bindCanvas", l_bindCanvas }, + { "unbindCanvas", l_unbindCanvas }, + /* shader */ + { "useShader", l_useShader }, + /* shapes */ + { "point", l_point }, + { "line", l_line }, + { "rect", l_rect }, + { "circle", l_circle }, + { "triangle", l_triangle }, + { "polygon", l_polygon }, + /* font */ + { "setFont", l_setFont }, + { "unsetFont", l_unsetFont }, + /* transform */ + { "pushMatrix", l_pushMatrix }, + { "clearMatrix", l_clearMatrix }, + { "popMatrix", l_popMatrix }, + { "translate", l_translate }, + { "rotate", l_rotate }, + { "scale", l_scale }, + { 0, 0 } + }; + // Load whole lib. + luax_newlib(L, methods); + return 1; + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_graphics.h b/src/libjin-lua/modules/graphics/l_graphics.h new file mode 100644 index 0000000..02a2c63 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_graphics.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_GRAPHICS_H__ +#define __JE_LUA_GRAPHICS_H__ + +namespace JinEngine +{ + namespace Lua + { + + int luaopen_graphics(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_mesh.cpp b/src/libjin-lua/modules/graphics/l_mesh.cpp new file mode 100644 index 0000000..73e0024 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_mesh.cpp @@ -0,0 +1,87 @@ +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" +#include "l_mesh.h" +#include "l_texture.h" + +using namespace JinEngine::Math; +using namespace JinEngine::Graphics; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_Mesh = "Mesh"; + + LUA_IMPLEMENT inline Mesh* checkMesh(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); + return luaObj->getObject(); + } + + LUA_IMPLEMENT int l_getBound(lua_State* L) + { + Mesh* mesh = checkMesh(L); + BBox bbox = mesh->getBound(); + luax_pushnumber(L, bbox.l); + luax_pushnumber(L, bbox.r); + luax_pushnumber(L, bbox.t); + luax_pushnumber(L, bbox.b); + return 4; + } + + LUA_IMPLEMENT int l_setGraphic(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); + Mesh* mesh = luaObj->getObject(); + luaObj->removeDependency((int)MeshDependency::DEP_GRAPHIC); + LuaObject* obj = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Texture); + mesh->setGraphic(obj->getObject()); + luaObj->setDependency((int)MeshDependency::DEP_GRAPHIC, obj); + return 0; + } + + // x, y, u, v, color_table + LUA_IMPLEMENT int l_pushVertex(lua_State* L) + { + Mesh* mesh = checkMesh(L); + float x = luax_checknumber(L, 2); + float y = luax_checknumber(L, 3); + float u = luax_checknumber(L, 4); + float v = luax_checknumber(L, 5); + if (!luax_istable(L, 6)) + { + luax_typerror(L, 6, "color table"); + return 1; + } + 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); + mesh->pushVertex(x, y, u, v, c); + return 0; + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); + luaObj->release(); + return 0; + } + + LUA_EXPORT void luaopen_Mesh(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "getBound", l_getBound }, + { "setGraphic", l_setGraphic }, + { "pushVertex", l_pushVertex }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Mesh, methods); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_mesh.h b/src/libjin-lua/modules/graphics/l_mesh.h new file mode 100644 index 0000000..b3fa00e --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_mesh.h @@ -0,0 +1,21 @@ +#ifndef __JE_LUA_MESH_H__ +#define __JE_LUA_MESH_H__ + +namespace JinEngine +{ + namespace Lua + { + + enum class MeshDependency + { + DEP_GRAPHIC = 1, + }; + + extern const char* Jin_Lua_Mesh; + + void luaopen_Mesh(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_page.cpp b/src/libjin-lua/modules/graphics/l_page.cpp new file mode 100644 index 0000000..b7aeb95 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_page.cpp @@ -0,0 +1,66 @@ +#include + +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" + +using namespace JinEngine::Graphics; +using namespace JinEngine::Graphics::Fonts; +using namespace JinEngine::Graphics::Shaders; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_Page = "Page"; + + Page* getPage(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Page); + return luaObj->getObject(); + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Page); + luaObj->release(); + return 0; + } + + LUA_IMPLEMENT int l_getSize(lua_State* L) + { + Page* page = getPage(L); + luax_pushinteger(L, page->size.w()); + luax_pushinteger(L, page->size.h()); + return 2; + } + + LUA_IMPLEMENT int l_getWidth(lua_State* L) + { + Page* page = getPage(L); + luax_pushinteger(L, page->size.w()); + return 1; + } + + LUA_IMPLEMENT int l_getHeight(lua_State* L) + { + Page* page = getPage(L); + luax_pushinteger(L, page->size.h()); + return 1; + } + + LUA_EXPORT void luaopen_Page(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "getSize", l_getSize }, + { "getWidth", l_getWidth }, + { "getHeight", l_getHeight }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Page, methods); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_page.h b/src/libjin-lua/modules/graphics/l_page.h new file mode 100644 index 0000000..e4a21a3 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_page.h @@ -0,0 +1,22 @@ +#ifndef __JE_LUA_PAGE_H__ +#define __JE_LUA_PAGE_H__ + +namespace JinEngine +{ + namespace Lua + { + + enum class PageDependency + { + DEP_TTF = 1, + DEP_TEXTURE_FONT = 2, + }; + + extern const char* Jin_Lua_Page; + + void luaopen_Page(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_particle_system.cpp b/src/libjin-lua/modules/graphics/l_particle_system.cpp new file mode 100644 index 0000000..5830221 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_particle_system.cpp @@ -0,0 +1,422 @@ +#include + +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" + +#include "l_sprite.h" +#include "l_particle_system.h" + +using namespace std; +using namespace JinEngine::Math; +using namespace JinEngine::Graphics; +using namespace JinEngine::Graphics::Particles; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_ParticleSystem = "ParticleSystem"; + + LUA_IMPLEMENT inline ParticleSystem* checkPS(lua_State* L) + { + LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem); + return luaObj->getObject(); + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem); + luaObj->release(); + return 0; + } + + LUA_IMPLEMENT int l_update(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + float dt = luax_checknumber(L, 2); + ps->update(dt); + return 0; + } + + LUA_IMPLEMENT int l_render(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + ps->render(); + return 0; + } + + LUA_IMPLEMENT int l_setPosition(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + float x = luax_checknumber(L, 2); + float y = luax_checknumber(L, 3); + ps->setPosition(x, y); + return 0; + } + + LUA_IMPLEMENT int l_setScale(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + float sx = luax_checknumber(L, 2); + float sy = luax_checknumber(L, 3); + //ps->setScale(sx, sy); + return 0; + } + + LUA_IMPLEMENT int l_pause(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + bool b = luax_checkbool(L, 2); + //ps->pause(b); + return 0; + } + + LUA_IMPLEMENT int l_clear(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + //ps->clear(); + return 0; + } + + LUA_IMPLEMENT int l_setEmitRate(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + if (luax_gettop(L) >= 3) + { + float floor = luax_checknumber(L, 2); + float ceil = luax_checknumber(L, 3); + ps->setEmitRate(floor, ceil); + } + else if (luax_gettop(L) >= 2) + { + float n = luax_checknumber(L, 2); + ps->setEmitRate(n); + } + return 0; + } + + LUA_IMPLEMENT int l_setEmitForce(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + if (luax_gettop(L) >= 3) + { + float floor = luax_checknumber(L, 2); + float ceil = luax_checknumber(L, 3); + ps->setEmitForce(floor, ceil); + } + else if (luax_gettop(L) >= 2) + { + float n = luax_checknumber(L, 2); + ps->setEmitForce(n); + } + return 0; + } + + LUA_IMPLEMENT int l_setEmitDirection(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + if (luax_gettop(L) >= 3) + { + float floor = luax_checknumber(L, 2); + float ceil = luax_checknumber(L, 3); + ps->setEmitDirection(floor, ceil); + } + else if (luax_gettop(L) >= 2) + { + float n = luax_checknumber(L, 2); + ps->setEmitDirection(n); + } + return 0; + } + + LUA_IMPLEMENT int l_setEmitPosition(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + if (luax_gettop(L) >= 3) + { + if (!luax_istable(L, 2)) + { + luax_typerror(L, 2, "table"); + return 1; + } + if (!luax_istable(L, 3)) + { + luax_typerror(L, 3, "table"); + return 1; + } + Vector2 floor, ceil; + floor.x() = luax_rawgetnumber(L, 2, 1); + floor.y() = luax_rawgetnumber(L, 2, 2); + ceil.x() = luax_rawgetnumber(L, 3, 1); + ceil.y() = luax_rawgetnumber(L, 3, 2); + ps->setEmitPosition(floor, ceil); + } + else if (luax_gettop(L) >= 2) + { + if (!luax_istable(L, 2)) + { + luax_typerror(L, 2, "table"); + return 1; + } + Vector2 pos; + pos.x() = luax_rawgetnumber(L, 2, 1); + pos.y() = luax_rawgetnumber(L, 2, 2); + ps->setEmitPosition(pos); + } + return 0; + } + + LUA_IMPLEMENT int l_setParticleLife(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + if (luax_gettop(L) >= 3) + { + float floor = luax_checknumber(L, 2); + float ceil = luax_checknumber(L, 3); + ps->setParticleLife(floor, ceil); + } + else if (luax_gettop(L) >= 2) + { + float n = luax_checknumber(L, 2); + ps->setParticleLife(n); + } + return 0; + } + + LUA_IMPLEMENT int l_setParticleLinearAccelaration(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + if (!luax_istable(L, 2)) + { + luax_typerror(L, 2, "table"); + return 1; + } + Vector2 ac; + ac.x() = luax_rawgetnumber(L, 2, 1); + ac.y() = luax_rawgetnumber(L, 2, 2); + ps->setParticleLinearAccelaration(ac); + return 0; + } + + LUA_IMPLEMENT int l_setParticleRadialAccelaration(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + float ra = luax_checknumber(L, 2); + ps->setParticleRadialAccelaration(ra); + return 0; + } + + LUA_IMPLEMENT int l_setParticleAngularSpeed(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + if (luax_gettop(L) >= 3) + { + float floor = luax_checknumber(L, 2); + float ceil = luax_checknumber(L, 3); + ps->setParticleAngularSpeed(floor, ceil); + } + else if (luax_gettop(L) >= 2) + { + float n = luax_checknumber(L, 2); + ps->setParticleAngularSpeed(n); + } + return 0; + } + + LUA_IMPLEMENT int l_setParticleSpritesMode(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + int n = luax_checkinteger(L, 2); + SpriteMode mode = static_cast(n); + ps->setParticleSpritesMode(mode); + return 0; + } + + LUA_IMPLEMENT int l_addParticleSprite(lua_State* L) + { + LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem); + ParticleSystem* ps = obj->getObject(); + LuaObject* objSpr = luax_checkobject(L, 2, Jin_Lua_Sprite); + Sprite* spr = objSpr->getObject(); + ps->addParticleSprite(spr); + int depn = (*obj).getDependenciesCount(); + (*obj).setDependency((int)ParticleSystemDependency::DEP_SPRITES + depn, objSpr); + return 0; + } + + LUA_IMPLEMENT int l_addParticleSprites(lua_State* L) + { + LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem); + ParticleSystem* ps = obj->getObject(); + if (!luax_istable(L, 2)) + { + luax_typerror(L, 2, "sprites table"); + return 1; + } + int n = luax_tableidxlen(L, 2); + int depn = (*obj).getDependenciesCount(); + for (int i = 1; i <= n; ++i) + { + luax_rawgeti(L, 2, i); + LuaObject* objSpr = luax_checkobject(L, -1, Jin_Lua_Sprite); + luax_pop(L, 1); + Sprite* spr = objSpr->getObject(); + ps->addParticleSprite(spr); + (*obj).setDependency((int)ParticleSystemDependency::DEP_SPRITES + depn + i - 1, objSpr); + } + return 0; + } + + // From 0 + LUA_IMPLEMENT int l_removeParticleSprite(lua_State* L) + { + LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem); + ParticleSystem* ps = obj->getObject(); + int n = luax_checkinteger(L, 2); + ps->removeParticleSprite(n); + (*obj).removeDependency((int)ParticleSystemDependency::DEP_SPRITES + n); + return 0; + } + + LUA_IMPLEMENT int l_enableParticleBlendAdditive(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + bool enable = luax_checkbool(L, 2); + ps->enableParticleBlendAdditive(enable); + return 0; + } + + LUA_IMPLEMENT int l_setParticleScale(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + float scale = luax_checknumber(L, 2); + ps->setParticleScale(scale); + return 0; + } + + LUA_IMPLEMENT int l_addParticleScalePoint(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + float scale = luax_checknumber(L, 2); + float t = luax_checknumber(L, 3); + ps->addParticleScalePoint(scale, t); + return 0; + } + + LUA_IMPLEMENT int l_removeParticleScalePoint(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + int i = luax_checkinteger(L, 2); + ps->removeParticleScalePoint(i); + return 0; + } + + LUA_IMPLEMENT int l_setParticleColor(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + if (!luax_istable(L, 2)) + { + luax_typerror(L, 2, "color table"); + return 1; + } + Color c; + c.r = luax_rawgetnumber(L, 2, 1); + c.g = luax_rawgetnumber(L, 2, 2); + c.b = luax_rawgetnumber(L, 2, 3); + c.a = luax_rawgetnumber(L, 2, 4); + ps->setParticleColor(c); + return 0; + } + + LUA_IMPLEMENT int l_addParticleColorPoint(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + if (!luax_istable(L, 2)) + { + luax_typerror(L, 2, "color table"); + return 1; + } + Color c; + c.r = luax_rawgetnumber(L, 2, 1); + c.g = luax_rawgetnumber(L, 2, 2); + c.b = luax_rawgetnumber(L, 2, 3); + c.a = luax_rawgetnumber(L, 2, 4); + float t = luax_checknumber(L, 3); + ps->addParticleColorPoint(c, t); + return 0; + } + + LUA_IMPLEMENT int l_removeParticleColorPoint(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + int i = luax_checkinteger(L, 2); + ps->removeParticleColorPoint(i); + return 0; + } + + LUA_IMPLEMENT int l_setParticleTransparency(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + float transparency = luax_checknumber(L, 2); + ps->setParticleTransparency(transparency); + return 0; + } + + LUA_IMPLEMENT int l_addParticleTransparencyPoint(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + float transparency = luax_checknumber(L, 2); + float t = luax_checknumber(L, 3); + ps->addParticleTransparencyPoint(transparency, t); + return 0; + } + + LUA_IMPLEMENT int l_removeParticleTransparencyPoint(lua_State* L) + { + ParticleSystem* ps = checkPS(L); + int i = luax_checkinteger(L, 2); + ps->removeParticleTransparencyPoint(i); + return 0; + } + + LUA_EXPORT void luaopen_ParticleSystem(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "update", l_update }, + { "render", l_render }, + { "setPosition", l_setPosition }, + { "setScale", l_setScale }, + { "pause", l_pause }, + { "clear", l_clear }, + { "setEmitRate", l_setEmitRate }, + { "setEmitForce", l_setEmitForce }, + { "setEmitDirection", l_setEmitDirection }, + { "setEmitPosition", l_setEmitPosition }, + { "setParticleLife", l_setParticleLife }, + { "setParticleLinearAccelaration", l_setParticleLinearAccelaration }, + { "setParticleRadialAccelaration", l_setParticleRadialAccelaration }, + { "setParticleAngularSpeed", l_setParticleAngularSpeed }, + { "setParticleSpritesMode", l_setParticleSpritesMode }, + { "addParticleSprite", l_addParticleSprite }, + { "addParticleSprites", l_addParticleSprites }, + { "removeParticleSprite", l_removeParticleSprite }, + { "enableParticleBlendAdditive", l_enableParticleBlendAdditive }, + { "setParticleScale", l_setParticleScale }, + { "addParticleScalePoint", l_addParticleScalePoint }, + { "removeParticleScalePoint", l_removeParticleScalePoint }, + { "setParticleColor", l_setParticleColor }, + { "addParticleColorPoint", l_addParticleColorPoint }, + { "removeParticleColorPoint", l_removeParticleColorPoint }, + { "setParticleTransparency", l_setParticleTransparency }, + { "addParticleTransparencyPoint", l_addParticleTransparencyPoint }, + { "removeParticleTransparencyPoint", l_removeParticleTransparencyPoint }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_ParticleSystem, methods); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_particle_system.h b/src/libjin-lua/modules/graphics/l_particle_system.h new file mode 100644 index 0000000..b75b569 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_particle_system.h @@ -0,0 +1,21 @@ +#ifndef __JE_LUA_PARTICLESYSTEM_H__ +#define __JE_LUA_PARTICLESYSTEM_H__ + +namespace JinEngine +{ + namespace Lua + { + + enum class ParticleSystemDependency + { + DEP_SPRITES = 1, + }; + + extern const char* Jin_Lua_ParticleSystem; + + void luaopen_ParticleSystem(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_shader.cpp b/src/libjin-lua/modules/graphics/l_shader.cpp new file mode 100644 index 0000000..bdf82b4 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_shader.cpp @@ -0,0 +1,132 @@ +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" + +#include "l_shader.h" +#include "l_canvas.h" +#include "l_texture.h" + +using namespace JinEngine::Graphics; +using namespace JinEngine::Graphics::Shaders; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_Shader = "Shader"; + + static inline Shader* checkShader(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Shader); + return luaObj->getObject(); + } + + /** + * jsl:sendNumber("variable", 0.1) + */ + LUA_IMPLEMENT int l_sendNumber(lua_State* L) + { + Shader* shader = checkShader(L); + const char* variable = luax_checkstring(L, 2); + float number = luax_checknumber(L, 3); + shader->sendFloat(variable, number); + return 0; + } + + LUA_IMPLEMENT int l_sendTexture(lua_State* L) + { + Shader* shader = checkShader(L); + const char* variable = luax_checkstring(L, 2); + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 3, Jin_Lua_Texture); + shader->sendTexture(variable, luaObj->getObject()); + return 0; + } + + LUA_IMPLEMENT int l_sendCanvas(lua_State* L) + { + Shader* shader = checkShader(L); + const char* variable = luax_checkstring(L, 2); + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 3, Jin_Lua_Canvas); + shader->sendCanvas(variable, luaObj->getObject()); + return 0; + } + + LUA_IMPLEMENT int l_sendVec2(lua_State* L) + { + Shader* shader = checkShader(L); + const char* variable = luax_checkstring(L, 2); + if (!luax_istable(L, 3)) + { + luax_typerror(L, 3, "table"); + return 1; + } + float x = luax_rawgetnumber(L, 3, 1); + float y = luax_rawgetnumber(L, 3, 2); + shader->sendVec2(variable, x, y); + return 0; + } + + LUA_IMPLEMENT int l_sendVec3(lua_State* L) + { + Shader* shader = checkShader(L); + const char* variable = luax_checkstring(L, 2); + if (!luax_istable(L, 3)) + { + luax_typerror(L, 3, "table"); + return 1; + } + float x = luax_rawgetnumber(L, 3, 1); + float y = luax_rawgetnumber(L, 3, 2); + float z = luax_rawgetnumber(L, 3, 3); + shader->sendVec3(variable, x, y, z); + return 0; + } + + LUA_IMPLEMENT int l_sendVec4(lua_State* L) + { + Shader* shader = checkShader(L); + const char* variable = luax_checkstring(L, 2); + if (!luax_istable(L, 3)) + { + luax_typerror(L, 3, "table"); + return 1; + } + float x = luax_rawgetnumber(L, 3, 1); + float y = luax_rawgetnumber(L, 3, 2); + float z = luax_rawgetnumber(L, 3, 3); + float w = luax_rawgetnumber(L, 3, 4); + shader->sendVec4(variable, x, y, z, w); + return 0; + } + + LUA_IMPLEMENT int l_sendColor(lua_State* L) + { + return l_sendVec4(L); + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Shader); + luaObj->release(); + return 0; + } + + LUA_EXPORT void luaopen_Shader(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "sendNumber", l_sendNumber }, + { "sendTexture", l_sendTexture }, + { "sendCanvas", l_sendCanvas }, + { "sendVec2", l_sendVec2 }, + { "sendVec3", l_sendVec3 }, + { "sendVec4", l_sendVec4 }, + { "sendColor", l_sendColor }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Shader, methods); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_shader.h b/src/libjin-lua/modules/graphics/l_shader.h new file mode 100644 index 0000000..5a84372 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_shader.h @@ -0,0 +1,16 @@ +#ifndef __JE_LUA_SHDER_H__ +#define __JE_LUA_SHDER_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Shader; + + void luaopen_Shader(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_sprite.cpp b/src/libjin-lua/modules/graphics/l_sprite.cpp new file mode 100644 index 0000000..1469042 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_sprite.cpp @@ -0,0 +1,66 @@ +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" + +#include "l_sprite.h" +#include "l_canvas.h" +#include "l_texture.h" +#include "l_shader.h" + +using namespace JinEngine::Math; +using namespace JinEngine::Graphics; +using namespace JinEngine::Graphics::Shaders; + +namespace JinEngine +{ + namespace Lua + { + const char* Jin_Lua_Sprite = "Sprite"; + + LUA_IMPLEMENT inline Sprite* checkSprite(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Sprite); + return luaObj->getObject(); + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Sprite); + p->release(); + return 0; + } + + LUA_IMPLEMENT int l_render(lua_State* L) + { + Sprite* sprite = checkSprite(L); + float x = luax_checknumber(L, 2); + float y = luax_checknumber(L, 3); + float sx = luax_checknumber(L, 4); + float sy = luax_checknumber(L, 5); + float r = luax_checknumber(L, 6); + sprite->render(x, y, sx, sy, r); + return 0; + } + + LUA_IMPLEMENT int l_getSize(lua_State* L) + { + Sprite* sprite = checkSprite(L); + Vector2 size = sprite->getSize(); + luax_pushinteger(L, size.x()); + luax_pushinteger(L, size.y()); + return 1; + } + + LUA_EXPORT void luaopen_Sprite(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "render", l_render }, + { "getSize", l_getSize }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Sprite, methods); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_sprite.h b/src/libjin-lua/modules/graphics/l_sprite.h new file mode 100644 index 0000000..02c44bf --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_sprite.h @@ -0,0 +1,24 @@ +#ifndef __JE_LUA_SPRITE_H__ +#define __JE_LUA_SPRITE_H__ + +namespace JinEngine +{ + namespace Lua + { + + // Sprite dependency slots. + enum class SpriteDependency + { + DEP_GRAPHIC = 1, + DEP_SHADER = 2, + DEP_SPRITESHEET = 3 + }; + + extern const char* Jin_Lua_Sprite; + + void luaopen_Sprite(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_spritesheet.cpp b/src/libjin-lua/modules/graphics/l_spritesheet.cpp new file mode 100644 index 0000000..e8400c3 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_spritesheet.cpp @@ -0,0 +1,118 @@ +#include + +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" +#include "l_sprite.h" +#include "l_spritesheet.h" + +using namespace std; +using namespace JinEngine::Math; +using namespace JinEngine::Graphics; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_SpriteSheet = "SpriteSheet"; + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* luaSSheet = (LuaObject*)luax_checktype(L, 1, Jin_Lua_SpriteSheet); + luaSSheet->release(); + return 0; + } + + LUA_IMPLEMENT int l_newSprite(lua_State* L) + { + LuaObject* luaSSheet = (LuaObject*)luax_checktype(L, 1, Jin_Lua_SpriteSheet); + SpriteSheet* sheet = luaSSheet->getObject(); + Quad quad; + quad.x = luax_rawgetnumberthenpop(L, 2, 1); + quad.y = luax_rawgetnumberthenpop(L, 2, 2); + quad.w = luax_rawgetnumberthenpop(L, 2, 3); + quad.h = luax_rawgetnumberthenpop(L, 2, 4); + Sprite* spr = nullptr; + if (luax_gettop(L) >= 4) + { + float ox = luax_checknumber(L, 3); + float oy = luax_checknumber(L, 4); + spr = sheet->createSprite(quad, ox, oy); + } + else if (luax_gettop(L) == 3) + { + int o = luax_checkinteger(L, 3); + Origin origin; + origin = static_cast(o); + spr = sheet->createSprite(quad, origin); + } + Shared* shrSprite = new Shared(spr); + LuaObject* luaSprite = luax_newinstance(L, Jin_Lua_Sprite, shrSprite); + luaSprite->setDependency((int)SpriteDependency::DEP_SPRITESHEET, luaSSheet); + return 1; + } + + // {} = newSprites + LUA_IMPLEMENT int l_newSprites(lua_State* L) + { + LuaObject* luaSS = (LuaObject*)luax_checktype(L, 1, Jin_Lua_SpriteSheet); + SpriteSheet* ss = luaSS->getObject(); + int count = luax_checkinteger(L, 2); + int r = luax_checkinteger(L, 3); + int c = luax_checkinteger(L, 4); + int w = luax_checkinteger(L, 5); + int h = luax_checkinteger(L, 6); + vector sprs; + int argc = luax_gettop(L); + if (argc == 6) + { + sprs = ss->createSprites(count, r, c, w, h, Origin::TOPLEFT); + } + else if (argc >= 8) + { + int ox = luax_checkinteger(L, 7); + int oy = luax_checkinteger(L, 8); + int offx = luax_optinteger(L, 9, 0); + int offy = luax_optinteger(L, 10, 0); + sprs = ss->createSprites(count, r, c, w, h, ox, oy, offx, offy); + } + else if (argc >= 7) + { + int o = luax_checkinteger(L, 7); + Origin origin = static_cast(o); + int offx = luax_optinteger(L, 8, 0); + int offy = luax_optinteger(L, 9, 0); + sprs = ss->createSprites(count, r, c, w, h, origin, offx, offy); + } + else + { + luax_error(L, "No matched override function."); + return 1; + } + luax_newtable(L); + LuaObject* graphic = luaSS->getDependency((int)SpriteSheetDependency::DEP_GRAPHIC); + for (int i = 0; i < sprs.size(); ++i) + { + Sprite* spr = sprs[i]; + Shared* shrSpr = new Shared(spr); + LuaObject* luaSpr = (LuaObject*)luax_newinstance(L, Jin_Lua_Sprite, shrSpr); + luaSpr->setDependency((int)SpriteDependency::DEP_GRAPHIC, graphic); + luax_rawseti(L, -2, i + 1); + } + return 1; + } + + LUA_EXPORT void luaopen_SpriteSheet(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "newSprite", l_newSprite }, + { "newSprites", l_newSprites }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_SpriteSheet, methods); + } + + } +} \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_spritesheet.h b/src/libjin-lua/modules/graphics/l_spritesheet.h new file mode 100644 index 0000000..bcae60b --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_spritesheet.h @@ -0,0 +1,21 @@ +#ifndef __JE_LUA_SPRITE_SHEET_H__ +#define __JE_LUA_SPRITE_SHEET_H__ + +namespace JinEngine +{ + namespace Lua + { + + enum class SpriteSheetDependency + { + DEP_GRAPHIC = 1 + }; + + extern const char* Jin_Lua_SpriteSheet; + + void luaopen_SpriteSheet(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_text.cpp b/src/libjin-lua/modules/graphics/l_text.cpp new file mode 100644 index 0000000..b634947 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_text.cpp @@ -0,0 +1,31 @@ +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" + +using namespace JinEngine::Graphics; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_Text = "Text"; + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Text); + p->release(); + return 0; + } + + LUA_EXPORT void luaopen_Text(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Text, methods); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_text.h b/src/libjin-lua/modules/graphics/l_text.h new file mode 100644 index 0000000..dfcc9cc --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_text.h @@ -0,0 +1,16 @@ +#ifndef __JE_LUA_TEXT_H__ +#define __JE_LUA_TEXT_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Text; + + void luaopen_Text(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_texture.cpp b/src/libjin-lua/modules/graphics/l_texture.cpp new file mode 100644 index 0000000..efef2cb --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_texture.cpp @@ -0,0 +1,63 @@ +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" +#include "l_texture.h" + +using namespace JinEngine::Graphics; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_Texture = "Texture"; + + LUA_IMPLEMENT inline Texture* checkTexture(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Texture); + return luaObj->getObject(); + } + + LUA_IMPLEMENT int l_getWidth(lua_State* L) + { + Texture* shared = checkTexture(L); + luax_pushnumber(L, shared->getWidth()); + return 1; + } + + LUA_IMPLEMENT int l_getHeight(lua_State *L) + { + Texture* shared = checkTexture(L); + luax_pushnumber(L, shared->getHeight()); + return 1; + } + + LUA_IMPLEMENT int l_getSize(lua_State* L) + { + Texture* shared = checkTexture(L); + luax_pushnumber(L, shared->getWidth()); + luax_pushnumber(L, shared->getHeight()); + return 2; + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Texture); + luaObj->release(); + return 0; + } + + LUA_EXPORT void luaopen_Texture(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "getWidth", l_getWidth }, + { "getHeight", l_getHeight }, + { "getSize", l_getSize }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Texture, methods); + } + + }// namespace Lua +}// namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_texture.h b/src/libjin-lua/modules/graphics/l_texture.h new file mode 100644 index 0000000..c8bb71c --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_texture.h @@ -0,0 +1,16 @@ +#ifndef __JE_LUA_TEXTURE_H__ +#define __JE_LUA_TEXTURE_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Texture; + + void luaopen_Texture(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_texture_font.cpp b/src/libjin-lua/modules/graphics/l_texture_font.cpp new file mode 100644 index 0000000..d9801ef --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_texture_font.cpp @@ -0,0 +1,63 @@ +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" + +#include "l_page.h" +#include "l_text.h" + +using namespace JinEngine::Graphics; +using namespace JinEngine::Graphics::Fonts; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_TextureFont = "TextureFont"; + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TextureFont); + luaObj->release(); + return 0; + } + + /* typeset(Text | string, lineheight, spacing) */ + LUA_IMPLEMENT int l_typeset(lua_State* L) + { + LuaObject* luaTexFont = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TextureFont); + TextureFont* tf = luaTexFont->getObject(); + int lineheight = luax_checkinteger(L, 3); + int spacing = luax_optnumber(L, 4, 0); + Page* page = nullptr; + if (luax_isstring(L, 2)) + { + unsigned length; + const char* str = luax_checklstring(L, 2, &length); + Text text(Encode::UTF8, str, length); + page = tf->typeset(text, lineheight, spacing); + } + else if (luax_istype(L, 2, Jin_Lua_Text)) + { + LuaObject* p2 = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Text); + Text* text = p2->getObject(); + page = tf->typeset(*text, lineheight, spacing); + } + Shared* shrPage = new Shared(page); + LuaObject* luaPage = luax_newinstance(L, Jin_Lua_Page, shrPage); + luaPage->setDependency((int)PageDependency::DEP_TEXTURE_FONT, luaTexFont); + return 1; + } + + LUA_EXPORT void luaopen_TextureFont(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "typeset", l_typeset }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_TextureFont, methods); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_texture_font.h b/src/libjin-lua/modules/graphics/l_texture_font.h new file mode 100644 index 0000000..d1fffe5 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_texture_font.h @@ -0,0 +1,16 @@ +#ifndef __JE_LUA_TEXTURE_FONT_H__ +#define __JE_LUA_TEXTURE_FONT_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_TextureFont; + + void luaopen_TextureFont(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_ttf.cpp b/src/libjin-lua/modules/graphics/l_ttf.cpp new file mode 100644 index 0000000..cc9db8e --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_ttf.cpp @@ -0,0 +1,63 @@ +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" + +#include "l_page.h" +#include "l_text.h" + +using namespace JinEngine::Graphics; +using namespace JinEngine::Graphics::Fonts; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_TTF = "TTF"; + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TTF); + luaObj->release(); + return 0; + } + + /* typeset(Text | string, lineheight, spacing) */ + LUA_IMPLEMENT int l_typeset(lua_State* L) + { + LuaObject* luaTTF = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TTF); + TTF* ttf = luaTTF->getObject(); + int lineheight = luax_optnumber(L, 3, ttf->getFontSize()); + int spacing = luax_optnumber(L, 4, 0); + Page* page = nullptr; + if (luax_isstring(L, 2)) + { + unsigned length; + const char* str = luax_checklstring(L, 2, &length); + Text text(Encode::UTF8, str, length); + page = ttf->typeset(text, lineheight, spacing); + } + else if (luax_istype(L, 2, Jin_Lua_Text)) + { + LuaObject* luaText = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Text); + Text* text = luaText->getObject(); + page = ttf->typeset(*text, lineheight, spacing); + } + Shared* refPage = new Shared(page); + LuaObject* luaPage = luax_newinstance(L, Jin_Lua_Page, refPage); + luaPage->setDependency((int)PageDependency::DEP_TTF, luaTTF); + return 1; + } + + LUA_EXPORT void luaopen_TTF(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "typeset", l_typeset }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_TTF, methods); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_ttf.h b/src/libjin-lua/modules/graphics/l_ttf.h new file mode 100644 index 0000000..bfe503d --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_ttf.h @@ -0,0 +1,16 @@ +#ifndef __JE_LUA_TTF_H__ +#define __JE_LUA_TTF_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_TTF; + + void luaopen_TTF(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_ttf_data.cpp b/src/libjin-lua/modules/graphics/l_ttf_data.cpp new file mode 100644 index 0000000..1c8c653 --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_ttf_data.cpp @@ -0,0 +1,49 @@ +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" + +#include "l_ttf.h" +#include "l_ttf_data.h" + +using namespace JinEngine::Graphics; +using namespace JinEngine::Graphics::Fonts; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_TTFData = "TTFData"; + + LUA_IMPLEMENT int l_newTTF(lua_State* L) + { + LuaObject* luaTTFData = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TTFData); + int fontsize = luax_checkinteger(L, 2); + TTFData* fontData = luaTTFData->getObject(); + TTF* font = fontData->createTTF(fontsize); + Shared* shrTTF = new Shared(font); + LuaObject* luaTTF = luax_newinstance(L, Jin_Lua_TTF, shrTTF); + luaTTF->setDependency((int)TTFDependency::DEP_TTFDATA, luaTTFData); + return 1; + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TTFData); + p->release(); + return 0; + } + + LUA_EXPORT void luaopen_TTFData(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "newTTF", l_newTTF }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_TTFData, methods); + + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/graphics/l_ttf_data.h b/src/libjin-lua/modules/graphics/l_ttf_data.h new file mode 100644 index 0000000..1fd832d --- /dev/null +++ b/src/libjin-lua/modules/graphics/l_ttf_data.h @@ -0,0 +1,21 @@ +#ifndef __JE_LUA_TTFDATA_H__ +#define __JE_LUA_TTFDATA_H__ + +namespace JinEngine +{ + namespace Lua + { + + enum class TTFDependency + { + DEP_TTFDATA = 1, + }; + + extern const char* Jin_Lua_TTFData; + + void luaopen_TTFData(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/je_lua_modules.h b/src/libjin-lua/modules/je_lua_modules.h deleted file mode 100644 index afe0a82..0000000 --- a/src/libjin-lua/modules/je_lua_modules.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __JE_LUA_MODULES_H__ -#define __JE_LUA_MODULES_H__ - -#include "ai/je_lua_ai.h" -#include "audio/je_lua_audio.h" -#include "bit/je_lua_bit.h" -#include "core/je_lua_core.h" -#include "event/je_lua_event.h" -#include "filesystem/je_lua_filesystem.h" -#include "graphics/je_lua_graphics.h" -#include "joypad/je_lua_joypad.h" -#include "keyboard/je_lua_keyboard.h" -#include "math/je_lua_math.h" -#include "mouse/je_lua_mouse.h" -#include "net/je_lua_net.h" -#include "thread/je_lua_thread.h" -#include "time/je_lua_time.h" - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/joypad/je_lua_joypad.cpp b/src/libjin-lua/modules/joypad/je_lua_joypad.cpp deleted file mode 100644 index a3623ae..0000000 --- a/src/libjin-lua/modules/joypad/je_lua_joypad.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" - -namespace JinEngine -{ - namespace Lua - { - - LUA_EXPORT int luaopen_joypad(lua_State* L) - { - luaL_Reg methods[] = { - { 0, 0 } - }; - luax_newlib(L, methods); - - return 1; - } - /*SDL_JoystickGetButton*/ - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/joypad/je_lua_joypad.h b/src/libjin-lua/modules/joypad/je_lua_joypad.h deleted file mode 100644 index ec0e20f..0000000 --- a/src/libjin-lua/modules/joypad/je_lua_joypad.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __JE_LUA_JOYPAD_H__ -#define __JE_LUA_JOYPAD_H__ - -namespace JinEngine -{ - namespace Lua - { - - int luaopen_joypad(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/joypad/l_joypad.cpp b/src/libjin-lua/modules/joypad/l_joypad.cpp new file mode 100644 index 0000000..a955978 --- /dev/null +++ b/src/libjin-lua/modules/joypad/l_joypad.cpp @@ -0,0 +1,21 @@ +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" + +namespace JinEngine +{ + namespace Lua + { + + LUA_EXPORT int luaopen_joypad(lua_State* L) + { + luaL_Reg methods[] = { + { 0, 0 } + }; + luax_newlib(L, methods); + + return 1; + } + /*SDL_JoystickGetButton*/ + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/joypad/l_joypad.h b/src/libjin-lua/modules/joypad/l_joypad.h new file mode 100644 index 0000000..ec0e20f --- /dev/null +++ b/src/libjin-lua/modules/joypad/l_joypad.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_JOYPAD_H__ +#define __JE_LUA_JOYPAD_H__ + +namespace JinEngine +{ + namespace Lua + { + + int luaopen_joypad(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/keyboard/je_lua_keyboard.cpp b/src/libjin-lua/modules/keyboard/je_lua_keyboard.cpp deleted file mode 100644 index 93a62bd..0000000 --- a/src/libjin-lua/modules/keyboard/je_lua_keyboard.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "common/je_lua_common.h" -#include "common/je_lua_object.h" - -namespace JinEngine -{ - namespace Lua - { - //https://wiki.libsdl.org/SDL_Keycode - - LUA_EXPORT int luaopen_keyboard(lua_State* L) - { - luax_newlib(L, 0); - return 1; - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/keyboard/je_lua_keyboard.h b/src/libjin-lua/modules/keyboard/je_lua_keyboard.h deleted file mode 100644 index bf00f83..0000000 --- a/src/libjin-lua/modules/keyboard/je_lua_keyboard.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __JE_LUA_KEYBOARD_H__ -#define __JE_LUA_KEYBOARD_H__ - -namespace JinEngine -{ - namespace Lua - { - - int luaopen_keyboard(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/keyboard/l_keyboard.cpp b/src/libjin-lua/modules/keyboard/l_keyboard.cpp new file mode 100644 index 0000000..4eba31d --- /dev/null +++ b/src/libjin-lua/modules/keyboard/l_keyboard.cpp @@ -0,0 +1,17 @@ +#include "common/l_common.h" +#include "common/l_object.h" + +namespace JinEngine +{ + namespace Lua + { + //https://wiki.libsdl.org/SDL_Keycode + + LUA_EXPORT int luaopen_keyboard(lua_State* L) + { + luax_newlib(L, 0); + return 1; + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/keyboard/l_keyboard.h b/src/libjin-lua/modules/keyboard/l_keyboard.h new file mode 100644 index 0000000..bf00f83 --- /dev/null +++ b/src/libjin-lua/modules/keyboard/l_keyboard.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_KEYBOARD_H__ +#define __JE_LUA_KEYBOARD_H__ + +namespace JinEngine +{ + namespace Lua + { + + int luaopen_keyboard(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/l_modules.h b/src/libjin-lua/modules/l_modules.h new file mode 100644 index 0000000..b2636dd --- /dev/null +++ b/src/libjin-lua/modules/l_modules.h @@ -0,0 +1,19 @@ +#ifndef __JE_LUA_MODULES_H__ +#define __JE_LUA_MODULES_H__ + +#include "ai/l_ai.h" +#include "audio/l_audio.h" +#include "bit/l_bit.h" +#include "core/l_core.h" +#include "event/l_event.h" +#include "filesystem/l_filesystem.h" +#include "graphics/l_graphics.h" +#include "joypad/l_joypad.h" +#include "keyboard/l_keyboard.h" +#include "math/l_math.h" +#include "mouse/l_mouse.h" +#include "net/l_net.h" +#include "thread/l_thread.h" +#include "time/l_time.h" + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/math/je_lua_math.cpp b/src/libjin-lua/modules/math/je_lua_math.cpp deleted file mode 100644 index 5b320ff..0000000 --- a/src/libjin-lua/modules/math/je_lua_math.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "common/je_lua_common.h" -#include "common/je_lua_object.h" -#include "libjin/jin.h" - -namespace JinEngine -{ - namespace Lua - { - - LUA_IMPLEMENT int l_mod(lua_State* L) - { - int n = luax_checkinteger(L, 1); - int m = luax_checkinteger(L, 2); - int mod = n % m; - luax_pushinteger(L, mod); - return 1; - } - - LUA_EXPORT int luaopen_math(lua_State* L) - { - luaL_Reg methods[] = { - { "mod", l_mod }, - { 0, 0 } - }; - luax_newlib(L, methods); - return 1; - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/math/je_lua_math.h b/src/libjin-lua/modules/math/je_lua_math.h deleted file mode 100644 index 2e7010c..0000000 --- a/src/libjin-lua/modules/math/je_lua_math.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __JE_LUA_MATH_H__ -#define __JE_LUA_MATH_H__ - -namespace JinEngine -{ - namespace Lua - { - - int luaopen_math(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/math/l_math.cpp b/src/libjin-lua/modules/math/l_math.cpp new file mode 100644 index 0000000..f7caa16 --- /dev/null +++ b/src/libjin-lua/modules/math/l_math.cpp @@ -0,0 +1,30 @@ +#include "common/l_common.h" +#include "common/l_object.h" +#include "libjin/jin.h" + +namespace JinEngine +{ + namespace Lua + { + + LUA_IMPLEMENT int l_mod(lua_State* L) + { + int n = luax_checkinteger(L, 1); + int m = luax_checkinteger(L, 2); + int mod = n % m; + luax_pushinteger(L, mod); + return 1; + } + + LUA_EXPORT int luaopen_math(lua_State* L) + { + luaL_Reg methods[] = { + { "mod", l_mod }, + { 0, 0 } + }; + luax_newlib(L, methods); + return 1; + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/math/l_math.h b/src/libjin-lua/modules/math/l_math.h new file mode 100644 index 0000000..2e7010c --- /dev/null +++ b/src/libjin-lua/modules/math/l_math.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_MATH_H__ +#define __JE_LUA_MATH_H__ + +namespace JinEngine +{ + namespace Lua + { + + int luaopen_math(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/mouse/je_lua_mouse.cpp b/src/libjin-lua/modules/mouse/je_lua_mouse.cpp deleted file mode 100644 index 222f596..0000000 --- a/src/libjin-lua/modules/mouse/je_lua_mouse.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "common/je_lua_common.h" -#include "common/je_lua_object.h" -#include "libjin/jin.h" - -using namespace JinEngine::Input; - -namespace JinEngine -{ - namespace Lua - { - - LUA_IMPLEMENT int l_pos(lua_State* L) - { - static Mouse* mouse = Mouse::get(); - int x, y; - mouse->getState(&x, &y); - luax_pushnumber(L, x); - luax_pushnumber(L, y); - return 2; - } - - LUA_IMPLEMENT int l_setVisible(lua_State* L) - { - bool visible = luax_checkbool(L, 1); - Mouse* mouse = Mouse::get(); - mouse->setVisible(visible); - return 0; - } - - LUA_EXPORT int luaopen_mouse(lua_State* L) - { - luaL_Reg methods[] = { - { "getPosition", l_pos }, - { "setVisible", l_setVisible }, - { 0, 0 } - }; - luax_newlib(L, methods); - return 1; - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/mouse/je_lua_mouse.h b/src/libjin-lua/modules/mouse/je_lua_mouse.h deleted file mode 100644 index 09738f5..0000000 --- a/src/libjin-lua/modules/mouse/je_lua_mouse.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __JE_LUA_MOUSE_H__ -#define __JE_LUA_MOUSE_H__ - -namespace JinEngine -{ - namespace Lua - { - - int luaopen_mouse(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/mouse/l_mouse.cpp b/src/libjin-lua/modules/mouse/l_mouse.cpp new file mode 100644 index 0000000..f6864ee --- /dev/null +++ b/src/libjin-lua/modules/mouse/l_mouse.cpp @@ -0,0 +1,42 @@ +#include "common/l_common.h" +#include "common/l_object.h" +#include "libjin/jin.h" + +using namespace JinEngine::Input; + +namespace JinEngine +{ + namespace Lua + { + + LUA_IMPLEMENT int l_pos(lua_State* L) + { + static Mouse* mouse = Mouse::get(); + int x, y; + mouse->getState(&x, &y); + luax_pushnumber(L, x); + luax_pushnumber(L, y); + return 2; + } + + LUA_IMPLEMENT int l_setVisible(lua_State* L) + { + bool visible = luax_checkbool(L, 1); + Mouse* mouse = Mouse::get(); + mouse->setVisible(visible); + return 0; + } + + LUA_EXPORT int luaopen_mouse(lua_State* L) + { + luaL_Reg methods[] = { + { "getPosition", l_pos }, + { "setVisible", l_setVisible }, + { 0, 0 } + }; + luax_newlib(L, methods); + return 1; + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/mouse/l_mouse.h b/src/libjin-lua/modules/mouse/l_mouse.h new file mode 100644 index 0000000..09738f5 --- /dev/null +++ b/src/libjin-lua/modules/mouse/l_mouse.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_MOUSE_H__ +#define __JE_LUA_MOUSE_H__ + +namespace JinEngine +{ + namespace Lua + { + + int luaopen_mouse(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/net/je_lua_buffer.cpp b/src/libjin-lua/modules/net/je_lua_buffer.cpp deleted file mode 100644 index 10e7143..0000000 --- a/src/libjin-lua/modules/net/je_lua_buffer.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" -#include "je_lua_buffer.h" - -using namespace JinEngine::Lua::Net; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_Buffer = "Buffer"; - - static inline Net::Buffer* checkNetBuffer(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Buffer); - return luaObj->getObject(); - } - - // net.Buffer:append(value) -> value_length - LUA_IMPLEMENT int l_append(lua_State* L) - { - Buffer* buffer = checkNetBuffer(L); - const int vp = 2; - if (luax_isintegerstrict(L, vp)) - { - int n = luax_checkinteger(L, vp); - int size = sizeof(n); - buffer->append(&n, size); - luax_pushinteger(L, size); - return 1; - } - else if (luax_isfloatstrict(L, vp)) - { - float n = luax_checknumber(L, vp); - int size = sizeof(n); - buffer->append(&n, size); - luax_pushinteger(L, size); - return 1; - } - else if (luax_isbooleanstrict(L, vp)) - { - bool n = luax_checkbool(L, vp); - int size = sizeof(n); - buffer->append(&n, size); - luax_pushinteger(L, size); - return 1; - } - else if (luax_isstringstrict(L, vp)) - { - const char* str = luax_checkstring(L, vp); - int size = strlen(str) + 1; - buffer->append(str, size); - luax_pushinteger(L, size); - return 1; - } - else - { - luax_typerror(L, vp, "number, bool or string"); - return 0; - } - } - - // net.Buffer:grabString(offset) -> string, length - LUA_IMPLEMENT int l_grabString(lua_State* L) - { - Buffer* buffer = checkNetBuffer(L); - int offset = luax_checkinteger(L, 2); - unsigned int len; - char* data = buffer->grabString(&len, offset); - Array str; - str.bind(data, len); - luax_pushstring(L, &str); - luax_pushinteger(L, str.count()); - return 2; - } - - // net.Buffer:grabInteger(offset) -> integer, length - LUA_IMPLEMENT int l_grabInteger(lua_State* L) - { - Buffer* buffer = checkNetBuffer(L); - int offset = luax_checkinteger(L, 2); - int len; - int integer = buffer->grabInteger(&len, offset); - luax_pushinteger(L, integer); - luax_pushinteger(L, len); - return 2; - } - - LUA_IMPLEMENT int l_grabFloat(lua_State* L) - { - Buffer* buffer = checkNetBuffer(L); - int offset = luax_checkinteger(L, 2); - int len; - float floatv = buffer->grabFloat(&len, offset); - luax_pushnumber(L, floatv); - luax_pushinteger(L, len); - return 2; - } - - LUA_IMPLEMENT int l_grabBoolean(lua_State* L) - { - Buffer* buffer = checkNetBuffer(L); - int offset = luax_checkinteger(L, 2); - int len; - bool boolean = buffer->grabBoolean(&len, offset); - luax_pushboolean(L, boolean); - luax_pushinteger(L, len); - return 2; - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Buffer); - luaObj->release(); - return 0; - } - - LUA_EXPORT void luaopen_Buffer(lua_State* L) - { - luaL_Reg netbuffer_function[] = { - { "__gc", l_gc }, - { "append", l_append }, - { "grabString", l_grabString }, - { "grabInteger", l_grabInteger }, - { "grabBoolean", l_grabBoolean }, - { "grabFloat", l_grabFloat }, - { 0, 0 } - }; - - luax_newtype(L, Jin_Lua_Buffer, netbuffer_function); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/net/je_lua_buffer.h b/src/libjin-lua/modules/net/je_lua_buffer.h deleted file mode 100644 index 974e23a..0000000 --- a/src/libjin-lua/modules/net/je_lua_buffer.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef __JIN_LUA_NET_NETBUFFER_H -#define __JIN_LUA_NET_NETBUFFER_H - -#include -#include -#include "common/je_lua_common.h" - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_Buffer; - - void luaopen_Buffer(lua_State* L); - - namespace Net - { - - class Buffer : public Object - { - public: - Buffer(size_t s = 0) - : size(s) - { - buffer = new char[size]; - memset(buffer, 0, size); - } - - Buffer(const char* data, size_t s) - : size(s) - { - buffer = new char[size]; - memcpy(buffer, data, size); - } - - ~Buffer() - { - if (buffer != nullptr) - { - delete[] buffer; - buffer = nullptr; - size = 0; - } - } - - void append(const void* data, size_t s) - { - if (data == nullptr) - return; - char* buf = buffer; - buffer = new char[size + s]; - memcpy(buffer, buf, size); - memcpy(buffer + size, data, s); - delete[] buf; - size += s; - return; - } - - /* grab and create a string */ - char* grabString(unsigned int* length, int offset = 0) - { - int l = offset; - for (; l < size; ++l) - { - if (buffer[l] == 0) - break; - } - *length = l - offset + 1; - char* str = (char*)malloc(*length); - memcpy(str, buffer + offset, *length); - return str; - } - - int grabInteger(int* length, int offset = 0) - { - *length = sizeof(int); - return *((int*)(buffer + offset)); - } - - float grabFloat(int* length, int offset = 0) - { - *length = sizeof(float); - return *((float*)(buffer + offset)); - } - - bool grabBoolean(int* length, int offset = 0) - { - *length = sizeof(bool); - return *((bool*)(buffer + offset)); - } - - char* buffer; - size_t size; - - }; - - } // namespace Net - } // namespace Lua -} // namespace JinEngine - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/net/je_lua_net.cpp b/src/libjin-lua/modules/net/je_lua_net.cpp deleted file mode 100644 index fad6fc5..0000000 --- a/src/libjin-lua/modules/net/je_lua_net.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "common/je_lua_object.h" -#include "libjin/jin.h" -#include "common/je_lua_common.h" - -#include "je_lua_buffer.h" -#include "je_lua_socket.h" - -namespace JinEngine -{ - namespace Lua - { - - using namespace JinEngine::Lua::Net; - using namespace JinEngine::Net; - - 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 }; - { - 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)); - 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)); - return 1; - } - - 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); - return 1; - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/net/je_lua_net.h b/src/libjin-lua/modules/net/je_lua_net.h deleted file mode 100644 index 1542791..0000000 --- a/src/libjin-lua/modules/net/je_lua_net.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __JE_LUA_NET_H__ -#define __JE_LUA_NET_H__ - -namespace JinEngine -{ - namespace Lua - { - - int luaopen_net(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/net/je_lua_socket.cpp b/src/libjin-lua/modules/net/je_lua_socket.cpp deleted file mode 100644 index d6cfe91..0000000 --- a/src/libjin-lua/modules/net/je_lua_socket.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" -#include "je_lua_buffer.h" - -using namespace JinEngine::Net; -using namespace JinEngine::Lua::Net; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_Socket = "Socket"; - - const int BUFFER_SIZE = 1024; - - LUA_IMPLEMENT inline Socket* checkSocket(lua_State* L, int pos = 1) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, pos, Jin_Lua_Socket); - return luaObj->getObject(); - } - - LUA_IMPLEMENT inline Buffer* checkNetBuffer(lua_State* L, int pos = 1) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, pos, Jin_Lua_Buffer); - return luaObj->getObject(); - } - - // return net.Socket - LUA_IMPLEMENT int l_accept(lua_State* L) - { - Socket* socket = checkSocket(L); - Socket* client = socket->accept(); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Socket, new Shared(client)); - return 1; - } - - // return net.Buffer - LUA_IMPLEMENT int l_receive(lua_State* L) - { - Socket* socket = checkSocket(L); - char buffer[BUFFER_SIZE] = {0}; - int size = socket->receive(buffer, BUFFER_SIZE); - Net::Buffer* netBuffer = new Net::Buffer(buffer, size); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared(netBuffer)); - return 1; - } - - // Socket:receiveFrom(address, port) - LUA_IMPLEMENT int l_receiveFrom(lua_State* L) - { - Socket* socket = checkSocket(L); - int address = luax_checkinteger(L, 2); - int port = luax_checkinteger(L, 3); - char buffer[BUFFER_SIZE]; - int size = socket->receiveFrom(buffer, BUFFER_SIZE, address, port); - Net::Buffer* netBuffer = new Net::Buffer(buffer, size); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared(netBuffer)); - return 1; - } - - // Socket:send(net.Buffer) -> data_length - LUA_IMPLEMENT int l_send(lua_State* L) - { - Socket* socket = checkSocket(L); - Buffer* buffer = checkNetBuffer(L, 2); - int len = socket->send(buffer->buffer, buffer->size); - luax_pushinteger(L, len); - return 1; - } - - // Socket:sendTo(address, port, net.Buffer) - LUA_IMPLEMENT int l_sendTo(lua_State* L) - { - Socket* socket = checkSocket(L); - int address = luax_checkinteger(L, 2); - int port = luax_checkinteger(L, 3); - Buffer* buffer = checkNetBuffer(L, 4); - socket->sendTo(buffer->buffer, buffer->size, address, port); - return 0; - } - - LUA_IMPLEMENT int l_close(lua_State* L) - { - Socket* socket = checkSocket(L); - socket->close(); - return 0; - } - - LUA_IMPLEMENT int l_configBlocking(lua_State* L) - { - Socket* socket = checkSocket(L); - bool blocking = luax_checkbool(L, 2); - socket->configureBlocking(blocking); - return 0; - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Socket); - luaObj->release(); - return 0; - } - - LUA_EXPORT void luaopen_Socket(lua_State* L) - { - 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 }, - { "configBlocking", l_configBlocking }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Socket, socket_function); - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/net/je_lua_socket.h b/src/libjin-lua/modules/net/je_lua_socket.h deleted file mode 100644 index b33fac6..0000000 --- a/src/libjin-lua/modules/net/je_lua_socket.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __JE_LUA_SOCKET_H__ -#define __JE_LUA_SOCKET_H__ - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_Socket; - - void luaopen_Socket(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/net/l_buffer.cpp b/src/libjin-lua/modules/net/l_buffer.cpp new file mode 100644 index 0000000..546787e --- /dev/null +++ b/src/libjin-lua/modules/net/l_buffer.cpp @@ -0,0 +1,136 @@ +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" +#include "l_buffer.h" + +using namespace JinEngine::Lua::Net; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_Buffer = "Buffer"; + + static inline Net::Buffer* checkNetBuffer(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Buffer); + return luaObj->getObject(); + } + + // net.Buffer:append(value) -> value_length + LUA_IMPLEMENT int l_append(lua_State* L) + { + Buffer* buffer = checkNetBuffer(L); + const int vp = 2; + if (luax_isintegerstrict(L, vp)) + { + int n = luax_checkinteger(L, vp); + int size = sizeof(n); + buffer->append(&n, size); + luax_pushinteger(L, size); + return 1; + } + else if (luax_isfloatstrict(L, vp)) + { + float n = luax_checknumber(L, vp); + int size = sizeof(n); + buffer->append(&n, size); + luax_pushinteger(L, size); + return 1; + } + else if (luax_isbooleanstrict(L, vp)) + { + bool n = luax_checkbool(L, vp); + int size = sizeof(n); + buffer->append(&n, size); + luax_pushinteger(L, size); + return 1; + } + else if (luax_isstringstrict(L, vp)) + { + const char* str = luax_checkstring(L, vp); + int size = strlen(str) + 1; + buffer->append(str, size); + luax_pushinteger(L, size); + return 1; + } + else + { + luax_typerror(L, vp, "number, bool or string"); + return 0; + } + } + + // net.Buffer:grabString(offset) -> string, length + LUA_IMPLEMENT int l_grabString(lua_State* L) + { + Buffer* buffer = checkNetBuffer(L); + int offset = luax_checkinteger(L, 2); + unsigned int len; + char* data = buffer->grabString(&len, offset); + Array str; + str.bind(data, len); + luax_pushstring(L, &str); + luax_pushinteger(L, str.count()); + return 2; + } + + // net.Buffer:grabInteger(offset) -> integer, length + LUA_IMPLEMENT int l_grabInteger(lua_State* L) + { + Buffer* buffer = checkNetBuffer(L); + int offset = luax_checkinteger(L, 2); + int len; + int integer = buffer->grabInteger(&len, offset); + luax_pushinteger(L, integer); + luax_pushinteger(L, len); + return 2; + } + + LUA_IMPLEMENT int l_grabFloat(lua_State* L) + { + Buffer* buffer = checkNetBuffer(L); + int offset = luax_checkinteger(L, 2); + int len; + float floatv = buffer->grabFloat(&len, offset); + luax_pushnumber(L, floatv); + luax_pushinteger(L, len); + return 2; + } + + LUA_IMPLEMENT int l_grabBoolean(lua_State* L) + { + Buffer* buffer = checkNetBuffer(L); + int offset = luax_checkinteger(L, 2); + int len; + bool boolean = buffer->grabBoolean(&len, offset); + luax_pushboolean(L, boolean); + luax_pushinteger(L, len); + return 2; + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Buffer); + luaObj->release(); + return 0; + } + + LUA_EXPORT void luaopen_Buffer(lua_State* L) + { + luaL_Reg netbuffer_function[] = { + { "__gc", l_gc }, + { "append", l_append }, + { "grabString", l_grabString }, + { "grabInteger", l_grabInteger }, + { "grabBoolean", l_grabBoolean }, + { "grabFloat", l_grabFloat }, + { 0, 0 } + }; + + luax_newtype(L, Jin_Lua_Buffer, netbuffer_function); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/net/l_buffer.h b/src/libjin-lua/modules/net/l_buffer.h new file mode 100644 index 0000000..4ff9be6 --- /dev/null +++ b/src/libjin-lua/modules/net/l_buffer.h @@ -0,0 +1,102 @@ +#ifndef __JIN_LUA_NET_NETBUFFER_H +#define __JIN_LUA_NET_NETBUFFER_H + +#include +#include +#include "common/l_common.h" + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Buffer; + + void luaopen_Buffer(lua_State* L); + + namespace Net + { + + class Buffer : public Object + { + public: + Buffer(size_t s = 0) + : size(s) + { + buffer = new char[size]; + memset(buffer, 0, size); + } + + Buffer(const char* data, size_t s) + : size(s) + { + buffer = new char[size]; + memcpy(buffer, data, size); + } + + ~Buffer() + { + if (buffer != nullptr) + { + delete[] buffer; + buffer = nullptr; + size = 0; + } + } + + void append(const void* data, size_t s) + { + if (data == nullptr) + return; + char* buf = buffer; + buffer = new char[size + s]; + memcpy(buffer, buf, size); + memcpy(buffer + size, data, s); + delete[] buf; + size += s; + return; + } + + /* grab and create a string */ + char* grabString(unsigned int* length, int offset = 0) + { + int l = offset; + for (; l < size; ++l) + { + if (buffer[l] == 0) + break; + } + *length = l - offset + 1; + char* str = (char*)malloc(*length); + memcpy(str, buffer + offset, *length); + return str; + } + + int grabInteger(int* length, int offset = 0) + { + *length = sizeof(int); + return *((int*)(buffer + offset)); + } + + float grabFloat(int* length, int offset = 0) + { + *length = sizeof(float); + return *((float*)(buffer + offset)); + } + + bool grabBoolean(int* length, int offset = 0) + { + *length = sizeof(bool); + return *((bool*)(buffer + offset)); + } + + char* buffer; + size_t size; + + }; + + } // namespace Net + } // namespace Lua +} // namespace JinEngine + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/net/l_net.cpp b/src/libjin-lua/modules/net/l_net.cpp new file mode 100644 index 0000000..5569381 --- /dev/null +++ b/src/libjin-lua/modules/net/l_net.cpp @@ -0,0 +1,79 @@ +#include "common/l_object.h" +#include "libjin/jin.h" +#include "common/l_common.h" + +#include "l_buffer.h" +#include "l_socket.h" + +namespace JinEngine +{ + namespace Lua + { + + using namespace JinEngine::Lua::Net; + using namespace JinEngine::Net; + + 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 }; + { + 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)); + 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)); + return 1; + } + + 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); + return 1; + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/net/l_net.h b/src/libjin-lua/modules/net/l_net.h new file mode 100644 index 0000000..1542791 --- /dev/null +++ b/src/libjin-lua/modules/net/l_net.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_NET_H__ +#define __JE_LUA_NET_H__ + +namespace JinEngine +{ + namespace Lua + { + + int luaopen_net(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/net/l_socket.cpp b/src/libjin-lua/modules/net/l_socket.cpp new file mode 100644 index 0000000..1e86ea9 --- /dev/null +++ b/src/libjin-lua/modules/net/l_socket.cpp @@ -0,0 +1,123 @@ +#include "common/l_object.h" +#include "common/l_common.h" +#include "libjin/jin.h" +#include "l_buffer.h" + +using namespace JinEngine::Net; +using namespace JinEngine::Lua::Net; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_Socket = "Socket"; + + const int BUFFER_SIZE = 1024; + + LUA_IMPLEMENT inline Socket* checkSocket(lua_State* L, int pos = 1) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, pos, Jin_Lua_Socket); + return luaObj->getObject(); + } + + LUA_IMPLEMENT inline Buffer* checkNetBuffer(lua_State* L, int pos = 1) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, pos, Jin_Lua_Buffer); + return luaObj->getObject(); + } + + // return net.Socket + LUA_IMPLEMENT int l_accept(lua_State* L) + { + Socket* socket = checkSocket(L); + Socket* client = socket->accept(); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Socket, new Shared(client)); + return 1; + } + + // return net.Buffer + LUA_IMPLEMENT int l_receive(lua_State* L) + { + Socket* socket = checkSocket(L); + char buffer[BUFFER_SIZE] = {0}; + int size = socket->receive(buffer, BUFFER_SIZE); + Net::Buffer* netBuffer = new Net::Buffer(buffer, size); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared(netBuffer)); + return 1; + } + + // Socket:receiveFrom(address, port) + LUA_IMPLEMENT int l_receiveFrom(lua_State* L) + { + Socket* socket = checkSocket(L); + int address = luax_checkinteger(L, 2); + int port = luax_checkinteger(L, 3); + char buffer[BUFFER_SIZE]; + int size = socket->receiveFrom(buffer, BUFFER_SIZE, address, port); + Net::Buffer* netBuffer = new Net::Buffer(buffer, size); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Buffer, new Shared(netBuffer)); + return 1; + } + + // Socket:send(net.Buffer) -> data_length + LUA_IMPLEMENT int l_send(lua_State* L) + { + Socket* socket = checkSocket(L); + Buffer* buffer = checkNetBuffer(L, 2); + int len = socket->send(buffer->buffer, buffer->size); + luax_pushinteger(L, len); + return 1; + } + + // Socket:sendTo(address, port, net.Buffer) + LUA_IMPLEMENT int l_sendTo(lua_State* L) + { + Socket* socket = checkSocket(L); + int address = luax_checkinteger(L, 2); + int port = luax_checkinteger(L, 3); + Buffer* buffer = checkNetBuffer(L, 4); + socket->sendTo(buffer->buffer, buffer->size, address, port); + return 0; + } + + LUA_IMPLEMENT int l_close(lua_State* L) + { + Socket* socket = checkSocket(L); + socket->close(); + return 0; + } + + LUA_IMPLEMENT int l_configBlocking(lua_State* L) + { + Socket* socket = checkSocket(L); + bool blocking = luax_checkbool(L, 2); + socket->configureBlocking(blocking); + return 0; + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Socket); + luaObj->release(); + return 0; + } + + LUA_EXPORT void luaopen_Socket(lua_State* L) + { + 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 }, + { "configBlocking", l_configBlocking }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Socket, socket_function); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/net/l_socket.h b/src/libjin-lua/modules/net/l_socket.h new file mode 100644 index 0000000..b33fac6 --- /dev/null +++ b/src/libjin-lua/modules/net/l_socket.h @@ -0,0 +1,16 @@ +#ifndef __JE_LUA_SOCKET_H__ +#define __JE_LUA_SOCKET_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Socket; + + void luaopen_Socket(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/thread/je_lua_thread.cpp b/src/libjin-lua/modules/thread/je_lua_thread.cpp deleted file mode 100644 index 2af3e53..0000000 --- a/src/libjin-lua/modules/thread/je_lua_thread.cpp +++ /dev/null @@ -1,240 +0,0 @@ -#include "common/je_lua_object.h" - -#include "libjin/jin.h" -#include "libjin-lua/je_lua_jin.h" -#include "common/je_lua_common.h" -#include "je_lua_thread.h" - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_Thread = "Thread"; - - int luaopen_thread(lua_State* L); - - static inline Thread* checkThread(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Thread); - return luaObj->getObject(); - } - - LUA_IMPLEMENT int threadRunner(void* t) - { - Shared* shared = (Shared*)t; - Thread* thread = shared->getObject(); - lua_State* L = lua_open(); - luax_openlibs(L); - open(L); - luax_getglobal(L, MODULE_NAME); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Thread, shared); - luax_setfield(L, -2, "_curThread"); - luax_dostring(L, thread->code.c_str()); - luax_close(L); - return 0; - } - - LUA_IMPLEMENT int l_thread_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Thread); - luaObj->release(); - return 0; - } - - LUA_IMPLEMENT int l_start(lua_State* L) - { - Thread* shared = checkThread(L); - bool result = shared->start(&shared); - luax_pushboolean(L, result); - return 1; - } - - LUA_IMPLEMENT int l_wait(lua_State* L) - { - Thread* shared = checkThread(L); - shared->wait(); - return 0; - } - - LUA_IMPLEMENT int l_send(lua_State* L) - { - Thread* shared = checkThread(L); - int slot = luax_checkinteger(L, 2); - const int vp = 3; - if (luax_isnumberstrict(L, vp)) - { - float real = luax_checknumber(L, vp); - shared->send(slot, real); - } - else if (luax_isbooleanstrict(L, vp)) - { - bool bol = luax_checkbool(L, vp); - shared->send(slot, bol); - } - else if (luax_isstringstrict(L, vp)) - { - const char* str = luax_checkstring(L, vp); - shared->send(slot, str); - } - else if (luax_isuserdata(L, vp)) - { - LuaObject* luaObj = (LuaObject*)luax_touserdata(L, vp); - shared->send(slot, luaObj); - }/* - else if (luax_islightuserdata(L, vp)) - { - void* p = luax_tolightuserdata(L, vp); - shared->send(slot, p); - }*/ - return 0; - } - - LUA_IMPLEMENT int l_receive(lua_State* L) - { - Thread* shared = checkThread(L); - int slot = luax_checkinteger(L, 2); - bool result = shared->receive(slot); - luax_pushboolean(L, result); - return 1; - } - - LUA_IMPLEMENT int l_fetch(lua_State* L) - { - Thread* shared = checkThread(L); - int slot = luax_checkinteger(L, 2); - Thread::Variant v = shared->fetch(slot); - switch (v.type) - { - case Thread::Variant::INTERGER: - luax_pushinteger(L, v.integer); - break; - - case Thread::Variant::BOOLEAN: - luax_pushboolean(L, v.boolean); - break; - - case Thread::Variant::CSTRING: - luax_pushstring(L, v.cstring); - break; - - case Thread::Variant::REAL: - luax_pushnumber(L, v.real); - break; - - case Thread::Variant::POINTER: - LuaObject* p = (LuaObject*)v.pointer; - // Create lua object from other lua_State. - LuaObject* luaObj = luax_copyinstance(L, p); - break; - - } - return 1; - } - - LUA_IMPLEMENT int l_demand(lua_State* L) - { - Thread* shared = checkThread(L); - int slot = luax_checkinteger(L, 2); - Thread::Variant v = shared->demand(slot); - switch (v.type) - { - case Thread::Variant::INTERGER: - luax_pushinteger(L, v.integer); - break; - - case Thread::Variant::BOOLEAN: - luax_pushboolean(L, v.boolean); - break; - - case Thread::Variant::CSTRING: - luax_pushstring(L, v.cstring); - break; - - case Thread::Variant::REAL: - luax_pushnumber(L, v.real); - break; - - case Thread::Variant::POINTER: - LuaObject* p = (LuaObject*)v.pointer; - // Create lua object from other lua_State. - LuaObject* luaObj = luax_copyinstance(L, p); - break; - - } - return 1; - } - - LUA_IMPLEMENT int l_remove(lua_State* L) - { - Thread* shared = checkThread(L); - int slot = luax_checkinteger(L, 2); - shared->remove(slot); - return 0; - } - - LUA_IMPLEMENT int l_getName(lua_State* L) - { - Thread* shared = checkThread(L); - const char* name = shared->getName(); - luax_pushstring(L, name); - return 1; - } - - LUA_IMPLEMENT int l_isRunning(lua_State* L) - { - Thread* shared = checkThread(L); - bool running = shared->isRunning(); - luax_pushboolean(L, running); - return 1; - } - - LUA_IMPLEMENT int luaopen_Thread(lua_State* L) - { - 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 }, - { "isRunning", l_isRunning }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Thread, thread_function); - return 0; - } - - LUA_IMPLEMENT int l_newThread(lua_State* L) - { - const char* name = luax_checkstring(L, 1); - const char* code = luax_checkstring(L, 2); - Thread* thread = new Thread(name, code, threadRunner); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Thread, new Shared(thread)); - return 1; - } - - LUA_IMPLEMENT int l_getThread(lua_State* L) - { - luax_getglobal(L, MODULE_NAME); - luax_getfield(L, -1, "_curThread"); - return 1; - } - - LUA_EXPORT int luaopen_thread(lua_State* L) - { - luaopen_Thread(L); - luaL_Reg methods[] = { - { "newThread", l_newThread }, - { "getThread", l_getThread }, - { 0, 0 } - }; - luax_newlib(L, methods); - return 1; - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/thread/je_lua_thread.h b/src/libjin-lua/modules/thread/je_lua_thread.h deleted file mode 100644 index acb4c49..0000000 --- a/src/libjin-lua/modules/thread/je_lua_thread.h +++ /dev/null @@ -1,95 +0,0 @@ -#include "libjin/jin.h" -#include "common/je_lua_common.h" - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_Thread; - - class Thread : public Object - { - public: - typedef JinEngine::Threads::Thread::Variant Variant; - typedef JinEngine::Threads::Thread::ThreadRunner ThreadRunner; - - Thread(std::string _name, std::string _code, ThreadRunner runner) - : name(_name) - , code(_code) - { - thread = new JinEngine::Threads::Thread(_name, runner); - } - - ~Thread() - { - delete thread; - } - - bool start(void* p) - { - return thread->start(p); - } - - void wait() - { - thread->wait(); - } - - void send(int slot, const Variant& value) - { - thread->send(slot, value); - } - - bool receive(int slot) - { - return thread->receive(slot); - } - - Variant fetch(int slot) - { - return thread->fetch(slot); - } - - Variant demand(int slot) - { - return thread->demand(slot); - } - - void remove(int slot) - { - thread->remove(slot); - } - - const char* getName() - { - return name.c_str(); - } - - bool isRunning() - { - return thread->isRunning(); - } - - void lock() - { - thread->lock(); - } - - void unlock() - { - thread->unlock(); - } - - const std::string name; - const std::string code; - - private: - JinEngine::Threads::Thread* thread; - - }; - - int luaopen_thread(lua_State* L); - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/thread/l_thread.cpp b/src/libjin-lua/modules/thread/l_thread.cpp new file mode 100644 index 0000000..757244a --- /dev/null +++ b/src/libjin-lua/modules/thread/l_thread.cpp @@ -0,0 +1,240 @@ +#include "common/l_object.h" + +#include "libjin/jin.h" +#include "libjin-lua/l_jin.h" +#include "common/l_common.h" +#include "l_thread.h" + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_Thread = "Thread"; + + int luaopen_thread(lua_State* L); + + static inline Thread* checkThread(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Thread); + return luaObj->getObject(); + } + + LUA_IMPLEMENT int threadRunner(void* t) + { + Shared* shared = (Shared*)t; + Thread* thread = shared->getObject(); + lua_State* L = lua_open(); + luax_openlibs(L); + open(L); + luax_getglobal(L, MODULE_NAME); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Thread, shared); + luax_setfield(L, -2, "_curThread"); + luax_dostring(L, thread->code.c_str()); + luax_close(L); + return 0; + } + + LUA_IMPLEMENT int l_thread_gc(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Thread); + luaObj->release(); + return 0; + } + + LUA_IMPLEMENT int l_start(lua_State* L) + { + Thread* shared = checkThread(L); + bool result = shared->start(&shared); + luax_pushboolean(L, result); + return 1; + } + + LUA_IMPLEMENT int l_wait(lua_State* L) + { + Thread* shared = checkThread(L); + shared->wait(); + return 0; + } + + LUA_IMPLEMENT int l_send(lua_State* L) + { + Thread* shared = checkThread(L); + int slot = luax_checkinteger(L, 2); + const int vp = 3; + if (luax_isnumberstrict(L, vp)) + { + float real = luax_checknumber(L, vp); + shared->send(slot, real); + } + else if (luax_isbooleanstrict(L, vp)) + { + bool bol = luax_checkbool(L, vp); + shared->send(slot, bol); + } + else if (luax_isstringstrict(L, vp)) + { + const char* str = luax_checkstring(L, vp); + shared->send(slot, str); + } + else if (luax_isuserdata(L, vp)) + { + LuaObject* luaObj = (LuaObject*)luax_touserdata(L, vp); + shared->send(slot, luaObj); + }/* + else if (luax_islightuserdata(L, vp)) + { + void* p = luax_tolightuserdata(L, vp); + shared->send(slot, p); + }*/ + return 0; + } + + LUA_IMPLEMENT int l_receive(lua_State* L) + { + Thread* shared = checkThread(L); + int slot = luax_checkinteger(L, 2); + bool result = shared->receive(slot); + luax_pushboolean(L, result); + return 1; + } + + LUA_IMPLEMENT int l_fetch(lua_State* L) + { + Thread* shared = checkThread(L); + int slot = luax_checkinteger(L, 2); + Thread::Variant v = shared->fetch(slot); + switch (v.type) + { + case Thread::Variant::INTERGER: + luax_pushinteger(L, v.integer); + break; + + case Thread::Variant::BOOLEAN: + luax_pushboolean(L, v.boolean); + break; + + case Thread::Variant::CSTRING: + luax_pushstring(L, v.cstring); + break; + + case Thread::Variant::REAL: + luax_pushnumber(L, v.real); + break; + + case Thread::Variant::POINTER: + LuaObject* p = (LuaObject*)v.pointer; + // Create lua object from other lua_State. + LuaObject* luaObj = luax_copyinstance(L, p); + break; + + } + return 1; + } + + LUA_IMPLEMENT int l_demand(lua_State* L) + { + Thread* shared = checkThread(L); + int slot = luax_checkinteger(L, 2); + Thread::Variant v = shared->demand(slot); + switch (v.type) + { + case Thread::Variant::INTERGER: + luax_pushinteger(L, v.integer); + break; + + case Thread::Variant::BOOLEAN: + luax_pushboolean(L, v.boolean); + break; + + case Thread::Variant::CSTRING: + luax_pushstring(L, v.cstring); + break; + + case Thread::Variant::REAL: + luax_pushnumber(L, v.real); + break; + + case Thread::Variant::POINTER: + LuaObject* p = (LuaObject*)v.pointer; + // Create lua object from other lua_State. + LuaObject* luaObj = luax_copyinstance(L, p); + break; + + } + return 1; + } + + LUA_IMPLEMENT int l_remove(lua_State* L) + { + Thread* shared = checkThread(L); + int slot = luax_checkinteger(L, 2); + shared->remove(slot); + return 0; + } + + LUA_IMPLEMENT int l_getName(lua_State* L) + { + Thread* shared = checkThread(L); + const char* name = shared->getName(); + luax_pushstring(L, name); + return 1; + } + + LUA_IMPLEMENT int l_isRunning(lua_State* L) + { + Thread* shared = checkThread(L); + bool running = shared->isRunning(); + luax_pushboolean(L, running); + return 1; + } + + LUA_IMPLEMENT int luaopen_Thread(lua_State* L) + { + 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 }, + { "isRunning", l_isRunning }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Thread, thread_function); + return 0; + } + + LUA_IMPLEMENT int l_newThread(lua_State* L) + { + const char* name = luax_checkstring(L, 1); + const char* code = luax_checkstring(L, 2); + Thread* thread = new Thread(name, code, threadRunner); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Thread, new Shared(thread)); + return 1; + } + + LUA_IMPLEMENT int l_getThread(lua_State* L) + { + luax_getglobal(L, MODULE_NAME); + luax_getfield(L, -1, "_curThread"); + return 1; + } + + LUA_EXPORT int luaopen_thread(lua_State* L) + { + luaopen_Thread(L); + luaL_Reg methods[] = { + { "newThread", l_newThread }, + { "getThread", l_getThread }, + { 0, 0 } + }; + luax_newlib(L, methods); + return 1; + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/thread/l_thread.h b/src/libjin-lua/modules/thread/l_thread.h new file mode 100644 index 0000000..8203134 --- /dev/null +++ b/src/libjin-lua/modules/thread/l_thread.h @@ -0,0 +1,95 @@ +#include "libjin/jin.h" +#include "common/l_common.h" + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Thread; + + class Thread : public Object + { + public: + typedef JinEngine::Threads::Thread::Variant Variant; + typedef JinEngine::Threads::Thread::ThreadRunner ThreadRunner; + + Thread(std::string _name, std::string _code, ThreadRunner runner) + : name(_name) + , code(_code) + { + thread = new JinEngine::Threads::Thread(_name, runner); + } + + ~Thread() + { + delete thread; + } + + bool start(void* p) + { + return thread->start(p); + } + + void wait() + { + thread->wait(); + } + + void send(int slot, const Variant& value) + { + thread->send(slot, value); + } + + bool receive(int slot) + { + return thread->receive(slot); + } + + Variant fetch(int slot) + { + return thread->fetch(slot); + } + + Variant demand(int slot) + { + return thread->demand(slot); + } + + void remove(int slot) + { + thread->remove(slot); + } + + const char* getName() + { + return name.c_str(); + } + + bool isRunning() + { + return thread->isRunning(); + } + + void lock() + { + thread->lock(); + } + + void unlock() + { + thread->unlock(); + } + + const std::string name; + const std::string code; + + private: + JinEngine::Threads::Thread* thread; + + }; + + int luaopen_thread(lua_State* L); + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/time/je_lua_time.cpp b/src/libjin-lua/modules/time/je_lua_time.cpp deleted file mode 100644 index b0468ec..0000000 --- a/src/libjin-lua/modules/time/je_lua_time.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "SDL2/SDL.h" -#include "common/je_lua_common.h" -#include "common/je_lua_object.h" -#include "libjin/jin.h" - -#include "je_lua_timer.h" - -using namespace JinEngine::Time; - -namespace JinEngine -{ - namespace Lua - { - - LUA_IMPLEMENT int l_sec(lua_State* L) - { - luax_pushnumber(L, getSecond()); - return 1; - } - - LUA_IMPLEMENT int l_sleep(lua_State* L) - { - double sec = luax_checknumber(L, 1); - sleep(sec * 1000.0f); - return 0; - } - - LUA_IMPLEMENT int l_newTimer(lua_State* L) - { - Shared* shrTimer = new Shared(new Timer()); - luax_newinstance(L, Jin_Lua_Timer, shrTimer); - return 1; - } - - LUA_IMPLEMENT int l_getDelta(lua_State* L) - { - luax_pushnumber(L, Time::getDeltaTime()); - return 1; - } - - LUA_IMPLEMENT int l_step(lua_State* L) - { - Time::step(); - return 0; - } - - LUA_EXPORT int luaopen_time(lua_State* L) - { - // Types. - luaopen_Timer(L); - // Functions. - luaL_Reg methods[] = { - { "second", l_sec }, - { "sleep", l_sleep }, - { "newTimer", l_newTimer }, - { "step", l_step }, - { "getDelta", l_getDelta }, - { 0, 0 }, - }; - luax_newlib(L, methods); - return 1; - } - - } // namespace Lua -} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/time/je_lua_time.h b/src/libjin-lua/modules/time/je_lua_time.h deleted file mode 100644 index 3c75221..0000000 --- a/src/libjin-lua/modules/time/je_lua_time.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __JE_LUA_TIME_H__ -#define __JE_LUA_TIME_H__ - -namespace JinEngine -{ - namespace Lua - { - - int luaopen_time(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/time/je_lua_timer.cpp b/src/libjin-lua/modules/time/je_lua_timer.cpp deleted file mode 100644 index e30baab..0000000 --- a/src/libjin-lua/modules/time/je_lua_timer.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "common/je_lua_callback.h" -#include "common/je_lua_common.h" -#include "je_lua_timer.h" - -using namespace JinEngine::Time; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_Timer = "Timer"; - - const char* Jin_Lua_Handler = "Handler"; - - static Timer::TimerCallback timerCallback = [](void* data)->void - { - LuaCallback* func = static_cast(data); - func->call(); - }; - - static Timer::FinishCallback finishCallback = [](void* data)->void - { - LuaCallback* func = static_cast(data); - delete func; - }; - - LUA_IMPLEMENT inline Timer* checkTimer(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Timer); - return luaObj->getObject(); - } - - // timer:every(time, callback, parameter) - LUA_IMPLEMENT int l_every(lua_State* L) - { - int n = luax_gettop(L); - Timer* shared = checkTimer(L); - float s = luax_checknumber(L, 2); - LuaCallback* func = new LuaCallback(L); - func->setFunc(3); - for(int i = 4; i <= n; ++i) - func->pushParam(i); - Timer::Handler* handler = shared->every(s, timerCallback, func, finishCallback); - Shared* shrHandler = new Shared(handler); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Handler, shrHandler); - return 1; - } - - // timer:after(time, callback, parameter) - LUA_IMPLEMENT int l_after(lua_State* L) - { - int n = luax_gettop(L); - Timer* shared = checkTimer(L); - float s = luax_checknumber(L, 2); - LuaCallback* func = new LuaCallback(L); - func->setFunc(3); - for (int i = 4; i <= n; ++i) - func->pushParam(i); - Timer::Handler* handler = shared->after(s, timerCallback, func, finishCallback); - Shared* shrHandler = new Shared(handler); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Handler, shrHandler); - return 1; - } - - // timer:repeat(time, callback, parameter) - LUA_IMPLEMENT int l_repeat(lua_State* L) - { - int n = luax_gettop(L); - Timer* shared = checkTimer(L); - float s = luax_checknumber(L, 2); - int count = luax_checkinteger(L, 3); - LuaCallback* func = new LuaCallback(L); - func->setFunc(4); - for (int i = 5; i <= n; ++i) - func->pushParam(i); - Timer::Handler* handler = shared->repeat(s, count, timerCallback, func, finishCallback); - Shared* shrHandler = new Shared(handler); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Handler, shrHandler); - return 1; - } - - LUA_IMPLEMENT int l_update(lua_State* L) - { - Timer* shared = checkTimer(L); - float s = luax_checknumber(L, 2); - shared->update(s); - return 0; - } - - LUA_IMPLEMENT int l_cancel(lua_State* L) - { - LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Timer); - Timer* timer = p->getObject(); - LuaObject* ph = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Handler); - Timer::Handler* handler = ph->getObject(); - timer->cancel(handler); - return 0; - } - - LUA_IMPLEMENT int l_cancelAll(lua_State* L) - { - LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Timer); - Timer* timer = p->getObject(); - timer->cancelAll(); - return 0; - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Timer); - p->release(); - return 0; - } - - LUA_EXPORT void luaopen_Timer(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "every", l_every }, - { "after", l_after }, - { "duplicate", l_repeat }, - { "update", l_update }, - { "cancel", l_cancel }, - { "cancelAll", l_cancelAll }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Timer, methods); - } - - } -} \ No newline at end of file diff --git a/src/libjin-lua/modules/time/je_lua_timer.h b/src/libjin-lua/modules/time/je_lua_timer.h deleted file mode 100644 index 35ec15d..0000000 --- a/src/libjin-lua/modules/time/je_lua_timer.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __JE_LUA_TIMER_H__ -#define __JE_LUA_TIMER_H__ - -#include "libjin/jin.h" - -namespace JinEngine -{ - namespace Lua - { - - extern const char* Jin_Lua_Timer; - - extern const char* Jin_Lua_Handler; - - void luaopen_Timer(lua_State* L); - - } -} - -#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/time/l_time.cpp b/src/libjin-lua/modules/time/l_time.cpp new file mode 100644 index 0000000..0e39f9e --- /dev/null +++ b/src/libjin-lua/modules/time/l_time.cpp @@ -0,0 +1,65 @@ +#include "SDL2/SDL.h" +#include "common/l_common.h" +#include "common/l_object.h" +#include "libjin/jin.h" + +#include "l_timer.h" + +using namespace JinEngine::Time; + +namespace JinEngine +{ + namespace Lua + { + + LUA_IMPLEMENT int l_sec(lua_State* L) + { + luax_pushnumber(L, getSecond()); + return 1; + } + + LUA_IMPLEMENT int l_sleep(lua_State* L) + { + double sec = luax_checknumber(L, 1); + sleep(sec * 1000.0f); + return 0; + } + + LUA_IMPLEMENT int l_newTimer(lua_State* L) + { + Shared* shrTimer = new Shared(new Timer()); + luax_newinstance(L, Jin_Lua_Timer, shrTimer); + return 1; + } + + LUA_IMPLEMENT int l_getDelta(lua_State* L) + { + luax_pushnumber(L, Time::getDeltaTime()); + return 1; + } + + LUA_IMPLEMENT int l_step(lua_State* L) + { + Time::step(); + return 0; + } + + LUA_EXPORT int luaopen_time(lua_State* L) + { + // Types. + luaopen_Timer(L); + // Functions. + luaL_Reg methods[] = { + { "second", l_sec }, + { "sleep", l_sleep }, + { "newTimer", l_newTimer }, + { "step", l_step }, + { "getDelta", l_getDelta }, + { 0, 0 }, + }; + luax_newlib(L, methods); + return 1; + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin-lua/modules/time/l_time.h b/src/libjin-lua/modules/time/l_time.h new file mode 100644 index 0000000..3c75221 --- /dev/null +++ b/src/libjin-lua/modules/time/l_time.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_TIME_H__ +#define __JE_LUA_TIME_H__ + +namespace JinEngine +{ + namespace Lua + { + + int luaopen_time(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/modules/time/l_timer.cpp b/src/libjin-lua/modules/time/l_timer.cpp new file mode 100644 index 0000000..8886913 --- /dev/null +++ b/src/libjin-lua/modules/time/l_timer.cpp @@ -0,0 +1,132 @@ +#include "common/l_callback.h" +#include "common/l_common.h" +#include "l_timer.h" + +using namespace JinEngine::Time; + +namespace JinEngine +{ + namespace Lua + { + + const char* Jin_Lua_Timer = "Timer"; + + const char* Jin_Lua_Handler = "Handler"; + + static Timer::TimerCallback timerCallback = [](void* data)->void + { + LuaCallback* func = static_cast(data); + func->call(); + }; + + static Timer::FinishCallback finishCallback = [](void* data)->void + { + LuaCallback* func = static_cast(data); + delete func; + }; + + LUA_IMPLEMENT inline Timer* checkTimer(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Timer); + return luaObj->getObject(); + } + + // timer:every(time, callback, parameter) + LUA_IMPLEMENT int l_every(lua_State* L) + { + int n = luax_gettop(L); + Timer* shared = checkTimer(L); + float s = luax_checknumber(L, 2); + LuaCallback* func = new LuaCallback(L); + func->setFunc(3); + for(int i = 4; i <= n; ++i) + func->pushParam(i); + Timer::Handler* handler = shared->every(s, timerCallback, func, finishCallback); + Shared* shrHandler = new Shared(handler); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Handler, shrHandler); + return 1; + } + + // timer:after(time, callback, parameter) + LUA_IMPLEMENT int l_after(lua_State* L) + { + int n = luax_gettop(L); + Timer* shared = checkTimer(L); + float s = luax_checknumber(L, 2); + LuaCallback* func = new LuaCallback(L); + func->setFunc(3); + for (int i = 4; i <= n; ++i) + func->pushParam(i); + Timer::Handler* handler = shared->after(s, timerCallback, func, finishCallback); + Shared* shrHandler = new Shared(handler); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Handler, shrHandler); + return 1; + } + + // timer:repeat(time, callback, parameter) + LUA_IMPLEMENT int l_repeat(lua_State* L) + { + int n = luax_gettop(L); + Timer* shared = checkTimer(L); + float s = luax_checknumber(L, 2); + int count = luax_checkinteger(L, 3); + LuaCallback* func = new LuaCallback(L); + func->setFunc(4); + for (int i = 5; i <= n; ++i) + func->pushParam(i); + Timer::Handler* handler = shared->repeat(s, count, timerCallback, func, finishCallback); + Shared* shrHandler = new Shared(handler); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Handler, shrHandler); + return 1; + } + + LUA_IMPLEMENT int l_update(lua_State* L) + { + Timer* shared = checkTimer(L); + float s = luax_checknumber(L, 2); + shared->update(s); + return 0; + } + + LUA_IMPLEMENT int l_cancel(lua_State* L) + { + LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Timer); + Timer* timer = p->getObject(); + LuaObject* ph = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Handler); + Timer::Handler* handler = ph->getObject(); + timer->cancel(handler); + return 0; + } + + LUA_IMPLEMENT int l_cancelAll(lua_State* L) + { + LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Timer); + Timer* timer = p->getObject(); + timer->cancelAll(); + return 0; + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Timer); + p->release(); + return 0; + } + + LUA_EXPORT void luaopen_Timer(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "every", l_every }, + { "after", l_after }, + { "duplicate", l_repeat }, + { "update", l_update }, + { "cancel", l_cancel }, + { "cancelAll", l_cancelAll }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Timer, methods); + } + + } +} \ No newline at end of file diff --git a/src/libjin-lua/modules/time/l_timer.h b/src/libjin-lua/modules/time/l_timer.h new file mode 100644 index 0000000..35ec15d --- /dev/null +++ b/src/libjin-lua/modules/time/l_timer.h @@ -0,0 +1,20 @@ +#ifndef __JE_LUA_TIMER_H__ +#define __JE_LUA_TIMER_H__ + +#include "libjin/jin.h" + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Timer; + + extern const char* Jin_Lua_Handler; + + void luaopen_Timer(lua_State* L); + + } +} + +#endif \ No newline at end of file diff --git a/src/libjin-lua/scripts/physics/physics.lua.h b/src/libjin-lua/scripts/physics/physics.lua.h index 84ac125..08e21ce 100644 --- a/src/libjin-lua/scripts/physics/physics.lua.h +++ b/src/libjin-lua/scripts/physics/physics.lua.h @@ -1,1037 +1,1074 @@ /*Auto generated, don't modify by hand.*/ static char physics_lua[] = { 106,105,110,46,112,104,121,115,105,99,115,32,61,32,106,105,110,46,112,104, -121,115,105,99,115,32,111,114,32,123,125,10,10,45,45,45,45,45,45,45, +121,115,105,99,115,32,111,114,32,123,125,13,10,13,10,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,45,45,45,45,45,45,10,45,45,32,104,116,116,112,115,58,47,47,103, -105,116,104,117,98,46,99,111,109,47,107,105,107,105,116,111,47,98,117,109, -112,46,108,117,97,10,45,45,45,45,45,45,45,45,45,45,45,45,45,45, +45,45,45,45,45,45,45,45,45,13,10,45,45,32,104,116,116,112,115,58, +47,47,103,105,116,104,117,98,46,99,111,109,47,107,105,107,105,116,111,47, +98,117,109,112,46,108,117,97,13,10,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -10,10,108,111,99,97,108,32,98,117,109,112,32,61,32,123,125,10,10,45, +45,45,45,45,13,10,13,10,108,111,99,97,108,32,98,117,109,112,32,61, +32,123,125,13,10,13,10,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, +45,45,45,45,45,45,45,45,45,13,10,45,45,32,65,117,120,105,108,105, +97,114,121,32,102,117,110,99,116,105,111,110,115,13,10,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,10,45,45,32,65,117,120,105,108,105,97,114,121,32,102,117,110,99,116, -105,111,110,115,10,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,45,45,45,45,45,45,10,108,111,99,97,108,32,68,69,76,84,65,32, -61,32,49,101,45,49,48,32,45,45,32,102,108,111,97,116,105,110,103,45, -112,111,105,110,116,32,109,97,114,103,105,110,32,111,102,32,101,114,114,111, -114,10,10,108,111,99,97,108,32,97,98,115,44,32,102,108,111,111,114,44, -32,99,101,105,108,44,32,109,105,110,44,32,109,97,120,32,61,32,109,97, -116,104,46,97,98,115,44,32,109,97,116,104,46,102,108,111,111,114,44,32, -109,97,116,104,46,99,101,105,108,44,32,109,97,116,104,46,109,105,110,44, -32,109,97,116,104,46,109,97,120,10,10,108,111,99,97,108,32,102,117,110, -99,116,105,111,110,32,115,105,103,110,40,120,41,10,32,32,105,102,32,120, -32,62,32,48,32,116,104,101,110,32,114,101,116,117,114,110,32,49,32,101, -110,100,10,32,32,105,102,32,120,32,61,61,32,48,32,116,104,101,110,32, -114,101,116,117,114,110,32,48,32,101,110,100,10,32,32,114,101,116,117,114, -110,32,45,49,10,101,110,100,10,10,108,111,99,97,108,32,102,117,110,99, -116,105,111,110,32,110,101,97,114,101,115,116,40,120,44,32,97,44,32,98, -41,10,32,32,105,102,32,97,98,115,40,97,32,45,32,120,41,32,60,32, -97,98,115,40,98,32,45,32,120,41,32,116,104,101,110,32,114,101,116,117, -114,110,32,97,32,101,108,115,101,32,114,101,116,117,114,110,32,98,32,101, -110,100,10,101,110,100,10,10,108,111,99,97,108,32,102,117,110,99,116,105, -111,110,32,97,115,115,101,114,116,84,121,112,101,40,100,101,115,105,114,101, -100,84,121,112,101,44,32,118,97,108,117,101,44,32,110,97,109,101,41,10, -32,32,105,102,32,116,121,112,101,40,118,97,108,117,101,41,32,126,61,32, -100,101,115,105,114,101,100,84,121,112,101,32,116,104,101,110,10,32,32,32, -32,101,114,114,111,114,40,110,97,109,101,32,46,46,32,39,32,109,117,115, -116,32,98,101,32,97,32,39,32,46,46,32,100,101,115,105,114,101,100,84, -121,112,101,32,46,46,32,39,44,32,98,117,116,32,119,97,115,32,39,32, -46,46,32,116,111,115,116,114,105,110,103,40,118,97,108,117,101,41,32,46, -46,32,39,40,97,32,39,32,46,46,32,116,121,112,101,40,118,97,108,117, -101,41,32,46,46,32,39,41,39,41,10,32,32,101,110,100,10,101,110,100, -10,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110,32,97,115,115, -101,114,116,73,115,80,111,115,105,116,105,118,101,78,117,109,98,101,114,40, -118,97,108,117,101,44,32,110,97,109,101,41,10,32,32,105,102,32,116,121, -112,101,40,118,97,108,117,101,41,32,126,61,32,39,110,117,109,98,101,114, -39,32,111,114,32,118,97,108,117,101,32,60,61,32,48,32,116,104,101,110, -10,32,32,32,32,101,114,114,111,114,40,110,97,109,101,32,46,46,32,39, -32,109,117,115,116,32,98,101,32,97,32,112,111,115,105,116,105,118,101,32, -105,110,116,101,103,101,114,44,32,98,117,116,32,119,97,115,32,39,32,46, -46,32,116,111,115,116,114,105,110,103,40,118,97,108,117,101,41,32,46,46, -32,39,40,39,32,46,46,32,116,121,112,101,40,118,97,108,117,101,41,32, -46,46,32,39,41,39,41,10,32,32,101,110,100,10,101,110,100,10,10,108, -111,99,97,108,32,102,117,110,99,116,105,111,110,32,97,115,115,101,114,116, -73,115,82,101,99,116,40,120,44,121,44,119,44,104,41,10,32,32,97,115, -115,101,114,116,84,121,112,101,40,39,110,117,109,98,101,114,39,44,32,120, -44,32,39,120,39,41,10,32,32,97,115,115,101,114,116,84,121,112,101,40, -39,110,117,109,98,101,114,39,44,32,121,44,32,39,121,39,41,10,32,32, +45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,13,10,108, +111,99,97,108,32,68,69,76,84,65,32,61,32,49,101,45,49,48,32,45, +45,32,102,108,111,97,116,105,110,103,45,112,111,105,110,116,32,109,97,114, +103,105,110,32,111,102,32,101,114,114,111,114,13,10,13,10,108,111,99,97, +108,32,97,98,115,44,32,102,108,111,111,114,44,32,99,101,105,108,44,32, +109,105,110,44,32,109,97,120,32,61,32,109,97,116,104,46,97,98,115,44, +32,109,97,116,104,46,102,108,111,111,114,44,32,109,97,116,104,46,99,101, +105,108,44,32,109,97,116,104,46,109,105,110,44,32,109,97,116,104,46,109, +97,120,13,10,13,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110, +32,115,105,103,110,40,120,41,13,10,32,32,105,102,32,120,32,62,32,48, +32,116,104,101,110,32,114,101,116,117,114,110,32,49,32,101,110,100,13,10, +32,32,105,102,32,120,32,61,61,32,48,32,116,104,101,110,32,114,101,116, +117,114,110,32,48,32,101,110,100,13,10,32,32,114,101,116,117,114,110,32, +45,49,13,10,101,110,100,13,10,13,10,108,111,99,97,108,32,102,117,110, +99,116,105,111,110,32,110,101,97,114,101,115,116,40,120,44,32,97,44,32, +98,41,13,10,32,32,105,102,32,97,98,115,40,97,32,45,32,120,41,32, +60,32,97,98,115,40,98,32,45,32,120,41,32,116,104,101,110,32,114,101, +116,117,114,110,32,97,32,101,108,115,101,32,114,101,116,117,114,110,32,98, +32,101,110,100,13,10,101,110,100,13,10,13,10,108,111,99,97,108,32,102, +117,110,99,116,105,111,110,32,97,115,115,101,114,116,84,121,112,101,40,100, +101,115,105,114,101,100,84,121,112,101,44,32,118,97,108,117,101,44,32,110, +97,109,101,41,13,10,32,32,105,102,32,116,121,112,101,40,118,97,108,117, +101,41,32,126,61,32,100,101,115,105,114,101,100,84,121,112,101,32,116,104, +101,110,13,10,32,32,32,32,101,114,114,111,114,40,110,97,109,101,32,46, +46,32,39,32,109,117,115,116,32,98,101,32,97,32,39,32,46,46,32,100, +101,115,105,114,101,100,84,121,112,101,32,46,46,32,39,44,32,98,117,116, +32,119,97,115,32,39,32,46,46,32,116,111,115,116,114,105,110,103,40,118, +97,108,117,101,41,32,46,46,32,39,40,97,32,39,32,46,46,32,116,121, +112,101,40,118,97,108,117,101,41,32,46,46,32,39,41,39,41,13,10,32, +32,101,110,100,13,10,101,110,100,13,10,13,10,108,111,99,97,108,32,102, +117,110,99,116,105,111,110,32,97,115,115,101,114,116,73,115,80,111,115,105, +116,105,118,101,78,117,109,98,101,114,40,118,97,108,117,101,44,32,110,97, +109,101,41,13,10,32,32,105,102,32,116,121,112,101,40,118,97,108,117,101, +41,32,126,61,32,39,110,117,109,98,101,114,39,32,111,114,32,118,97,108, +117,101,32,60,61,32,48,32,116,104,101,110,13,10,32,32,32,32,101,114, +114,111,114,40,110,97,109,101,32,46,46,32,39,32,109,117,115,116,32,98, +101,32,97,32,112,111,115,105,116,105,118,101,32,105,110,116,101,103,101,114, +44,32,98,117,116,32,119,97,115,32,39,32,46,46,32,116,111,115,116,114, +105,110,103,40,118,97,108,117,101,41,32,46,46,32,39,40,39,32,46,46, +32,116,121,112,101,40,118,97,108,117,101,41,32,46,46,32,39,41,39,41, +13,10,32,32,101,110,100,13,10,101,110,100,13,10,13,10,108,111,99,97, +108,32,102,117,110,99,116,105,111,110,32,97,115,115,101,114,116,73,115,82, +101,99,116,40,120,44,121,44,119,44,104,41,13,10,32,32,97,115,115,101, +114,116,84,121,112,101,40,39,110,117,109,98,101,114,39,44,32,120,44,32, +39,120,39,41,13,10,32,32,97,115,115,101,114,116,84,121,112,101,40,39, +110,117,109,98,101,114,39,44,32,121,44,32,39,121,39,41,13,10,32,32, 97,115,115,101,114,116,73,115,80,111,115,105,116,105,118,101,78,117,109,98, -101,114,40,119,44,32,39,119,39,41,10,32,32,97,115,115,101,114,116,73, -115,80,111,115,105,116,105,118,101,78,117,109,98,101,114,40,104,44,32,39, -104,39,41,10,101,110,100,10,10,108,111,99,97,108,32,100,101,102,97,117, -108,116,70,105,108,116,101,114,32,61,32,102,117,110,99,116,105,111,110,40, -41,10,32,32,114,101,116,117,114,110,32,39,115,108,105,100,101,39,10,101, -110,100,10,10,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, +101,114,40,119,44,32,39,119,39,41,13,10,32,32,97,115,115,101,114,116, +73,115,80,111,115,105,116,105,118,101,78,117,109,98,101,114,40,104,44,32, +39,104,39,41,13,10,101,110,100,13,10,13,10,108,111,99,97,108,32,100, +101,102,97,117,108,116,70,105,108,116,101,114,32,61,32,102,117,110,99,116, +105,111,110,40,41,13,10,32,32,114,101,116,117,114,110,32,39,115,108,105, +100,101,39,13,10,101,110,100,13,10,13,10,45,45,45,45,45,45,45,45, +45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, +45,45,45,45,45,45,45,45,45,45,45,45,45,45,13,10,45,45,32,82, +101,99,116,97,110,103,108,101,32,102,117,110,99,116,105,111,110,115,13,10, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,45,45,45,45,45,10,45,45,32,82,101,99,116,97,110,103,108,101,32, -102,117,110,99,116,105,111,110,115,10,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,45,45,45,45,45,45,45,45,45,45,45,10,10,108,111,99,97,108,32, -102,117,110,99,116,105,111,110,32,114,101,99,116,95,103,101,116,78,101,97, -114,101,115,116,67,111,114,110,101,114,40,120,44,121,44,119,44,104,44,32, -112,120,44,32,112,121,41,10,32,32,114,101,116,117,114,110,32,110,101,97, -114,101,115,116,40,112,120,44,32,120,44,32,120,43,119,41,44,32,110,101, -97,114,101,115,116,40,112,121,44,32,121,44,32,121,43,104,41,10,101,110, -100,10,10,45,45,32,84,104,105,115,32,105,115,32,97,32,103,101,110,101, -114,97,108,105,122,101,100,32,105,109,112,108,101,109,101,110,116,97,116,105, -111,110,32,111,102,32,116,104,101,32,108,105,97,110,103,45,98,97,114,115, -107,121,32,97,108,103,111,114,105,116,104,109,44,32,119,104,105,99,104,32, -97,108,115,111,32,114,101,116,117,114,110,115,10,45,45,32,116,104,101,32, -110,111,114,109,97,108,115,32,111,102,32,116,104,101,32,115,105,100,101,115, -32,119,104,101,114,101,32,116,104,101,32,115,101,103,109,101,110,116,32,105, -110,116,101,114,115,101,99,116,115,46,10,45,45,32,82,101,116,117,114,110, -115,32,110,105,108,32,105,102,32,116,104,101,32,115,101,103,109,101,110,116, -32,110,101,118,101,114,32,116,111,117,99,104,101,115,32,116,104,101,32,114, -101,99,116,10,45,45,32,78,111,116,105,99,101,32,116,104,97,116,32,110, -111,114,109,97,108,115,32,97,114,101,32,111,110,108,121,32,103,117,97,114, -97,110,116,101,101,100,32,116,111,32,98,101,32,97,99,99,117,114,97,116, -101,32,119,104,101,110,32,105,110,105,116,105,97,108,108,121,32,116,105,49, -44,32,116,105,50,32,61,61,32,45,109,97,116,104,46,104,117,103,101,44, -32,109,97,116,104,46,104,117,103,101,10,108,111,99,97,108,32,102,117,110, +45,45,13,10,13,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110, +32,114,101,99,116,95,103,101,116,78,101,97,114,101,115,116,67,111,114,110, +101,114,40,120,44,121,44,119,44,104,44,32,112,120,44,32,112,121,41,13, +10,32,32,114,101,116,117,114,110,32,110,101,97,114,101,115,116,40,112,120, +44,32,120,44,32,120,43,119,41,44,32,110,101,97,114,101,115,116,40,112, +121,44,32,121,44,32,121,43,104,41,13,10,101,110,100,13,10,13,10,45, +45,32,84,104,105,115,32,105,115,32,97,32,103,101,110,101,114,97,108,105, +122,101,100,32,105,109,112,108,101,109,101,110,116,97,116,105,111,110,32,111, +102,32,116,104,101,32,108,105,97,110,103,45,98,97,114,115,107,121,32,97, +108,103,111,114,105,116,104,109,44,32,119,104,105,99,104,32,97,108,115,111, +32,114,101,116,117,114,110,115,13,10,45,45,32,116,104,101,32,110,111,114, +109,97,108,115,32,111,102,32,116,104,101,32,115,105,100,101,115,32,119,104, +101,114,101,32,116,104,101,32,115,101,103,109,101,110,116,32,105,110,116,101, +114,115,101,99,116,115,46,13,10,45,45,32,82,101,116,117,114,110,115,32, +110,105,108,32,105,102,32,116,104,101,32,115,101,103,109,101,110,116,32,110, +101,118,101,114,32,116,111,117,99,104,101,115,32,116,104,101,32,114,101,99, +116,13,10,45,45,32,78,111,116,105,99,101,32,116,104,97,116,32,110,111, +114,109,97,108,115,32,97,114,101,32,111,110,108,121,32,103,117,97,114,97, +110,116,101,101,100,32,116,111,32,98,101,32,97,99,99,117,114,97,116,101, +32,119,104,101,110,32,105,110,105,116,105,97,108,108,121,32,116,105,49,44, +32,116,105,50,32,61,61,32,45,109,97,116,104,46,104,117,103,101,44,32, +109,97,116,104,46,104,117,103,101,13,10,108,111,99,97,108,32,102,117,110, 99,116,105,111,110,32,114,101,99,116,95,103,101,116,83,101,103,109,101,110, 116,73,110,116,101,114,115,101,99,116,105,111,110,73,110,100,105,99,101,115, 40,120,44,121,44,119,44,104,44,32,120,49,44,121,49,44,120,50,44,121, -50,44,32,116,105,49,44,116,105,50,41,10,32,32,116,105,49,44,32,116, -105,50,32,61,32,116,105,49,32,111,114,32,48,44,32,116,105,50,32,111, -114,32,49,10,32,32,108,111,99,97,108,32,100,120,44,32,100,121,32,61, -32,120,50,45,120,49,44,32,121,50,45,121,49,10,32,32,108,111,99,97, -108,32,110,120,44,32,110,121,10,32,32,108,111,99,97,108,32,110,120,49, -44,32,110,121,49,44,32,110,120,50,44,32,110,121,50,32,61,32,48,44, -48,44,48,44,48,10,32,32,108,111,99,97,108,32,112,44,32,113,44,32, -114,10,10,32,32,102,111,114,32,115,105,100,101,32,61,32,49,44,52,32, -100,111,10,32,32,32,32,105,102,32,32,32,32,32,115,105,100,101,32,61, -61,32,49,32,116,104,101,110,32,110,120,44,110,121,44,112,44,113,32,61, -32,45,49,44,32,32,48,44,32,45,100,120,44,32,120,49,32,45,32,120, -32,32,32,32,32,45,45,32,108,101,102,116,10,32,32,32,32,101,108,115, -101,105,102,32,115,105,100,101,32,61,61,32,50,32,116,104,101,110,32,110, -120,44,110,121,44,112,44,113,32,61,32,32,49,44,32,32,48,44,32,32, -100,120,44,32,120,32,43,32,119,32,45,32,120,49,32,45,45,32,114,105, -103,104,116,10,32,32,32,32,101,108,115,101,105,102,32,115,105,100,101,32, -61,61,32,51,32,116,104,101,110,32,110,120,44,110,121,44,112,44,113,32, -61,32,32,48,44,32,45,49,44,32,45,100,121,44,32,121,49,32,45,32, -121,32,32,32,32,32,45,45,32,116,111,112,10,32,32,32,32,101,108,115, -101,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,110, -120,44,110,121,44,112,44,113,32,61,32,32,48,44,32,32,49,44,32,32, -100,121,44,32,121,32,43,32,104,32,45,32,121,49,32,45,45,32,98,111, -116,116,111,109,10,32,32,32,32,101,110,100,10,10,32,32,32,32,105,102, -32,112,32,61,61,32,48,32,116,104,101,110,10,32,32,32,32,32,32,105, -102,32,113,32,60,61,32,48,32,116,104,101,110,32,114,101,116,117,114,110, -32,110,105,108,32,101,110,100,10,32,32,32,32,101,108,115,101,10,32,32, -32,32,32,32,114,32,61,32,113,32,47,32,112,10,32,32,32,32,32,32, -105,102,32,112,32,60,32,48,32,116,104,101,110,10,32,32,32,32,32,32, -32,32,105,102,32,32,32,32,32,114,32,62,32,116,105,50,32,116,104,101, -110,32,114,101,116,117,114,110,32,110,105,108,10,32,32,32,32,32,32,32, +50,44,32,116,105,49,44,116,105,50,41,13,10,32,32,116,105,49,44,32, +116,105,50,32,61,32,116,105,49,32,111,114,32,48,44,32,116,105,50,32, +111,114,32,49,13,10,32,32,108,111,99,97,108,32,100,120,44,32,100,121, +32,61,32,120,50,45,120,49,44,32,121,50,45,121,49,13,10,32,32,108, +111,99,97,108,32,110,120,44,32,110,121,13,10,32,32,108,111,99,97,108, +32,110,120,49,44,32,110,121,49,44,32,110,120,50,44,32,110,121,50,32, +61,32,48,44,48,44,48,44,48,13,10,32,32,108,111,99,97,108,32,112, +44,32,113,44,32,114,13,10,13,10,32,32,102,111,114,32,115,105,100,101, +32,61,32,49,44,52,32,100,111,13,10,32,32,32,32,105,102,32,32,32, +32,32,115,105,100,101,32,61,61,32,49,32,116,104,101,110,32,110,120,44, +110,121,44,112,44,113,32,61,32,45,49,44,32,32,48,44,32,45,100,120, +44,32,120,49,32,45,32,120,32,32,32,32,32,45,45,32,108,101,102,116, +13,10,32,32,32,32,101,108,115,101,105,102,32,115,105,100,101,32,61,61, +32,50,32,116,104,101,110,32,110,120,44,110,121,44,112,44,113,32,61,32, +32,49,44,32,32,48,44,32,32,100,120,44,32,120,32,43,32,119,32,45, +32,120,49,32,45,45,32,114,105,103,104,116,13,10,32,32,32,32,101,108, +115,101,105,102,32,115,105,100,101,32,61,61,32,51,32,116,104,101,110,32, +110,120,44,110,121,44,112,44,113,32,61,32,32,48,44,32,45,49,44,32, +45,100,121,44,32,121,49,32,45,32,121,32,32,32,32,32,45,45,32,116, +111,112,13,10,32,32,32,32,101,108,115,101,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,110,120,44,110,121,44,112,44,113,32, +61,32,32,48,44,32,32,49,44,32,32,100,121,44,32,121,32,43,32,104, +32,45,32,121,49,32,45,45,32,98,111,116,116,111,109,13,10,32,32,32, +32,101,110,100,13,10,13,10,32,32,32,32,105,102,32,112,32,61,61,32, +48,32,116,104,101,110,13,10,32,32,32,32,32,32,105,102,32,113,32,60, +61,32,48,32,116,104,101,110,32,114,101,116,117,114,110,32,110,105,108,32, +101,110,100,13,10,32,32,32,32,101,108,115,101,13,10,32,32,32,32,32, +32,114,32,61,32,113,32,47,32,112,13,10,32,32,32,32,32,32,105,102, +32,112,32,60,32,48,32,116,104,101,110,13,10,32,32,32,32,32,32,32, +32,105,102,32,32,32,32,32,114,32,62,32,116,105,50,32,116,104,101,110, +32,114,101,116,117,114,110,32,110,105,108,13,10,32,32,32,32,32,32,32, 32,101,108,115,101,105,102,32,114,32,62,32,116,105,49,32,116,104,101,110, 32,116,105,49,44,110,120,49,44,110,121,49,32,61,32,114,44,110,120,44, -110,121,10,32,32,32,32,32,32,32,32,101,110,100,10,32,32,32,32,32, -32,101,108,115,101,32,45,45,32,112,32,62,32,48,10,32,32,32,32,32, -32,32,32,105,102,32,32,32,32,32,114,32,60,32,116,105,49,32,116,104, -101,110,32,114,101,116,117,114,110,32,110,105,108,10,32,32,32,32,32,32, -32,32,101,108,115,101,105,102,32,114,32,60,32,116,105,50,32,116,104,101, -110,32,116,105,50,44,110,120,50,44,110,121,50,32,61,32,114,44,110,120, -44,110,121,10,32,32,32,32,32,32,32,32,101,110,100,10,32,32,32,32, -32,32,101,110,100,10,32,32,32,32,101,110,100,10,32,32,101,110,100,10, -10,32,32,114,101,116,117,114,110,32,116,105,49,44,116,105,50,44,32,110, -120,49,44,110,121,49,44,32,110,120,50,44,110,121,50,10,101,110,100,10, -10,45,45,32,67,97,108,99,117,108,97,116,101,115,32,116,104,101,32,109, -105,110,107,111,119,115,107,121,32,100,105,102,102,101,114,101,110,99,101,32, -98,101,116,119,101,101,110,32,50,32,114,101,99,116,115,44,32,119,104,105, -99,104,32,105,115,32,97,110,111,116,104,101,114,32,114,101,99,116,10,108, -111,99,97,108,32,102,117,110,99,116,105,111,110,32,114,101,99,116,95,103, -101,116,68,105,102,102,40,120,49,44,121,49,44,119,49,44,104,49,44,32, -120,50,44,121,50,44,119,50,44,104,50,41,10,32,32,114,101,116,117,114, -110,32,120,50,32,45,32,120,49,32,45,32,119,49,44,10,32,32,32,32, -32,32,32,32,32,121,50,32,45,32,121,49,32,45,32,104,49,44,10,32, -32,32,32,32,32,32,32,32,119,49,32,43,32,119,50,44,10,32,32,32, -32,32,32,32,32,32,104,49,32,43,32,104,50,10,101,110,100,10,10,108, -111,99,97,108,32,102,117,110,99,116,105,111,110,32,114,101,99,116,95,99, -111,110,116,97,105,110,115,80,111,105,110,116,40,120,44,121,44,119,44,104, -44,32,112,120,44,112,121,41,10,32,32,114,101,116,117,114,110,32,112,120, -32,45,32,120,32,62,32,68,69,76,84,65,32,32,32,32,32,32,97,110, -100,32,112,121,32,45,32,121,32,62,32,68,69,76,84,65,32,97,110,100, -10,32,32,32,32,32,32,32,32,32,120,32,43,32,119,32,45,32,112,120, -32,62,32,68,69,76,84,65,32,32,97,110,100,32,121,32,43,32,104,32, -45,32,112,121,32,62,32,68,69,76,84,65,10,101,110,100,10,10,108,111, -99,97,108,32,102,117,110,99,116,105,111,110,32,114,101,99,116,95,105,115, -73,110,116,101,114,115,101,99,116,105,110,103,40,120,49,44,121,49,44,119, -49,44,104,49,44,32,120,50,44,121,50,44,119,50,44,104,50,41,10,32, -32,114,101,116,117,114,110,32,120,49,32,60,32,120,50,43,119,50,32,97, -110,100,32,120,50,32,60,32,120,49,43,119,49,32,97,110,100,10,32,32, -32,32,32,32,32,32,32,121,49,32,60,32,121,50,43,104,50,32,97,110, -100,32,121,50,32,60,32,121,49,43,104,49,10,101,110,100,10,10,108,111, -99,97,108,32,102,117,110,99,116,105,111,110,32,114,101,99,116,95,103,101, -116,83,113,117,97,114,101,68,105,115,116,97,110,99,101,40,120,49,44,121, -49,44,119,49,44,104,49,44,32,120,50,44,121,50,44,119,50,44,104,50, -41,10,32,32,108,111,99,97,108,32,100,120,32,61,32,120,49,32,45,32, -120,50,32,43,32,40,119,49,32,45,32,119,50,41,47,50,10,32,32,108, -111,99,97,108,32,100,121,32,61,32,121,49,32,45,32,121,50,32,43,32, -40,104,49,32,45,32,104,50,41,47,50,10,32,32,114,101,116,117,114,110, -32,100,120,42,100,120,32,43,32,100,121,42,100,121,10,101,110,100,10,10, -108,111,99,97,108,32,102,117,110,99,116,105,111,110,32,114,101,99,116,95, -100,101,116,101,99,116,67,111,108,108,105,115,105,111,110,40,120,49,44,121, -49,44,119,49,44,104,49,44,32,120,50,44,121,50,44,119,50,44,104,50, -44,32,103,111,97,108,88,44,32,103,111,97,108,89,41,10,32,32,103,111, -97,108,88,32,61,32,103,111,97,108,88,32,111,114,32,120,49,10,32,32, -103,111,97,108,89,32,61,32,103,111,97,108,89,32,111,114,32,121,49,10, -10,32,32,108,111,99,97,108,32,100,120,44,32,100,121,32,32,32,32,32, -32,61,32,103,111,97,108,88,32,45,32,120,49,44,32,103,111,97,108,89, -32,45,32,121,49,10,32,32,108,111,99,97,108,32,120,44,121,44,119,44, -104,32,32,32,32,32,61,32,114,101,99,116,95,103,101,116,68,105,102,102, +110,121,13,10,32,32,32,32,32,32,32,32,101,110,100,13,10,32,32,32, +32,32,32,101,108,115,101,32,45,45,32,112,32,62,32,48,13,10,32,32, +32,32,32,32,32,32,105,102,32,32,32,32,32,114,32,60,32,116,105,49, +32,116,104,101,110,32,114,101,116,117,114,110,32,110,105,108,13,10,32,32, +32,32,32,32,32,32,101,108,115,101,105,102,32,114,32,60,32,116,105,50, +32,116,104,101,110,32,116,105,50,44,110,120,50,44,110,121,50,32,61,32, +114,44,110,120,44,110,121,13,10,32,32,32,32,32,32,32,32,101,110,100, +13,10,32,32,32,32,32,32,101,110,100,13,10,32,32,32,32,101,110,100, +13,10,32,32,101,110,100,13,10,13,10,32,32,114,101,116,117,114,110,32, +116,105,49,44,116,105,50,44,32,110,120,49,44,110,121,49,44,32,110,120, +50,44,110,121,50,13,10,101,110,100,13,10,13,10,45,45,32,67,97,108, +99,117,108,97,116,101,115,32,116,104,101,32,109,105,110,107,111,119,115,107, +121,32,100,105,102,102,101,114,101,110,99,101,32,98,101,116,119,101,101,110, +32,50,32,114,101,99,116,115,44,32,119,104,105,99,104,32,105,115,32,97, +110,111,116,104,101,114,32,114,101,99,116,13,10,108,111,99,97,108,32,102, +117,110,99,116,105,111,110,32,114,101,99,116,95,103,101,116,68,105,102,102, 40,120,49,44,121,49,44,119,49,44,104,49,44,32,120,50,44,121,50,44, -119,50,44,104,50,41,10,10,32,32,108,111,99,97,108,32,111,118,101,114, -108,97,112,115,44,32,116,105,44,32,110,120,44,32,110,121,10,10,32,32, -105,102,32,114,101,99,116,95,99,111,110,116,97,105,110,115,80,111,105,110, -116,40,120,44,121,44,119,44,104,44,32,48,44,48,41,32,116,104,101,110, -32,45,45,32,105,116,101,109,32,119,97,115,32,105,110,116,101,114,115,101, -99,116,105,110,103,32,111,116,104,101,114,10,32,32,32,32,108,111,99,97, -108,32,112,120,44,32,112,121,32,32,32,32,61,32,114,101,99,116,95,103, -101,116,78,101,97,114,101,115,116,67,111,114,110,101,114,40,120,44,121,44, -119,44,104,44,32,48,44,32,48,41,10,32,32,32,32,108,111,99,97,108, -32,119,105,44,32,104,105,32,32,32,32,61,32,109,105,110,40,119,49,44, -32,97,98,115,40,112,120,41,41,44,32,109,105,110,40,104,49,44,32,97, -98,115,40,112,121,41,41,32,45,45,32,97,114,101,97,32,111,102,32,105, -110,116,101,114,115,101,99,116,105,111,110,10,32,32,32,32,116,105,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,61,32,45,119,105,32,42,32, -104,105,32,45,45,32,116,105,32,105,115,32,116,104,101,32,110,101,103,97, -116,105,118,101,32,97,114,101,97,32,111,102,32,105,110,116,101,114,115,101, -99,116,105,111,110,10,32,32,32,32,111,118,101,114,108,97,112,115,32,61, -32,116,114,117,101,10,32,32,101,108,115,101,10,32,32,32,32,108,111,99, -97,108,32,116,105,49,44,116,105,50,44,110,120,49,44,110,121,49,32,61, -32,114,101,99,116,95,103,101,116,83,101,103,109,101,110,116,73,110,116,101, -114,115,101,99,116,105,111,110,73,110,100,105,99,101,115,40,120,44,121,44, -119,44,104,44,32,48,44,48,44,100,120,44,100,121,44,32,45,109,97,116, -104,46,104,117,103,101,44,32,109,97,116,104,46,104,117,103,101,41,10,10, -32,32,32,32,45,45,32,105,116,101,109,32,116,117,110,110,101,108,115,32, -105,110,116,111,32,111,116,104,101,114,10,32,32,32,32,105,102,32,116,105, -49,10,32,32,32,32,97,110,100,32,116,105,49,32,60,32,49,10,32,32, -32,32,97,110,100,32,40,97,98,115,40,116,105,49,32,45,32,116,105,50, -41,32,62,61,32,68,69,76,84,65,41,32,45,45,32,115,112,101,99,105, -97,108,32,99,97,115,101,32,102,111,114,32,114,101,99,116,32,103,111,105, -110,103,32,116,104,114,111,117,103,104,32,97,110,111,116,104,101,114,32,114, -101,99,116,39,115,32,99,111,114,110,101,114,10,32,32,32,32,97,110,100, -32,40,48,32,60,32,116,105,49,32,43,32,68,69,76,84,65,10,32,32, -32,32,32,32,111,114,32,48,32,61,61,32,116,105,49,32,97,110,100,32, -116,105,50,32,62,32,48,41,10,32,32,32,32,116,104,101,110,10,32,32, -32,32,32,32,116,105,44,32,110,120,44,32,110,121,32,61,32,116,105,49, -44,32,110,120,49,44,32,110,121,49,10,32,32,32,32,32,32,111,118,101, -114,108,97,112,115,32,32,32,61,32,102,97,108,115,101,10,32,32,32,32, -101,110,100,10,32,32,101,110,100,10,10,32,32,105,102,32,110,111,116,32, -116,105,32,116,104,101,110,32,114,101,116,117,114,110,32,101,110,100,10,10, -32,32,108,111,99,97,108,32,116,120,44,32,116,121,10,10,32,32,105,102, -32,111,118,101,114,108,97,112,115,32,116,104,101,110,10,32,32,32,32,105, -102,32,100,120,32,61,61,32,48,32,97,110,100,32,100,121,32,61,61,32, -48,32,116,104,101,110,10,32,32,32,32,32,32,45,45,32,105,110,116,101, -114,115,101,99,116,105,110,103,32,97,110,100,32,110,111,116,32,109,111,118, -105,110,103,32,45,32,117,115,101,32,109,105,110,105,109,117,109,32,100,105, -115,112,108,97,99,101,109,101,110,116,32,118,101,99,116,111,114,10,32,32, -32,32,32,32,108,111,99,97,108,32,112,120,44,32,112,121,32,61,32,114, -101,99,116,95,103,101,116,78,101,97,114,101,115,116,67,111,114,110,101,114, -40,120,44,121,44,119,44,104,44,32,48,44,48,41,10,32,32,32,32,32, -32,105,102,32,97,98,115,40,112,120,41,32,60,32,97,98,115,40,112,121, -41,32,116,104,101,110,32,112,121,32,61,32,48,32,101,108,115,101,32,112, -120,32,61,32,48,32,101,110,100,10,32,32,32,32,32,32,110,120,44,32, -110,121,32,61,32,115,105,103,110,40,112,120,41,44,32,115,105,103,110,40, -112,121,41,10,32,32,32,32,32,32,116,120,44,32,116,121,32,61,32,120, -49,32,43,32,112,120,44,32,121,49,32,43,32,112,121,10,32,32,32,32, -101,108,115,101,10,32,32,32,32,32,32,45,45,32,105,110,116,101,114,115, -101,99,116,105,110,103,32,97,110,100,32,109,111,118,105,110,103,32,45,32, -109,111,118,101,32,105,110,32,116,104,101,32,111,112,112,111,115,105,116,101, -32,100,105,114,101,99,116,105,111,110,10,32,32,32,32,32,32,108,111,99, -97,108,32,116,105,49,44,32,95,10,32,32,32,32,32,32,116,105,49,44, +119,50,44,104,50,41,13,10,32,32,114,101,116,117,114,110,32,120,50,32, +45,32,120,49,32,45,32,119,49,44,13,10,32,32,32,32,32,32,32,32, +32,121,50,32,45,32,121,49,32,45,32,104,49,44,13,10,32,32,32,32, +32,32,32,32,32,119,49,32,43,32,119,50,44,13,10,32,32,32,32,32, +32,32,32,32,104,49,32,43,32,104,50,13,10,101,110,100,13,10,13,10, +108,111,99,97,108,32,102,117,110,99,116,105,111,110,32,114,101,99,116,95, +99,111,110,116,97,105,110,115,80,111,105,110,116,40,120,44,121,44,119,44, +104,44,32,112,120,44,112,121,41,13,10,32,32,114,101,116,117,114,110,32, +112,120,32,45,32,120,32,62,32,68,69,76,84,65,32,32,32,32,32,32, +97,110,100,32,112,121,32,45,32,121,32,62,32,68,69,76,84,65,32,97, +110,100,13,10,32,32,32,32,32,32,32,32,32,120,32,43,32,119,32,45, +32,112,120,32,62,32,68,69,76,84,65,32,32,97,110,100,32,121,32,43, +32,104,32,45,32,112,121,32,62,32,68,69,76,84,65,13,10,101,110,100, +13,10,13,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110,32,114, +101,99,116,95,105,115,73,110,116,101,114,115,101,99,116,105,110,103,40,120, +49,44,121,49,44,119,49,44,104,49,44,32,120,50,44,121,50,44,119,50, +44,104,50,41,13,10,32,32,114,101,116,117,114,110,32,120,49,32,60,32, +120,50,43,119,50,32,97,110,100,32,120,50,32,60,32,120,49,43,119,49, +32,97,110,100,13,10,32,32,32,32,32,32,32,32,32,121,49,32,60,32, +121,50,43,104,50,32,97,110,100,32,121,50,32,60,32,121,49,43,104,49, +13,10,101,110,100,13,10,13,10,108,111,99,97,108,32,102,117,110,99,116, +105,111,110,32,114,101,99,116,95,103,101,116,83,113,117,97,114,101,68,105, +115,116,97,110,99,101,40,120,49,44,121,49,44,119,49,44,104,49,44,32, +120,50,44,121,50,44,119,50,44,104,50,41,13,10,32,32,108,111,99,97, +108,32,100,120,32,61,32,120,49,32,45,32,120,50,32,43,32,40,119,49, +32,45,32,119,50,41,47,50,13,10,32,32,108,111,99,97,108,32,100,121, +32,61,32,121,49,32,45,32,121,50,32,43,32,40,104,49,32,45,32,104, +50,41,47,50,13,10,32,32,114,101,116,117,114,110,32,100,120,42,100,120, +32,43,32,100,121,42,100,121,13,10,101,110,100,13,10,13,10,108,111,99, +97,108,32,102,117,110,99,116,105,111,110,32,114,101,99,116,95,100,101,116, +101,99,116,67,111,108,108,105,115,105,111,110,40,120,49,44,121,49,44,119, +49,44,104,49,44,32,120,50,44,121,50,44,119,50,44,104,50,44,32,103, +111,97,108,88,44,32,103,111,97,108,89,41,13,10,32,32,103,111,97,108, +88,32,61,32,103,111,97,108,88,32,111,114,32,120,49,13,10,32,32,103, +111,97,108,89,32,61,32,103,111,97,108,89,32,111,114,32,121,49,13,10, +13,10,32,32,108,111,99,97,108,32,100,120,44,32,100,121,32,32,32,32, +32,32,61,32,103,111,97,108,88,32,45,32,120,49,44,32,103,111,97,108, +89,32,45,32,121,49,13,10,32,32,108,111,99,97,108,32,120,44,121,44, +119,44,104,32,32,32,32,32,61,32,114,101,99,116,95,103,101,116,68,105, +102,102,40,120,49,44,121,49,44,119,49,44,104,49,44,32,120,50,44,121, +50,44,119,50,44,104,50,41,13,10,13,10,32,32,108,111,99,97,108,32, +111,118,101,114,108,97,112,115,44,32,116,105,44,32,110,120,44,32,110,121, +13,10,13,10,32,32,105,102,32,114,101,99,116,95,99,111,110,116,97,105, +110,115,80,111,105,110,116,40,120,44,121,44,119,44,104,44,32,48,44,48, +41,32,116,104,101,110,32,45,45,32,105,116,101,109,32,119,97,115,32,105, +110,116,101,114,115,101,99,116,105,110,103,32,111,116,104,101,114,13,10,32, +32,32,32,108,111,99,97,108,32,112,120,44,32,112,121,32,32,32,32,61, +32,114,101,99,116,95,103,101,116,78,101,97,114,101,115,116,67,111,114,110, +101,114,40,120,44,121,44,119,44,104,44,32,48,44,32,48,41,13,10,32, +32,32,32,108,111,99,97,108,32,119,105,44,32,104,105,32,32,32,32,61, +32,109,105,110,40,119,49,44,32,97,98,115,40,112,120,41,41,44,32,109, +105,110,40,104,49,44,32,97,98,115,40,112,121,41,41,32,45,45,32,97, +114,101,97,32,111,102,32,105,110,116,101,114,115,101,99,116,105,111,110,13, +10,32,32,32,32,116,105,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,61,32,45,119,105,32,42,32,104,105,32,45,45,32,116,105,32,105,115, +32,116,104,101,32,110,101,103,97,116,105,118,101,32,97,114,101,97,32,111, +102,32,105,110,116,101,114,115,101,99,116,105,111,110,13,10,32,32,32,32, +111,118,101,114,108,97,112,115,32,61,32,116,114,117,101,13,10,32,32,101, +108,115,101,13,10,32,32,32,32,108,111,99,97,108,32,116,105,49,44,116, +105,50,44,110,120,49,44,110,121,49,32,61,32,114,101,99,116,95,103,101, +116,83,101,103,109,101,110,116,73,110,116,101,114,115,101,99,116,105,111,110, +73,110,100,105,99,101,115,40,120,44,121,44,119,44,104,44,32,48,44,48, +44,100,120,44,100,121,44,32,45,109,97,116,104,46,104,117,103,101,44,32, +109,97,116,104,46,104,117,103,101,41,13,10,13,10,32,32,32,32,45,45, +32,105,116,101,109,32,116,117,110,110,101,108,115,32,105,110,116,111,32,111, +116,104,101,114,13,10,32,32,32,32,105,102,32,116,105,49,13,10,32,32, +32,32,97,110,100,32,116,105,49,32,60,32,49,13,10,32,32,32,32,97, +110,100,32,40,97,98,115,40,116,105,49,32,45,32,116,105,50,41,32,62, +61,32,68,69,76,84,65,41,32,45,45,32,115,112,101,99,105,97,108,32, +99,97,115,101,32,102,111,114,32,114,101,99,116,32,103,111,105,110,103,32, +116,104,114,111,117,103,104,32,97,110,111,116,104,101,114,32,114,101,99,116, +39,115,32,99,111,114,110,101,114,13,10,32,32,32,32,97,110,100,32,40, +48,32,60,32,116,105,49,32,43,32,68,69,76,84,65,13,10,32,32,32, +32,32,32,111,114,32,48,32,61,61,32,116,105,49,32,97,110,100,32,116, +105,50,32,62,32,48,41,13,10,32,32,32,32,116,104,101,110,13,10,32, +32,32,32,32,32,116,105,44,32,110,120,44,32,110,121,32,61,32,116,105, +49,44,32,110,120,49,44,32,110,121,49,13,10,32,32,32,32,32,32,111, +118,101,114,108,97,112,115,32,32,32,61,32,102,97,108,115,101,13,10,32, +32,32,32,101,110,100,13,10,32,32,101,110,100,13,10,13,10,32,32,105, +102,32,110,111,116,32,116,105,32,116,104,101,110,32,114,101,116,117,114,110, +32,101,110,100,13,10,13,10,32,32,108,111,99,97,108,32,116,120,44,32, +116,121,13,10,13,10,32,32,105,102,32,111,118,101,114,108,97,112,115,32, +116,104,101,110,13,10,32,32,32,32,105,102,32,100,120,32,61,61,32,48, +32,97,110,100,32,100,121,32,61,61,32,48,32,116,104,101,110,13,10,32, +32,32,32,32,32,45,45,32,105,110,116,101,114,115,101,99,116,105,110,103, +32,97,110,100,32,110,111,116,32,109,111,118,105,110,103,32,45,32,117,115, +101,32,109,105,110,105,109,117,109,32,100,105,115,112,108,97,99,101,109,101, +110,116,32,118,101,99,116,111,114,13,10,32,32,32,32,32,32,108,111,99, +97,108,32,112,120,44,32,112,121,32,61,32,114,101,99,116,95,103,101,116, +78,101,97,114,101,115,116,67,111,114,110,101,114,40,120,44,121,44,119,44, +104,44,32,48,44,48,41,13,10,32,32,32,32,32,32,105,102,32,97,98, +115,40,112,120,41,32,60,32,97,98,115,40,112,121,41,32,116,104,101,110, +32,112,121,32,61,32,48,32,101,108,115,101,32,112,120,32,61,32,48,32, +101,110,100,13,10,32,32,32,32,32,32,110,120,44,32,110,121,32,61,32, +115,105,103,110,40,112,120,41,44,32,115,105,103,110,40,112,121,41,13,10, +32,32,32,32,32,32,116,120,44,32,116,121,32,61,32,120,49,32,43,32, +112,120,44,32,121,49,32,43,32,112,121,13,10,32,32,32,32,101,108,115, +101,13,10,32,32,32,32,32,32,45,45,32,105,110,116,101,114,115,101,99, +116,105,110,103,32,97,110,100,32,109,111,118,105,110,103,32,45,32,109,111, +118,101,32,105,110,32,116,104,101,32,111,112,112,111,115,105,116,101,32,100, +105,114,101,99,116,105,111,110,13,10,32,32,32,32,32,32,108,111,99,97, +108,32,116,105,49,44,32,95,13,10,32,32,32,32,32,32,116,105,49,44, 95,44,110,120,44,110,121,32,61,32,114,101,99,116,95,103,101,116,83,101, 103,109,101,110,116,73,110,116,101,114,115,101,99,116,105,111,110,73,110,100, 105,99,101,115,40,120,44,121,44,119,44,104,44,32,48,44,48,44,100,120, -44,100,121,44,32,45,109,97,116,104,46,104,117,103,101,44,32,49,41,10, -32,32,32,32,32,32,105,102,32,110,111,116,32,116,105,49,32,116,104,101, -110,32,114,101,116,117,114,110,32,101,110,100,10,32,32,32,32,32,32,116, -120,44,32,116,121,32,61,32,120,49,32,43,32,100,120,32,42,32,116,105, -49,44,32,121,49,32,43,32,100,121,32,42,32,116,105,49,10,32,32,32, -32,101,110,100,10,32,32,101,108,115,101,32,45,45,32,116,117,110,110,101, -108,10,32,32,32,32,116,120,44,32,116,121,32,61,32,120,49,32,43,32, -100,120,32,42,32,116,105,44,32,121,49,32,43,32,100,121,32,42,32,116, -105,10,32,32,101,110,100,10,10,32,32,114,101,116,117,114,110,32,123,10, -32,32,32,32,111,118,101,114,108,97,112,115,32,32,61,32,111,118,101,114, -108,97,112,115,44,10,32,32,32,32,116,105,32,32,32,32,32,32,32,32, -61,32,116,105,44,10,32,32,32,32,109,111,118,101,32,32,32,32,32,32, -61,32,123,120,32,61,32,100,120,44,32,121,32,61,32,100,121,125,44,10, -32,32,32,32,110,111,114,109,97,108,32,32,32,32,61,32,123,120,32,61, -32,110,120,44,32,121,32,61,32,110,121,125,44,10,32,32,32,32,116,111, -117,99,104,32,32,32,32,32,61,32,123,120,32,61,32,116,120,44,32,121, -32,61,32,116,121,125,44,10,32,32,32,32,105,116,101,109,82,101,99,116, -32,32,61,32,123,120,32,61,32,120,49,44,32,121,32,61,32,121,49,44, -32,119,32,61,32,119,49,44,32,104,32,61,32,104,49,125,44,10,32,32, -32,32,111,116,104,101,114,82,101,99,116,32,61,32,123,120,32,61,32,120, -50,44,32,121,32,61,32,121,50,44,32,119,32,61,32,119,50,44,32,104, -32,61,32,104,50,125,10,32,32,125,10,101,110,100,10,10,45,45,45,45, +44,100,121,44,32,45,109,97,116,104,46,104,117,103,101,44,32,49,41,13, +10,32,32,32,32,32,32,105,102,32,110,111,116,32,116,105,49,32,116,104, +101,110,32,114,101,116,117,114,110,32,101,110,100,13,10,32,32,32,32,32, +32,116,120,44,32,116,121,32,61,32,120,49,32,43,32,100,120,32,42,32, +116,105,49,44,32,121,49,32,43,32,100,121,32,42,32,116,105,49,13,10, +32,32,32,32,101,110,100,13,10,32,32,101,108,115,101,32,45,45,32,116, +117,110,110,101,108,13,10,32,32,32,32,116,120,44,32,116,121,32,61,32, +120,49,32,43,32,100,120,32,42,32,116,105,44,32,121,49,32,43,32,100, +121,32,42,32,116,105,13,10,32,32,101,110,100,13,10,13,10,32,32,114, +101,116,117,114,110,32,123,13,10,32,32,32,32,111,118,101,114,108,97,112, +115,32,32,61,32,111,118,101,114,108,97,112,115,44,13,10,32,32,32,32, +116,105,32,32,32,32,32,32,32,32,61,32,116,105,44,13,10,32,32,32, +32,109,111,118,101,32,32,32,32,32,32,61,32,123,120,32,61,32,100,120, +44,32,121,32,61,32,100,121,125,44,13,10,32,32,32,32,110,111,114,109, +97,108,32,32,32,32,61,32,123,120,32,61,32,110,120,44,32,121,32,61, +32,110,121,125,44,13,10,32,32,32,32,116,111,117,99,104,32,32,32,32, +32,61,32,123,120,32,61,32,116,120,44,32,121,32,61,32,116,121,125,44, +13,10,32,32,32,32,105,116,101,109,82,101,99,116,32,32,61,32,123,120, +32,61,32,120,49,44,32,121,32,61,32,121,49,44,32,119,32,61,32,119, +49,44,32,104,32,61,32,104,49,125,44,13,10,32,32,32,32,111,116,104, +101,114,82,101,99,116,32,61,32,123,120,32,61,32,120,50,44,32,121,32, +61,32,121,50,44,32,119,32,61,32,119,50,44,32,104,32,61,32,104,50, +125,13,10,32,32,125,13,10,101,110,100,13,10,13,10,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,10,45, -45,32,71,114,105,100,32,102,117,110,99,116,105,111,110,115,10,45,45,45, +45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,13,10,45, +45,32,71,114,105,100,32,102,117,110,99,116,105,111,110,115,13,10,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,10, -10,108,111,99,97,108,32,102,117,110,99,116,105,111,110,32,103,114,105,100, -95,116,111,87,111,114,108,100,40,99,101,108,108,83,105,122,101,44,32,99, -120,44,32,99,121,41,10,32,32,114,101,116,117,114,110,32,40,99,120,32, -45,32,49,41,42,99,101,108,108,83,105,122,101,44,32,40,99,121,45,49, -41,42,99,101,108,108,83,105,122,101,10,101,110,100,10,10,108,111,99,97, -108,32,102,117,110,99,116,105,111,110,32,103,114,105,100,95,116,111,67,101, -108,108,40,99,101,108,108,83,105,122,101,44,32,120,44,32,121,41,10,32, -32,114,101,116,117,114,110,32,102,108,111,111,114,40,120,32,47,32,99,101, -108,108,83,105,122,101,41,32,43,32,49,44,32,102,108,111,111,114,40,121, -32,47,32,99,101,108,108,83,105,122,101,41,32,43,32,49,10,101,110,100, -10,10,45,45,32,103,114,105,100,95,116,114,97,118,101,114,115,101,42,32, -102,117,110,99,116,105,111,110,115,32,97,114,101,32,98,97,115,101,100,32, -111,110,32,34,65,32,70,97,115,116,32,86,111,120,101,108,32,84,114,97, -118,101,114,115,97,108,32,65,108,103,111,114,105,116,104,109,32,102,111,114, -32,82,97,121,32,84,114,97,99,105,110,103,34,44,10,45,45,32,98,121, -32,74,111,104,110,32,65,109,97,110,105,100,101,115,32,97,110,100,32,65, -110,100,114,101,119,32,87,111,111,32,45,32,104,116,116,112,58,47,47,119, -119,119,46,99,115,101,46,121,111,114,107,117,46,99,97,47,126,97,109,97, -110,97,47,114,101,115,101,97,114,99,104,47,103,114,105,100,46,112,100,102, -10,45,45,32,73,116,32,104,97,115,32,98,101,101,110,32,109,111,100,105, -102,105,101,100,32,116,111,32,105,110,99,108,117,100,101,32,98,111,116,104, -32,99,101,108,108,115,32,119,104,101,110,32,116,104,101,32,114,97,121,32, -34,116,111,117,99,104,101,115,32,97,32,103,114,105,100,32,99,111,114,110, -101,114,34,44,10,45,45,32,97,110,100,32,119,105,116,104,32,97,32,100, -105,102,102,101,114,101,110,116,32,101,120,105,116,32,99,111,110,100,105,116, -105,111,110,10,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110,32, -103,114,105,100,95,116,114,97,118,101,114,115,101,95,105,110,105,116,83,116, -101,112,40,99,101,108,108,83,105,122,101,44,32,99,116,44,32,116,49,44, -32,116,50,41,10,32,32,108,111,99,97,108,32,118,32,61,32,116,50,32, -45,32,116,49,10,32,32,105,102,32,32,32,32,32,118,32,62,32,48,32, -116,104,101,110,10,32,32,32,32,114,101,116,117,114,110,32,32,49,44,32, -32,99,101,108,108,83,105,122,101,32,47,32,118,44,32,40,40,99,116,32, -43,32,118,41,32,42,32,99,101,108,108,83,105,122,101,32,45,32,116,49, -41,32,47,32,118,10,32,32,101,108,115,101,105,102,32,118,32,60,32,48, -32,116,104,101,110,10,32,32,32,32,114,101,116,117,114,110,32,45,49,44, -32,45,99,101,108,108,83,105,122,101,32,47,32,118,44,32,40,40,99,116, -32,43,32,118,32,45,32,49,41,32,42,32,99,101,108,108,83,105,122,101, -32,45,32,116,49,41,32,47,32,118,10,32,32,101,108,115,101,10,32,32, -32,32,114,101,116,117,114,110,32,48,44,32,109,97,116,104,46,104,117,103, -101,44,32,109,97,116,104,46,104,117,103,101,10,32,32,101,110,100,10,101, -110,100,10,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110,32,103, -114,105,100,95,116,114,97,118,101,114,115,101,40,99,101,108,108,83,105,122, -101,44,32,120,49,44,121,49,44,120,50,44,121,50,44,32,102,41,10,32, -32,108,111,99,97,108,32,99,120,49,44,99,121,49,32,32,32,32,32,32, -32,32,61,32,103,114,105,100,95,116,111,67,101,108,108,40,99,101,108,108, -83,105,122,101,44,32,120,49,44,121,49,41,10,32,32,108,111,99,97,108, -32,99,120,50,44,99,121,50,32,32,32,32,32,32,32,32,61,32,103,114, +45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, +13,10,13,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110,32,103, +114,105,100,95,116,111,87,111,114,108,100,40,99,101,108,108,83,105,122,101, +44,32,99,120,44,32,99,121,41,13,10,32,32,114,101,116,117,114,110,32, +40,99,120,32,45,32,49,41,42,99,101,108,108,83,105,122,101,44,32,40, +99,121,45,49,41,42,99,101,108,108,83,105,122,101,13,10,101,110,100,13, +10,13,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110,32,103,114, 105,100,95,116,111,67,101,108,108,40,99,101,108,108,83,105,122,101,44,32, -120,50,44,121,50,41,10,32,32,108,111,99,97,108,32,115,116,101,112,88, -44,32,100,120,44,32,116,120,32,32,61,32,103,114,105,100,95,116,114,97, -118,101,114,115,101,95,105,110,105,116,83,116,101,112,40,99,101,108,108,83, -105,122,101,44,32,99,120,49,44,32,120,49,44,32,120,50,41,10,32,32, -108,111,99,97,108,32,115,116,101,112,89,44,32,100,121,44,32,116,121,32, -32,61,32,103,114,105,100,95,116,114,97,118,101,114,115,101,95,105,110,105, -116,83,116,101,112,40,99,101,108,108,83,105,122,101,44,32,99,121,49,44, -32,121,49,44,32,121,50,41,10,32,32,108,111,99,97,108,32,99,120,44, -99,121,32,32,32,32,32,32,32,32,32,32,61,32,99,120,49,44,99,121, -49,10,10,32,32,102,40,99,120,44,32,99,121,41,10,10,32,32,45,45, -32,84,104,101,32,100,101,102,97,117,108,116,32,105,109,112,108,101,109,101, -110,116,97,116,105,111,110,32,104,97,100,32,97,110,32,105,110,102,105,110, -105,116,101,32,108,111,111,112,32,112,114,111,98,108,101,109,32,119,104,101, -110,10,32,32,45,45,32,97,112,112,114,111,97,99,104,105,110,103,32,116, -104,101,32,108,97,115,116,32,99,101,108,108,32,105,110,32,115,111,109,101, -32,111,99,99,97,115,115,105,111,110,115,46,32,87,101,32,102,105,110,105, -115,104,32,105,116,101,114,97,116,105,110,103,10,32,32,45,45,32,119,104, -101,110,32,119,101,32,97,114,101,32,42,110,101,120,116,42,32,116,111,32, -116,104,101,32,108,97,115,116,32,99,101,108,108,10,32,32,119,104,105,108, -101,32,97,98,115,40,99,120,32,45,32,99,120,50,41,32,43,32,97,98, -115,40,99,121,32,45,32,99,121,50,41,32,62,32,49,32,100,111,10,32, -32,32,32,105,102,32,116,120,32,60,32,116,121,32,116,104,101,110,10,32, -32,32,32,32,32,116,120,44,32,99,120,32,61,32,116,120,32,43,32,100, -120,44,32,99,120,32,43,32,115,116,101,112,88,10,32,32,32,32,32,32, -102,40,99,120,44,32,99,121,41,10,32,32,32,32,101,108,115,101,10,32, -32,32,32,32,32,45,45,32,65,100,100,105,116,105,111,110,58,32,105,110, -99,108,117,100,101,32,98,111,116,104,32,99,101,108,108,115,32,119,104,101, -110,32,103,111,105,110,103,32,116,104,114,111,117,103,104,32,99,111,114,110, -101,114,115,10,32,32,32,32,32,32,105,102,32,116,120,32,61,61,32,116, -121,32,116,104,101,110,32,102,40,99,120,32,43,32,115,116,101,112,88,44, -32,99,121,41,32,101,110,100,10,32,32,32,32,32,32,116,121,44,32,99, -121,32,61,32,116,121,32,43,32,100,121,44,32,99,121,32,43,32,115,116, -101,112,89,10,32,32,32,32,32,32,102,40,99,120,44,32,99,121,41,10, -32,32,32,32,101,110,100,10,32,32,101,110,100,10,10,32,32,45,45,32, -73,102,32,119,101,32,104,97,118,101,32,110,111,116,32,97,114,114,105,118, -101,100,32,116,111,32,116,104,101,32,108,97,115,116,32,99,101,108,108,44, -32,117,115,101,32,105,116,10,32,32,105,102,32,99,120,32,126,61,32,99, -120,50,32,111,114,32,99,121,32,126,61,32,99,121,50,32,116,104,101,110, -32,102,40,99,120,50,44,32,99,121,50,41,32,101,110,100,10,10,101,110, -100,10,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110,32,103,114, -105,100,95,116,111,67,101,108,108,82,101,99,116,40,99,101,108,108,83,105, -122,101,44,32,120,44,121,44,119,44,104,41,10,32,32,108,111,99,97,108, -32,99,120,44,99,121,32,61,32,103,114,105,100,95,116,111,67,101,108,108, -40,99,101,108,108,83,105,122,101,44,32,120,44,32,121,41,10,32,32,108, -111,99,97,108,32,99,114,44,99,98,32,61,32,99,101,105,108,40,40,120, -43,119,41,32,47,32,99,101,108,108,83,105,122,101,41,44,32,99,101,105, -108,40,40,121,43,104,41,32,47,32,99,101,108,108,83,105,122,101,41,10, -32,32,114,101,116,117,114,110,32,99,120,44,32,99,121,44,32,99,114,32, -45,32,99,120,32,43,32,49,44,32,99,98,32,45,32,99,121,32,43,32, -49,10,101,110,100,10,10,45,45,45,45,45,45,45,45,45,45,45,45,45, +120,44,32,121,41,13,10,32,32,114,101,116,117,114,110,32,102,108,111,111, +114,40,120,32,47,32,99,101,108,108,83,105,122,101,41,32,43,32,49,44, +32,102,108,111,111,114,40,121,32,47,32,99,101,108,108,83,105,122,101,41, +32,43,32,49,13,10,101,110,100,13,10,13,10,45,45,32,103,114,105,100, +95,116,114,97,118,101,114,115,101,42,32,102,117,110,99,116,105,111,110,115, +32,97,114,101,32,98,97,115,101,100,32,111,110,32,34,65,32,70,97,115, +116,32,86,111,120,101,108,32,84,114,97,118,101,114,115,97,108,32,65,108, +103,111,114,105,116,104,109,32,102,111,114,32,82,97,121,32,84,114,97,99, +105,110,103,34,44,13,10,45,45,32,98,121,32,74,111,104,110,32,65,109, +97,110,105,100,101,115,32,97,110,100,32,65,110,100,114,101,119,32,87,111, +111,32,45,32,104,116,116,112,58,47,47,119,119,119,46,99,115,101,46,121, +111,114,107,117,46,99,97,47,126,97,109,97,110,97,47,114,101,115,101,97, +114,99,104,47,103,114,105,100,46,112,100,102,13,10,45,45,32,73,116,32, +104,97,115,32,98,101,101,110,32,109,111,100,105,102,105,101,100,32,116,111, +32,105,110,99,108,117,100,101,32,98,111,116,104,32,99,101,108,108,115,32, +119,104,101,110,32,116,104,101,32,114,97,121,32,34,116,111,117,99,104,101, +115,32,97,32,103,114,105,100,32,99,111,114,110,101,114,34,44,13,10,45, +45,32,97,110,100,32,119,105,116,104,32,97,32,100,105,102,102,101,114,101, +110,116,32,101,120,105,116,32,99,111,110,100,105,116,105,111,110,13,10,13, +10,108,111,99,97,108,32,102,117,110,99,116,105,111,110,32,103,114,105,100, +95,116,114,97,118,101,114,115,101,95,105,110,105,116,83,116,101,112,40,99, +101,108,108,83,105,122,101,44,32,99,116,44,32,116,49,44,32,116,50,41, +13,10,32,32,108,111,99,97,108,32,118,32,61,32,116,50,32,45,32,116, +49,13,10,32,32,105,102,32,32,32,32,32,118,32,62,32,48,32,116,104, +101,110,13,10,32,32,32,32,114,101,116,117,114,110,32,32,49,44,32,32, +99,101,108,108,83,105,122,101,32,47,32,118,44,32,40,40,99,116,32,43, +32,118,41,32,42,32,99,101,108,108,83,105,122,101,32,45,32,116,49,41, +32,47,32,118,13,10,32,32,101,108,115,101,105,102,32,118,32,60,32,48, +32,116,104,101,110,13,10,32,32,32,32,114,101,116,117,114,110,32,45,49, +44,32,45,99,101,108,108,83,105,122,101,32,47,32,118,44,32,40,40,99, +116,32,43,32,118,32,45,32,49,41,32,42,32,99,101,108,108,83,105,122, +101,32,45,32,116,49,41,32,47,32,118,13,10,32,32,101,108,115,101,13, +10,32,32,32,32,114,101,116,117,114,110,32,48,44,32,109,97,116,104,46, +104,117,103,101,44,32,109,97,116,104,46,104,117,103,101,13,10,32,32,101, +110,100,13,10,101,110,100,13,10,13,10,108,111,99,97,108,32,102,117,110, +99,116,105,111,110,32,103,114,105,100,95,116,114,97,118,101,114,115,101,40, +99,101,108,108,83,105,122,101,44,32,120,49,44,121,49,44,120,50,44,121, +50,44,32,102,41,13,10,32,32,108,111,99,97,108,32,99,120,49,44,99, +121,49,32,32,32,32,32,32,32,32,61,32,103,114,105,100,95,116,111,67, +101,108,108,40,99,101,108,108,83,105,122,101,44,32,120,49,44,121,49,41, +13,10,32,32,108,111,99,97,108,32,99,120,50,44,99,121,50,32,32,32, +32,32,32,32,32,61,32,103,114,105,100,95,116,111,67,101,108,108,40,99, +101,108,108,83,105,122,101,44,32,120,50,44,121,50,41,13,10,32,32,108, +111,99,97,108,32,115,116,101,112,88,44,32,100,120,44,32,116,120,32,32, +61,32,103,114,105,100,95,116,114,97,118,101,114,115,101,95,105,110,105,116, +83,116,101,112,40,99,101,108,108,83,105,122,101,44,32,99,120,49,44,32, +120,49,44,32,120,50,41,13,10,32,32,108,111,99,97,108,32,115,116,101, +112,89,44,32,100,121,44,32,116,121,32,32,61,32,103,114,105,100,95,116, +114,97,118,101,114,115,101,95,105,110,105,116,83,116,101,112,40,99,101,108, +108,83,105,122,101,44,32,99,121,49,44,32,121,49,44,32,121,50,41,13, +10,32,32,108,111,99,97,108,32,99,120,44,99,121,32,32,32,32,32,32, +32,32,32,32,61,32,99,120,49,44,99,121,49,13,10,13,10,32,32,102, +40,99,120,44,32,99,121,41,13,10,13,10,32,32,45,45,32,84,104,101, +32,100,101,102,97,117,108,116,32,105,109,112,108,101,109,101,110,116,97,116, +105,111,110,32,104,97,100,32,97,110,32,105,110,102,105,110,105,116,101,32, +108,111,111,112,32,112,114,111,98,108,101,109,32,119,104,101,110,13,10,32, +32,45,45,32,97,112,112,114,111,97,99,104,105,110,103,32,116,104,101,32, +108,97,115,116,32,99,101,108,108,32,105,110,32,115,111,109,101,32,111,99, +99,97,115,115,105,111,110,115,46,32,87,101,32,102,105,110,105,115,104,32, +105,116,101,114,97,116,105,110,103,13,10,32,32,45,45,32,119,104,101,110, +32,119,101,32,97,114,101,32,42,110,101,120,116,42,32,116,111,32,116,104, +101,32,108,97,115,116,32,99,101,108,108,13,10,32,32,119,104,105,108,101, +32,97,98,115,40,99,120,32,45,32,99,120,50,41,32,43,32,97,98,115, +40,99,121,32,45,32,99,121,50,41,32,62,32,49,32,100,111,13,10,32, +32,32,32,105,102,32,116,120,32,60,32,116,121,32,116,104,101,110,13,10, +32,32,32,32,32,32,116,120,44,32,99,120,32,61,32,116,120,32,43,32, +100,120,44,32,99,120,32,43,32,115,116,101,112,88,13,10,32,32,32,32, +32,32,102,40,99,120,44,32,99,121,41,13,10,32,32,32,32,101,108,115, +101,13,10,32,32,32,32,32,32,45,45,32,65,100,100,105,116,105,111,110, +58,32,105,110,99,108,117,100,101,32,98,111,116,104,32,99,101,108,108,115, +32,119,104,101,110,32,103,111,105,110,103,32,116,104,114,111,117,103,104,32, +99,111,114,110,101,114,115,13,10,32,32,32,32,32,32,105,102,32,116,120, +32,61,61,32,116,121,32,116,104,101,110,32,102,40,99,120,32,43,32,115, +116,101,112,88,44,32,99,121,41,32,101,110,100,13,10,32,32,32,32,32, +32,116,121,44,32,99,121,32,61,32,116,121,32,43,32,100,121,44,32,99, +121,32,43,32,115,116,101,112,89,13,10,32,32,32,32,32,32,102,40,99, +120,44,32,99,121,41,13,10,32,32,32,32,101,110,100,13,10,32,32,101, +110,100,13,10,13,10,32,32,45,45,32,73,102,32,119,101,32,104,97,118, +101,32,110,111,116,32,97,114,114,105,118,101,100,32,116,111,32,116,104,101, +32,108,97,115,116,32,99,101,108,108,44,32,117,115,101,32,105,116,13,10, +32,32,105,102,32,99,120,32,126,61,32,99,120,50,32,111,114,32,99,121, +32,126,61,32,99,121,50,32,116,104,101,110,32,102,40,99,120,50,44,32, +99,121,50,41,32,101,110,100,13,10,13,10,101,110,100,13,10,13,10,108, +111,99,97,108,32,102,117,110,99,116,105,111,110,32,103,114,105,100,95,116, +111,67,101,108,108,82,101,99,116,40,99,101,108,108,83,105,122,101,44,32, +120,44,121,44,119,44,104,41,13,10,32,32,108,111,99,97,108,32,99,120, +44,99,121,32,61,32,103,114,105,100,95,116,111,67,101,108,108,40,99,101, +108,108,83,105,122,101,44,32,120,44,32,121,41,13,10,32,32,108,111,99, +97,108,32,99,114,44,99,98,32,61,32,99,101,105,108,40,40,120,43,119, +41,32,47,32,99,101,108,108,83,105,122,101,41,44,32,99,101,105,108,40, +40,121,43,104,41,32,47,32,99,101,108,108,83,105,122,101,41,13,10,32, +32,114,101,116,117,114,110,32,99,120,44,32,99,121,44,32,99,114,32,45, +32,99,120,32,43,32,49,44,32,99,98,32,45,32,99,121,32,43,32,49, +13,10,101,110,100,13,10,13,10,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,45,45,45,45,45,45,45,45,10,45,45,32,82,101,115,112,111,110,115, -101,115,10,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, +45,45,45,45,45,45,45,45,45,45,45,13,10,45,45,32,82,101,115,112, +111,110,115,101,115,13,10,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,45,45,45,45,10,10,108,111,99,97,108,32,116,111,117,99,104,32,61, -32,102,117,110,99,116,105,111,110,40,119,111,114,108,100,44,32,99,111,108, -44,32,120,44,121,44,119,44,104,44,32,103,111,97,108,88,44,32,103,111, -97,108,89,44,32,102,105,108,116,101,114,41,10,32,32,114,101,116,117,114, -110,32,99,111,108,46,116,111,117,99,104,46,120,44,32,99,111,108,46,116, -111,117,99,104,46,121,44,32,123,125,44,32,48,10,101,110,100,10,10,108, -111,99,97,108,32,99,114,111,115,115,32,61,32,102,117,110,99,116,105,111, -110,40,119,111,114,108,100,44,32,99,111,108,44,32,120,44,121,44,119,44, -104,44,32,103,111,97,108,88,44,32,103,111,97,108,89,44,32,102,105,108, -116,101,114,41,10,32,32,108,111,99,97,108,32,99,111,108,115,44,32,108, -101,110,32,61,32,119,111,114,108,100,58,112,114,111,106,101,99,116,40,99, -111,108,46,105,116,101,109,44,32,120,44,121,44,119,44,104,44,32,103,111, -97,108,88,44,32,103,111,97,108,89,44,32,102,105,108,116,101,114,41,10, -32,32,114,101,116,117,114,110,32,103,111,97,108,88,44,32,103,111,97,108, -89,44,32,99,111,108,115,44,32,108,101,110,10,101,110,100,10,10,108,111, -99,97,108,32,115,108,105,100,101,32,61,32,102,117,110,99,116,105,111,110, -40,119,111,114,108,100,44,32,99,111,108,44,32,120,44,121,44,119,44,104, -44,32,103,111,97,108,88,44,32,103,111,97,108,89,44,32,102,105,108,116, -101,114,41,10,32,32,103,111,97,108,88,32,61,32,103,111,97,108,88,32, -111,114,32,120,10,32,32,103,111,97,108,89,32,61,32,103,111,97,108,89, -32,111,114,32,121,10,10,32,32,108,111,99,97,108,32,116,99,104,44,32, -109,111,118,101,32,32,61,32,99,111,108,46,116,111,117,99,104,44,32,99, -111,108,46,109,111,118,101,10,32,32,105,102,32,109,111,118,101,46,120,32, -126,61,32,48,32,111,114,32,109,111,118,101,46,121,32,126,61,32,48,32, -116,104,101,110,10,32,32,32,32,105,102,32,99,111,108,46,110,111,114,109, -97,108,46,120,32,126,61,32,48,32,116,104,101,110,10,32,32,32,32,32, -32,103,111,97,108,88,32,61,32,116,99,104,46,120,10,32,32,32,32,101, -108,115,101,10,32,32,32,32,32,32,103,111,97,108,89,32,61,32,116,99, -104,46,121,10,32,32,32,32,101,110,100,10,32,32,101,110,100,10,10,32, -32,99,111,108,46,115,108,105,100,101,32,61,32,123,120,32,61,32,103,111, -97,108,88,44,32,121,32,61,32,103,111,97,108,89,125,10,10,32,32,120, -44,121,32,61,32,116,99,104,46,120,44,32,116,99,104,46,121,10,32,32, -108,111,99,97,108,32,99,111,108,115,44,32,108,101,110,32,32,61,32,119, -111,114,108,100,58,112,114,111,106,101,99,116,40,99,111,108,46,105,116,101, -109,44,32,120,44,121,44,119,44,104,44,32,103,111,97,108,88,44,32,103, -111,97,108,89,44,32,102,105,108,116,101,114,41,10,32,32,114,101,116,117, -114,110,32,103,111,97,108,88,44,32,103,111,97,108,89,44,32,99,111,108, -115,44,32,108,101,110,10,101,110,100,10,10,108,111,99,97,108,32,98,111, -117,110,99,101,32,61,32,102,117,110,99,116,105,111,110,40,119,111,114,108, +45,45,45,45,45,45,45,45,45,13,10,13,10,108,111,99,97,108,32,116, +111,117,99,104,32,61,32,102,117,110,99,116,105,111,110,40,119,111,114,108, +100,44,32,99,111,108,44,32,120,44,121,44,119,44,104,44,32,103,111,97, +108,88,44,32,103,111,97,108,89,44,32,102,105,108,116,101,114,41,13,10, +32,32,114,101,116,117,114,110,32,99,111,108,46,116,111,117,99,104,46,120, +44,32,99,111,108,46,116,111,117,99,104,46,121,44,32,123,125,44,32,48, +13,10,101,110,100,13,10,13,10,108,111,99,97,108,32,99,114,111,115,115, +32,61,32,102,117,110,99,116,105,111,110,40,119,111,114,108,100,44,32,99, +111,108,44,32,120,44,121,44,119,44,104,44,32,103,111,97,108,88,44,32, +103,111,97,108,89,44,32,102,105,108,116,101,114,41,13,10,32,32,108,111, +99,97,108,32,99,111,108,115,44,32,108,101,110,32,61,32,119,111,114,108, +100,58,112,114,111,106,101,99,116,40,99,111,108,46,105,116,101,109,44,32, +120,44,121,44,119,44,104,44,32,103,111,97,108,88,44,32,103,111,97,108, +89,44,32,102,105,108,116,101,114,41,13,10,32,32,114,101,116,117,114,110, +32,103,111,97,108,88,44,32,103,111,97,108,89,44,32,99,111,108,115,44, +32,108,101,110,13,10,101,110,100,13,10,13,10,108,111,99,97,108,32,115, +108,105,100,101,32,61,32,102,117,110,99,116,105,111,110,40,119,111,114,108, 100,44,32,99,111,108,44,32,120,44,121,44,119,44,104,44,32,103,111,97, -108,88,44,32,103,111,97,108,89,44,32,102,105,108,116,101,114,41,10,32, -32,103,111,97,108,88,32,61,32,103,111,97,108,88,32,111,114,32,120,10, -32,32,103,111,97,108,89,32,61,32,103,111,97,108,89,32,111,114,32,121, -10,10,32,32,108,111,99,97,108,32,116,99,104,44,32,109,111,118,101,32, -61,32,99,111,108,46,116,111,117,99,104,44,32,99,111,108,46,109,111,118, -101,10,32,32,108,111,99,97,108,32,116,120,44,32,116,121,32,61,32,116, -99,104,46,120,44,32,116,99,104,46,121,10,10,32,32,108,111,99,97,108, -32,98,120,44,32,98,121,32,61,32,116,120,44,32,116,121,10,10,32,32, -105,102,32,109,111,118,101,46,120,32,126,61,32,48,32,111,114,32,109,111, -118,101,46,121,32,126,61,32,48,32,116,104,101,110,10,32,32,32,32,108, -111,99,97,108,32,98,110,120,44,32,98,110,121,32,61,32,103,111,97,108, -88,32,45,32,116,120,44,32,103,111,97,108,89,32,45,32,116,121,10,32, -32,32,32,105,102,32,99,111,108,46,110,111,114,109,97,108,46,120,32,61, -61,32,48,32,116,104,101,110,32,98,110,121,32,61,32,45,98,110,121,32, -101,108,115,101,32,98,110,120,32,61,32,45,98,110,120,32,101,110,100,10, -32,32,32,32,98,120,44,32,98,121,32,61,32,116,120,32,43,32,98,110, -120,44,32,116,121,32,43,32,98,110,121,10,32,32,101,110,100,10,10,32, -32,99,111,108,46,98,111,117,110,99,101,32,32,32,61,32,123,120,32,61, -32,98,120,44,32,32,121,32,61,32,98,121,125,10,32,32,120,44,121,32, -32,32,32,32,32,32,32,32,32,61,32,116,99,104,46,120,44,32,116,99, -104,46,121,10,32,32,103,111,97,108,88,44,32,103,111,97,108,89,32,61, -32,98,120,44,32,98,121,10,10,32,32,108,111,99,97,108,32,99,111,108, -115,44,32,108,101,110,32,32,32,32,61,32,119,111,114,108,100,58,112,114, -111,106,101,99,116,40,99,111,108,46,105,116,101,109,44,32,120,44,121,44, -119,44,104,44,32,103,111,97,108,88,44,32,103,111,97,108,89,44,32,102, -105,108,116,101,114,41,10,32,32,114,101,116,117,114,110,32,103,111,97,108, -88,44,32,103,111,97,108,89,44,32,99,111,108,115,44,32,108,101,110,10, -101,110,100,10,10,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, +108,88,44,32,103,111,97,108,89,44,32,102,105,108,116,101,114,41,13,10, +32,32,103,111,97,108,88,32,61,32,103,111,97,108,88,32,111,114,32,120, +13,10,32,32,103,111,97,108,89,32,61,32,103,111,97,108,89,32,111,114, +32,121,13,10,13,10,32,32,108,111,99,97,108,32,116,99,104,44,32,109, +111,118,101,32,32,61,32,99,111,108,46,116,111,117,99,104,44,32,99,111, +108,46,109,111,118,101,13,10,32,32,105,102,32,109,111,118,101,46,120,32, +126,61,32,48,32,111,114,32,109,111,118,101,46,121,32,126,61,32,48,32, +116,104,101,110,13,10,32,32,32,32,105,102,32,99,111,108,46,110,111,114, +109,97,108,46,120,32,126,61,32,48,32,116,104,101,110,13,10,32,32,32, +32,32,32,103,111,97,108,88,32,61,32,116,99,104,46,120,13,10,32,32, +32,32,101,108,115,101,13,10,32,32,32,32,32,32,103,111,97,108,89,32, +61,32,116,99,104,46,121,13,10,32,32,32,32,101,110,100,13,10,32,32, +101,110,100,13,10,13,10,32,32,99,111,108,46,115,108,105,100,101,32,61, +32,123,120,32,61,32,103,111,97,108,88,44,32,121,32,61,32,103,111,97, +108,89,125,13,10,13,10,32,32,120,44,121,32,61,32,116,99,104,46,120, +44,32,116,99,104,46,121,13,10,32,32,108,111,99,97,108,32,99,111,108, +115,44,32,108,101,110,32,32,61,32,119,111,114,108,100,58,112,114,111,106, +101,99,116,40,99,111,108,46,105,116,101,109,44,32,120,44,121,44,119,44, +104,44,32,103,111,97,108,88,44,32,103,111,97,108,89,44,32,102,105,108, +116,101,114,41,13,10,32,32,114,101,116,117,114,110,32,103,111,97,108,88, +44,32,103,111,97,108,89,44,32,99,111,108,115,44,32,108,101,110,13,10, +101,110,100,13,10,13,10,108,111,99,97,108,32,98,111,117,110,99,101,32, +61,32,102,117,110,99,116,105,111,110,40,119,111,114,108,100,44,32,99,111, +108,44,32,120,44,121,44,119,44,104,44,32,103,111,97,108,88,44,32,103, +111,97,108,89,44,32,102,105,108,116,101,114,41,13,10,32,32,103,111,97, +108,88,32,61,32,103,111,97,108,88,32,111,114,32,120,13,10,32,32,103, +111,97,108,89,32,61,32,103,111,97,108,89,32,111,114,32,121,13,10,13, +10,32,32,108,111,99,97,108,32,116,99,104,44,32,109,111,118,101,32,61, +32,99,111,108,46,116,111,117,99,104,44,32,99,111,108,46,109,111,118,101, +13,10,32,32,108,111,99,97,108,32,116,120,44,32,116,121,32,61,32,116, +99,104,46,120,44,32,116,99,104,46,121,13,10,13,10,32,32,108,111,99, +97,108,32,98,120,44,32,98,121,32,61,32,116,120,44,32,116,121,13,10, +13,10,32,32,105,102,32,109,111,118,101,46,120,32,126,61,32,48,32,111, +114,32,109,111,118,101,46,121,32,126,61,32,48,32,116,104,101,110,13,10, +32,32,32,32,108,111,99,97,108,32,98,110,120,44,32,98,110,121,32,61, +32,103,111,97,108,88,32,45,32,116,120,44,32,103,111,97,108,89,32,45, +32,116,121,13,10,32,32,32,32,105,102,32,99,111,108,46,110,111,114,109, +97,108,46,120,32,61,61,32,48,32,116,104,101,110,32,98,110,121,32,61, +32,45,98,110,121,32,101,108,115,101,32,98,110,120,32,61,32,45,98,110, +120,32,101,110,100,13,10,32,32,32,32,98,120,44,32,98,121,32,61,32, +116,120,32,43,32,98,110,120,44,32,116,121,32,43,32,98,110,121,13,10, +32,32,101,110,100,13,10,13,10,32,32,99,111,108,46,98,111,117,110,99, +101,32,32,32,61,32,123,120,32,61,32,98,120,44,32,32,121,32,61,32, +98,121,125,13,10,32,32,120,44,121,32,32,32,32,32,32,32,32,32,32, +61,32,116,99,104,46,120,44,32,116,99,104,46,121,13,10,32,32,103,111, +97,108,88,44,32,103,111,97,108,89,32,61,32,98,120,44,32,98,121,13, +10,13,10,32,32,108,111,99,97,108,32,99,111,108,115,44,32,108,101,110, +32,32,32,32,61,32,119,111,114,108,100,58,112,114,111,106,101,99,116,40, +99,111,108,46,105,116,101,109,44,32,120,44,121,44,119,44,104,44,32,103, +111,97,108,88,44,32,103,111,97,108,89,44,32,102,105,108,116,101,114,41, +13,10,32,32,114,101,116,117,114,110,32,103,111,97,108,88,44,32,103,111, +97,108,89,44,32,99,111,108,115,44,32,108,101,110,13,10,101,110,100,13, +10,13,10,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,45,45,45,45,45,45,10,45,45,32,87,111,114,108,100,10,45,45,45, +45,45,45,45,45,13,10,45,45,32,87,111,114,108,100,13,10,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,10, -10,108,111,99,97,108,32,87,111,114,108,100,32,61,32,123,125,10,108,111, -99,97,108,32,87,111,114,108,100,95,109,116,32,61,32,123,95,95,105,110, -100,101,120,32,61,32,87,111,114,108,100,125,10,10,45,45,32,80,114,105, -118,97,116,101,32,102,117,110,99,116,105,111,110,115,32,97,110,100,32,109, -101,116,104,111,100,115,10,10,108,111,99,97,108,32,102,117,110,99,116,105, -111,110,32,115,111,114,116,66,121,87,101,105,103,104,116,40,97,44,98,41, -32,114,101,116,117,114,110,32,97,46,119,101,105,103,104,116,32,60,32,98, -46,119,101,105,103,104,116,32,101,110,100,10,10,108,111,99,97,108,32,102, -117,110,99,116,105,111,110,32,115,111,114,116,66,121,84,105,65,110,100,68, -105,115,116,97,110,99,101,40,97,44,98,41,10,32,32,105,102,32,97,46, -116,105,32,61,61,32,98,46,116,105,32,116,104,101,110,10,32,32,32,32, -108,111,99,97,108,32,105,114,44,32,97,114,44,32,98,114,32,61,32,97, -46,105,116,101,109,82,101,99,116,44,32,97,46,111,116,104,101,114,82,101, -99,116,44,32,98,46,111,116,104,101,114,82,101,99,116,10,32,32,32,32, -108,111,99,97,108,32,97,100,32,61,32,114,101,99,116,95,103,101,116,83, -113,117,97,114,101,68,105,115,116,97,110,99,101,40,105,114,46,120,44,105, -114,46,121,44,105,114,46,119,44,105,114,46,104,44,32,97,114,46,120,44, -97,114,46,121,44,97,114,46,119,44,97,114,46,104,41,10,32,32,32,32, -108,111,99,97,108,32,98,100,32,61,32,114,101,99,116,95,103,101,116,83, -113,117,97,114,101,68,105,115,116,97,110,99,101,40,105,114,46,120,44,105, -114,46,121,44,105,114,46,119,44,105,114,46,104,44,32,98,114,46,120,44, -98,114,46,121,44,98,114,46,119,44,98,114,46,104,41,10,32,32,32,32, -114,101,116,117,114,110,32,97,100,32,60,32,98,100,10,32,32,101,110,100, -10,32,32,114,101,116,117,114,110,32,97,46,116,105,32,60,32,98,46,116, -105,10,101,110,100,10,10,108,111,99,97,108,32,102,117,110,99,116,105,111, -110,32,97,100,100,73,116,101,109,84,111,67,101,108,108,40,115,101,108,102, -44,32,105,116,101,109,44,32,99,120,44,32,99,121,41,10,32,32,115,101, +45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,13, +10,13,10,108,111,99,97,108,32,87,111,114,108,100,32,61,32,123,125,13, +10,108,111,99,97,108,32,87,111,114,108,100,95,109,116,32,61,32,123,95, +95,105,110,100,101,120,32,61,32,87,111,114,108,100,125,13,10,13,10,45, +45,32,80,114,105,118,97,116,101,32,102,117,110,99,116,105,111,110,115,32, +97,110,100,32,109,101,116,104,111,100,115,13,10,13,10,108,111,99,97,108, +32,102,117,110,99,116,105,111,110,32,115,111,114,116,66,121,87,101,105,103, +104,116,40,97,44,98,41,32,114,101,116,117,114,110,32,97,46,119,101,105, +103,104,116,32,60,32,98,46,119,101,105,103,104,116,32,101,110,100,13,10, +13,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110,32,115,111,114, +116,66,121,84,105,65,110,100,68,105,115,116,97,110,99,101,40,97,44,98, +41,13,10,32,32,105,102,32,97,46,116,105,32,61,61,32,98,46,116,105, +32,116,104,101,110,13,10,32,32,32,32,108,111,99,97,108,32,105,114,44, +32,97,114,44,32,98,114,32,61,32,97,46,105,116,101,109,82,101,99,116, +44,32,97,46,111,116,104,101,114,82,101,99,116,44,32,98,46,111,116,104, +101,114,82,101,99,116,13,10,32,32,32,32,108,111,99,97,108,32,97,100, +32,61,32,114,101,99,116,95,103,101,116,83,113,117,97,114,101,68,105,115, +116,97,110,99,101,40,105,114,46,120,44,105,114,46,121,44,105,114,46,119, +44,105,114,46,104,44,32,97,114,46,120,44,97,114,46,121,44,97,114,46, +119,44,97,114,46,104,41,13,10,32,32,32,32,108,111,99,97,108,32,98, +100,32,61,32,114,101,99,116,95,103,101,116,83,113,117,97,114,101,68,105, +115,116,97,110,99,101,40,105,114,46,120,44,105,114,46,121,44,105,114,46, +119,44,105,114,46,104,44,32,98,114,46,120,44,98,114,46,121,44,98,114, +46,119,44,98,114,46,104,41,13,10,32,32,32,32,114,101,116,117,114,110, +32,97,100,32,60,32,98,100,13,10,32,32,101,110,100,13,10,32,32,114, +101,116,117,114,110,32,97,46,116,105,32,60,32,98,46,116,105,13,10,101, +110,100,13,10,13,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110, +32,97,100,100,73,116,101,109,84,111,67,101,108,108,40,115,101,108,102,44, +32,105,116,101,109,44,32,99,120,44,32,99,121,41,13,10,32,32,115,101, 108,102,46,114,111,119,115,91,99,121,93,32,61,32,115,101,108,102,46,114, 111,119,115,91,99,121,93,32,111,114,32,115,101,116,109,101,116,97,116,97, 98,108,101,40,123,125,44,32,123,95,95,109,111,100,101,32,61,32,39,118, -39,125,41,10,32,32,108,111,99,97,108,32,114,111,119,32,61,32,115,101, -108,102,46,114,111,119,115,91,99,121,93,10,32,32,114,111,119,91,99,120, -93,32,61,32,114,111,119,91,99,120,93,32,111,114,32,123,105,116,101,109, -67,111,117,110,116,32,61,32,48,44,32,120,32,61,32,99,120,44,32,121, -32,61,32,99,121,44,32,105,116,101,109,115,32,61,32,115,101,116,109,101, -116,97,116,97,98,108,101,40,123,125,44,32,123,95,95,109,111,100,101,32, -61,32,39,107,39,125,41,125,10,32,32,108,111,99,97,108,32,99,101,108, -108,32,61,32,114,111,119,91,99,120,93,10,32,32,115,101,108,102,46,110, -111,110,69,109,112,116,121,67,101,108,108,115,91,99,101,108,108,93,32,61, -32,116,114,117,101,10,32,32,105,102,32,110,111,116,32,99,101,108,108,46, -105,116,101,109,115,91,105,116,101,109,93,32,116,104,101,110,10,32,32,32, -32,99,101,108,108,46,105,116,101,109,115,91,105,116,101,109,93,32,61,32, -116,114,117,101,10,32,32,32,32,99,101,108,108,46,105,116,101,109,67,111, -117,110,116,32,61,32,99,101,108,108,46,105,116,101,109,67,111,117,110,116, -32,43,32,49,10,32,32,101,110,100,10,101,110,100,10,10,108,111,99,97, -108,32,102,117,110,99,116,105,111,110,32,114,101,109,111,118,101,73,116,101, -109,70,114,111,109,67,101,108,108,40,115,101,108,102,44,32,105,116,101,109, -44,32,99,120,44,32,99,121,41,10,32,32,108,111,99,97,108,32,114,111, -119,32,61,32,115,101,108,102,46,114,111,119,115,91,99,121,93,10,32,32, -105,102,32,110,111,116,32,114,111,119,32,111,114,32,110,111,116,32,114,111, -119,91,99,120,93,32,111,114,32,110,111,116,32,114,111,119,91,99,120,93, -46,105,116,101,109,115,91,105,116,101,109,93,32,116,104,101,110,32,114,101, -116,117,114,110,32,102,97,108,115,101,32,101,110,100,10,10,32,32,108,111, -99,97,108,32,99,101,108,108,32,61,32,114,111,119,91,99,120,93,10,32, -32,99,101,108,108,46,105,116,101,109,115,91,105,116,101,109,93,32,61,32, -110,105,108,10,32,32,99,101,108,108,46,105,116,101,109,67,111,117,110,116, -32,61,32,99,101,108,108,46,105,116,101,109,67,111,117,110,116,32,45,32, -49,10,32,32,105,102,32,99,101,108,108,46,105,116,101,109,67,111,117,110, -116,32,61,61,32,48,32,116,104,101,110,10,32,32,32,32,115,101,108,102, -46,110,111,110,69,109,112,116,121,67,101,108,108,115,91,99,101,108,108,93, -32,61,32,110,105,108,10,32,32,101,110,100,10,32,32,114,101,116,117,114, -110,32,116,114,117,101,10,101,110,100,10,10,108,111,99,97,108,32,102,117, -110,99,116,105,111,110,32,103,101,116,68,105,99,116,73,116,101,109,115,73, -110,67,101,108,108,82,101,99,116,40,115,101,108,102,44,32,99,108,44,99, -116,44,99,119,44,99,104,41,10,32,32,108,111,99,97,108,32,105,116,101, -109,115,95,100,105,99,116,32,61,32,123,125,10,32,32,102,111,114,32,99, -121,61,99,116,44,99,116,43,99,104,45,49,32,100,111,10,32,32,32,32, -108,111,99,97,108,32,114,111,119,32,61,32,115,101,108,102,46,114,111,119, -115,91,99,121,93,10,32,32,32,32,105,102,32,114,111,119,32,116,104,101, -110,10,32,32,32,32,32,32,102,111,114,32,99,120,61,99,108,44,99,108, -43,99,119,45,49,32,100,111,10,32,32,32,32,32,32,32,32,108,111,99, -97,108,32,99,101,108,108,32,61,32,114,111,119,91,99,120,93,10,32,32, -32,32,32,32,32,32,105,102,32,99,101,108,108,32,97,110,100,32,99,101, -108,108,46,105,116,101,109,67,111,117,110,116,32,62,32,48,32,116,104,101, -110,32,45,45,32,110,111,32,99,101,108,108,46,105,116,101,109,67,111,117, -110,116,32,62,32,49,32,98,101,99,97,117,115,101,32,116,117,110,110,101, -108,105,110,103,10,32,32,32,32,32,32,32,32,32,32,102,111,114,32,105, -116,101,109,44,95,32,105,110,32,112,97,105,114,115,40,99,101,108,108,46, -105,116,101,109,115,41,32,100,111,10,32,32,32,32,32,32,32,32,32,32, -32,32,105,116,101,109,115,95,100,105,99,116,91,105,116,101,109,93,32,61, -32,116,114,117,101,10,32,32,32,32,32,32,32,32,32,32,101,110,100,10, -32,32,32,32,32,32,32,32,101,110,100,10,32,32,32,32,32,32,101,110, -100,10,32,32,32,32,101,110,100,10,32,32,101,110,100,10,10,32,32,114, -101,116,117,114,110,32,105,116,101,109,115,95,100,105,99,116,10,101,110,100, -10,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110,32,103,101,116, -67,101,108,108,115,84,111,117,99,104,101,100,66,121,83,101,103,109,101,110, -116,40,115,101,108,102,44,32,120,49,44,121,49,44,120,50,44,121,50,41, -10,10,32,32,108,111,99,97,108,32,99,101,108,108,115,44,32,99,101,108, -108,115,76,101,110,44,32,118,105,115,105,116,101,100,32,61,32,123,125,44, -32,48,44,32,123,125,10,10,32,32,103,114,105,100,95,116,114,97,118,101, -114,115,101,40,115,101,108,102,46,99,101,108,108,83,105,122,101,44,32,120, -49,44,121,49,44,120,50,44,121,50,44,32,102,117,110,99,116,105,111,110, -40,99,120,44,32,99,121,41,10,32,32,32,32,108,111,99,97,108,32,114, -111,119,32,32,61,32,115,101,108,102,46,114,111,119,115,91,99,121,93,10, -32,32,32,32,105,102,32,110,111,116,32,114,111,119,32,116,104,101,110,32, -114,101,116,117,114,110,32,101,110,100,10,32,32,32,32,108,111,99,97,108, -32,99,101,108,108,32,61,32,114,111,119,91,99,120,93,10,32,32,32,32, -105,102,32,110,111,116,32,99,101,108,108,32,111,114,32,118,105,115,105,116, -101,100,91,99,101,108,108,93,32,116,104,101,110,32,114,101,116,117,114,110, -32,101,110,100,10,10,32,32,32,32,118,105,115,105,116,101,100,91,99,101, -108,108,93,32,61,32,116,114,117,101,10,32,32,32,32,99,101,108,108,115, -76,101,110,32,61,32,99,101,108,108,115,76,101,110,32,43,32,49,10,32, -32,32,32,99,101,108,108,115,91,99,101,108,108,115,76,101,110,93,32,61, -32,99,101,108,108,10,32,32,101,110,100,41,10,10,32,32,114,101,116,117, -114,110,32,99,101,108,108,115,44,32,99,101,108,108,115,76,101,110,10,101, -110,100,10,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110,32,103, -101,116,73,110,102,111,65,98,111,117,116,73,116,101,109,115,84,111,117,99, -104,101,100,66,121,83,101,103,109,101,110,116,40,115,101,108,102,44,32,120, -49,44,121,49,44,32,120,50,44,121,50,44,32,102,105,108,116,101,114,41, -10,32,32,108,111,99,97,108,32,99,101,108,108,115,44,32,108,101,110,32, -61,32,103,101,116,67,101,108,108,115,84,111,117,99,104,101,100,66,121,83, -101,103,109,101,110,116,40,115,101,108,102,44,32,120,49,44,121,49,44,120, -50,44,121,50,41,10,32,32,108,111,99,97,108,32,99,101,108,108,44,32, -114,101,99,116,44,32,108,44,116,44,119,44,104,44,32,116,105,49,44,116, -105,50,44,32,116,105,105,48,44,116,105,105,49,10,32,32,108,111,99,97, -108,32,118,105,115,105,116,101,100,44,32,105,116,101,109,73,110,102,111,44, -32,105,116,101,109,73,110,102,111,76,101,110,32,61,32,123,125,44,123,125, -44,48,10,32,32,102,111,114,32,105,61,49,44,108,101,110,32,100,111,10, -32,32,32,32,99,101,108,108,32,61,32,99,101,108,108,115,91,105,93,10, -32,32,32,32,102,111,114,32,105,116,101,109,32,105,110,32,112,97,105,114, -115,40,99,101,108,108,46,105,116,101,109,115,41,32,100,111,10,32,32,32, -32,32,32,105,102,32,110,111,116,32,118,105,115,105,116,101,100,91,105,116, -101,109,93,32,116,104,101,110,10,32,32,32,32,32,32,32,32,118,105,115, -105,116,101,100,91,105,116,101,109,93,32,32,61,32,116,114,117,101,10,32, -32,32,32,32,32,32,32,105,102,32,40,110,111,116,32,102,105,108,116,101, -114,32,111,114,32,102,105,108,116,101,114,40,105,116,101,109,41,41,32,116, -104,101,110,10,32,32,32,32,32,32,32,32,32,32,114,101,99,116,32,32, -32,32,32,32,32,32,32,32,32,61,32,115,101,108,102,46,114,101,99,116, -115,91,105,116,101,109,93,10,32,32,32,32,32,32,32,32,32,32,108,44, -116,44,119,44,104,32,32,32,32,32,32,32,32,61,32,114,101,99,116,46, -120,44,114,101,99,116,46,121,44,114,101,99,116,46,119,44,114,101,99,116, -46,104,10,10,32,32,32,32,32,32,32,32,32,32,116,105,49,44,116,105, -50,32,61,32,114,101,99,116,95,103,101,116,83,101,103,109,101,110,116,73, -110,116,101,114,115,101,99,116,105,111,110,73,110,100,105,99,101,115,40,108, -44,116,44,119,44,104,44,32,120,49,44,121,49,44,32,120,50,44,121,50, -44,32,48,44,32,49,41,10,32,32,32,32,32,32,32,32,32,32,105,102, -32,116,105,49,32,97,110,100,32,40,40,48,32,60,32,116,105,49,32,97, -110,100,32,116,105,49,32,60,32,49,41,32,111,114,32,40,48,32,60,32, -116,105,50,32,97,110,100,32,116,105,50,32,60,32,49,41,41,32,116,104, -101,110,10,32,32,32,32,32,32,32,32,32,32,32,32,45,45,32,116,104, -101,32,115,111,114,116,105,110,103,32,105,115,32,97,99,99,111,114,100,105, -110,103,32,116,111,32,116,104,101,32,116,32,111,102,32,97,110,32,105,110, -102,105,110,105,116,101,32,108,105,110,101,44,32,110,111,116,32,116,104,101, -32,115,101,103,109,101,110,116,10,32,32,32,32,32,32,32,32,32,32,32, -32,116,105,105,48,44,116,105,105,49,32,32,32,32,61,32,114,101,99,116, -95,103,101,116,83,101,103,109,101,110,116,73,110,116,101,114,115,101,99,116, -105,111,110,73,110,100,105,99,101,115,40,108,44,116,44,119,44,104,44,32, -120,49,44,121,49,44,32,120,50,44,121,50,44,32,45,109,97,116,104,46, -104,117,103,101,44,32,109,97,116,104,46,104,117,103,101,41,10,32,32,32, -32,32,32,32,32,32,32,32,32,105,116,101,109,73,110,102,111,76,101,110, -32,32,61,32,105,116,101,109,73,110,102,111,76,101,110,32,43,32,49,10, -32,32,32,32,32,32,32,32,32,32,32,32,105,116,101,109,73,110,102,111, -91,105,116,101,109,73,110,102,111,76,101,110,93,32,61,32,123,105,116,101, -109,32,61,32,105,116,101,109,44,32,116,105,49,32,61,32,116,105,49,44, -32,116,105,50,32,61,32,116,105,50,44,32,119,101,105,103,104,116,32,61, -32,109,105,110,40,116,105,105,48,44,116,105,105,49,41,125,10,32,32,32, -32,32,32,32,32,32,32,101,110,100,10,32,32,32,32,32,32,32,32,101, -110,100,10,32,32,32,32,32,32,101,110,100,10,32,32,32,32,101,110,100, -10,32,32,101,110,100,10,32,32,116,97,98,108,101,46,115,111,114,116,40, -105,116,101,109,73,110,102,111,44,32,115,111,114,116,66,121,87,101,105,103, -104,116,41,10,32,32,114,101,116,117,114,110,32,105,116,101,109,73,110,102, -111,44,32,105,116,101,109,73,110,102,111,76,101,110,10,101,110,100,10,10, -108,111,99,97,108,32,102,117,110,99,116,105,111,110,32,103,101,116,82,101, -115,112,111,110,115,101,66,121,78,97,109,101,40,115,101,108,102,44,32,110, -97,109,101,41,10,32,32,108,111,99,97,108,32,114,101,115,112,111,110,115, -101,32,61,32,115,101,108,102,46,114,101,115,112,111,110,115,101,115,91,110, -97,109,101,93,10,32,32,105,102,32,110,111,116,32,114,101,115,112,111,110, -115,101,32,116,104,101,110,10,32,32,32,32,101,114,114,111,114,40,40,39, -85,110,107,110,111,119,110,32,99,111,108,108,105,115,105,111,110,32,116,121, -112,101,58,32,37,115,32,40,37,115,41,39,41,58,102,111,114,109,97,116, -40,110,97,109,101,44,32,116,121,112,101,40,110,97,109,101,41,41,41,10, -32,32,101,110,100,10,32,32,114,101,116,117,114,110,32,114,101,115,112,111, -110,115,101,10,101,110,100,10,10,10,45,45,32,77,105,115,99,32,80,117, -98,108,105,99,32,77,101,116,104,111,100,115,10,10,102,117,110,99,116,105, +39,125,41,13,10,32,32,108,111,99,97,108,32,114,111,119,32,61,32,115, +101,108,102,46,114,111,119,115,91,99,121,93,13,10,32,32,114,111,119,91, +99,120,93,32,61,32,114,111,119,91,99,120,93,32,111,114,32,123,105,116, +101,109,67,111,117,110,116,32,61,32,48,44,32,120,32,61,32,99,120,44, +32,121,32,61,32,99,121,44,32,105,116,101,109,115,32,61,32,115,101,116, +109,101,116,97,116,97,98,108,101,40,123,125,44,32,123,95,95,109,111,100, +101,32,61,32,39,107,39,125,41,125,13,10,32,32,108,111,99,97,108,32, +99,101,108,108,32,61,32,114,111,119,91,99,120,93,13,10,32,32,115,101, +108,102,46,110,111,110,69,109,112,116,121,67,101,108,108,115,91,99,101,108, +108,93,32,61,32,116,114,117,101,13,10,32,32,105,102,32,110,111,116,32, +99,101,108,108,46,105,116,101,109,115,91,105,116,101,109,93,32,116,104,101, +110,13,10,32,32,32,32,99,101,108,108,46,105,116,101,109,115,91,105,116, +101,109,93,32,61,32,116,114,117,101,13,10,32,32,32,32,99,101,108,108, +46,105,116,101,109,67,111,117,110,116,32,61,32,99,101,108,108,46,105,116, +101,109,67,111,117,110,116,32,43,32,49,13,10,32,32,101,110,100,13,10, +101,110,100,13,10,13,10,108,111,99,97,108,32,102,117,110,99,116,105,111, +110,32,114,101,109,111,118,101,73,116,101,109,70,114,111,109,67,101,108,108, +40,115,101,108,102,44,32,105,116,101,109,44,32,99,120,44,32,99,121,41, +13,10,32,32,108,111,99,97,108,32,114,111,119,32,61,32,115,101,108,102, +46,114,111,119,115,91,99,121,93,13,10,32,32,105,102,32,110,111,116,32, +114,111,119,32,111,114,32,110,111,116,32,114,111,119,91,99,120,93,32,111, +114,32,110,111,116,32,114,111,119,91,99,120,93,46,105,116,101,109,115,91, +105,116,101,109,93,32,116,104,101,110,32,114,101,116,117,114,110,32,102,97, +108,115,101,32,101,110,100,13,10,13,10,32,32,108,111,99,97,108,32,99, +101,108,108,32,61,32,114,111,119,91,99,120,93,13,10,32,32,99,101,108, +108,46,105,116,101,109,115,91,105,116,101,109,93,32,61,32,110,105,108,13, +10,32,32,99,101,108,108,46,105,116,101,109,67,111,117,110,116,32,61,32, +99,101,108,108,46,105,116,101,109,67,111,117,110,116,32,45,32,49,13,10, +32,32,105,102,32,99,101,108,108,46,105,116,101,109,67,111,117,110,116,32, +61,61,32,48,32,116,104,101,110,13,10,32,32,32,32,115,101,108,102,46, +110,111,110,69,109,112,116,121,67,101,108,108,115,91,99,101,108,108,93,32, +61,32,110,105,108,13,10,32,32,101,110,100,13,10,32,32,114,101,116,117, +114,110,32,116,114,117,101,13,10,101,110,100,13,10,13,10,108,111,99,97, +108,32,102,117,110,99,116,105,111,110,32,103,101,116,68,105,99,116,73,116, +101,109,115,73,110,67,101,108,108,82,101,99,116,40,115,101,108,102,44,32, +99,108,44,99,116,44,99,119,44,99,104,41,13,10,32,32,108,111,99,97, +108,32,105,116,101,109,115,95,100,105,99,116,32,61,32,123,125,13,10,32, +32,102,111,114,32,99,121,61,99,116,44,99,116,43,99,104,45,49,32,100, +111,13,10,32,32,32,32,108,111,99,97,108,32,114,111,119,32,61,32,115, +101,108,102,46,114,111,119,115,91,99,121,93,13,10,32,32,32,32,105,102, +32,114,111,119,32,116,104,101,110,13,10,32,32,32,32,32,32,102,111,114, +32,99,120,61,99,108,44,99,108,43,99,119,45,49,32,100,111,13,10,32, +32,32,32,32,32,32,32,108,111,99,97,108,32,99,101,108,108,32,61,32, +114,111,119,91,99,120,93,13,10,32,32,32,32,32,32,32,32,105,102,32, +99,101,108,108,32,97,110,100,32,99,101,108,108,46,105,116,101,109,67,111, +117,110,116,32,62,32,48,32,116,104,101,110,32,45,45,32,110,111,32,99, +101,108,108,46,105,116,101,109,67,111,117,110,116,32,62,32,49,32,98,101, +99,97,117,115,101,32,116,117,110,110,101,108,105,110,103,13,10,32,32,32, +32,32,32,32,32,32,32,102,111,114,32,105,116,101,109,44,95,32,105,110, +32,112,97,105,114,115,40,99,101,108,108,46,105,116,101,109,115,41,32,100, +111,13,10,32,32,32,32,32,32,32,32,32,32,32,32,105,116,101,109,115, +95,100,105,99,116,91,105,116,101,109,93,32,61,32,116,114,117,101,13,10, +32,32,32,32,32,32,32,32,32,32,101,110,100,13,10,32,32,32,32,32, +32,32,32,101,110,100,13,10,32,32,32,32,32,32,101,110,100,13,10,32, +32,32,32,101,110,100,13,10,32,32,101,110,100,13,10,13,10,32,32,114, +101,116,117,114,110,32,105,116,101,109,115,95,100,105,99,116,13,10,101,110, +100,13,10,13,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110,32, +103,101,116,67,101,108,108,115,84,111,117,99,104,101,100,66,121,83,101,103, +109,101,110,116,40,115,101,108,102,44,32,120,49,44,121,49,44,120,50,44, +121,50,41,13,10,13,10,32,32,108,111,99,97,108,32,99,101,108,108,115, +44,32,99,101,108,108,115,76,101,110,44,32,118,105,115,105,116,101,100,32, +61,32,123,125,44,32,48,44,32,123,125,13,10,13,10,32,32,103,114,105, +100,95,116,114,97,118,101,114,115,101,40,115,101,108,102,46,99,101,108,108, +83,105,122,101,44,32,120,49,44,121,49,44,120,50,44,121,50,44,32,102, +117,110,99,116,105,111,110,40,99,120,44,32,99,121,41,13,10,32,32,32, +32,108,111,99,97,108,32,114,111,119,32,32,61,32,115,101,108,102,46,114, +111,119,115,91,99,121,93,13,10,32,32,32,32,105,102,32,110,111,116,32, +114,111,119,32,116,104,101,110,32,114,101,116,117,114,110,32,101,110,100,13, +10,32,32,32,32,108,111,99,97,108,32,99,101,108,108,32,61,32,114,111, +119,91,99,120,93,13,10,32,32,32,32,105,102,32,110,111,116,32,99,101, +108,108,32,111,114,32,118,105,115,105,116,101,100,91,99,101,108,108,93,32, +116,104,101,110,32,114,101,116,117,114,110,32,101,110,100,13,10,13,10,32, +32,32,32,118,105,115,105,116,101,100,91,99,101,108,108,93,32,61,32,116, +114,117,101,13,10,32,32,32,32,99,101,108,108,115,76,101,110,32,61,32, +99,101,108,108,115,76,101,110,32,43,32,49,13,10,32,32,32,32,99,101, +108,108,115,91,99,101,108,108,115,76,101,110,93,32,61,32,99,101,108,108, +13,10,32,32,101,110,100,41,13,10,13,10,32,32,114,101,116,117,114,110, +32,99,101,108,108,115,44,32,99,101,108,108,115,76,101,110,13,10,101,110, +100,13,10,13,10,108,111,99,97,108,32,102,117,110,99,116,105,111,110,32, +103,101,116,73,110,102,111,65,98,111,117,116,73,116,101,109,115,84,111,117, +99,104,101,100,66,121,83,101,103,109,101,110,116,40,115,101,108,102,44,32, +120,49,44,121,49,44,32,120,50,44,121,50,44,32,102,105,108,116,101,114, +41,13,10,32,32,108,111,99,97,108,32,99,101,108,108,115,44,32,108,101, +110,32,61,32,103,101,116,67,101,108,108,115,84,111,117,99,104,101,100,66, +121,83,101,103,109,101,110,116,40,115,101,108,102,44,32,120,49,44,121,49, +44,120,50,44,121,50,41,13,10,32,32,108,111,99,97,108,32,99,101,108, +108,44,32,114,101,99,116,44,32,108,44,116,44,119,44,104,44,32,116,105, +49,44,116,105,50,44,32,116,105,105,48,44,116,105,105,49,13,10,32,32, +108,111,99,97,108,32,118,105,115,105,116,101,100,44,32,105,116,101,109,73, +110,102,111,44,32,105,116,101,109,73,110,102,111,76,101,110,32,61,32,123, +125,44,123,125,44,48,13,10,32,32,102,111,114,32,105,61,49,44,108,101, +110,32,100,111,13,10,32,32,32,32,99,101,108,108,32,61,32,99,101,108, +108,115,91,105,93,13,10,32,32,32,32,102,111,114,32,105,116,101,109,32, +105,110,32,112,97,105,114,115,40,99,101,108,108,46,105,116,101,109,115,41, +32,100,111,13,10,32,32,32,32,32,32,105,102,32,110,111,116,32,118,105, +115,105,116,101,100,91,105,116,101,109,93,32,116,104,101,110,13,10,32,32, +32,32,32,32,32,32,118,105,115,105,116,101,100,91,105,116,101,109,93,32, +32,61,32,116,114,117,101,13,10,32,32,32,32,32,32,32,32,105,102,32, +40,110,111,116,32,102,105,108,116,101,114,32,111,114,32,102,105,108,116,101, +114,40,105,116,101,109,41,41,32,116,104,101,110,13,10,32,32,32,32,32, +32,32,32,32,32,114,101,99,116,32,32,32,32,32,32,32,32,32,32,32, +61,32,115,101,108,102,46,114,101,99,116,115,91,105,116,101,109,93,13,10, +32,32,32,32,32,32,32,32,32,32,108,44,116,44,119,44,104,32,32,32, +32,32,32,32,32,61,32,114,101,99,116,46,120,44,114,101,99,116,46,121, +44,114,101,99,116,46,119,44,114,101,99,116,46,104,13,10,13,10,32,32, +32,32,32,32,32,32,32,32,116,105,49,44,116,105,50,32,61,32,114,101, +99,116,95,103,101,116,83,101,103,109,101,110,116,73,110,116,101,114,115,101, +99,116,105,111,110,73,110,100,105,99,101,115,40,108,44,116,44,119,44,104, +44,32,120,49,44,121,49,44,32,120,50,44,121,50,44,32,48,44,32,49, +41,13,10,32,32,32,32,32,32,32,32,32,32,105,102,32,116,105,49,32, +97,110,100,32,40,40,48,32,60,32,116,105,49,32,97,110,100,32,116,105, +49,32,60,32,49,41,32,111,114,32,40,48,32,60,32,116,105,50,32,97, +110,100,32,116,105,50,32,60,32,49,41,41,32,116,104,101,110,13,10,32, +32,32,32,32,32,32,32,32,32,32,32,45,45,32,116,104,101,32,115,111, +114,116,105,110,103,32,105,115,32,97,99,99,111,114,100,105,110,103,32,116, +111,32,116,104,101,32,116,32,111,102,32,97,110,32,105,110,102,105,110,105, +116,101,32,108,105,110,101,44,32,110,111,116,32,116,104,101,32,115,101,103, +109,101,110,116,13,10,32,32,32,32,32,32,32,32,32,32,32,32,116,105, +105,48,44,116,105,105,49,32,32,32,32,61,32,114,101,99,116,95,103,101, +116,83,101,103,109,101,110,116,73,110,116,101,114,115,101,99,116,105,111,110, +73,110,100,105,99,101,115,40,108,44,116,44,119,44,104,44,32,120,49,44, +121,49,44,32,120,50,44,121,50,44,32,45,109,97,116,104,46,104,117,103, +101,44,32,109,97,116,104,46,104,117,103,101,41,13,10,32,32,32,32,32, +32,32,32,32,32,32,32,105,116,101,109,73,110,102,111,76,101,110,32,32, +61,32,105,116,101,109,73,110,102,111,76,101,110,32,43,32,49,13,10,32, +32,32,32,32,32,32,32,32,32,32,32,105,116,101,109,73,110,102,111,91, +105,116,101,109,73,110,102,111,76,101,110,93,32,61,32,123,105,116,101,109, +32,61,32,105,116,101,109,44,32,116,105,49,32,61,32,116,105,49,44,32, +116,105,50,32,61,32,116,105,50,44,32,119,101,105,103,104,116,32,61,32, +109,105,110,40,116,105,105,48,44,116,105,105,49,41,125,13,10,32,32,32, +32,32,32,32,32,32,32,101,110,100,13,10,32,32,32,32,32,32,32,32, +101,110,100,13,10,32,32,32,32,32,32,101,110,100,13,10,32,32,32,32, +101,110,100,13,10,32,32,101,110,100,13,10,32,32,116,97,98,108,101,46, +115,111,114,116,40,105,116,101,109,73,110,102,111,44,32,115,111,114,116,66, +121,87,101,105,103,104,116,41,13,10,32,32,114,101,116,117,114,110,32,105, +116,101,109,73,110,102,111,44,32,105,116,101,109,73,110,102,111,76,101,110, +13,10,101,110,100,13,10,13,10,108,111,99,97,108,32,102,117,110,99,116, +105,111,110,32,103,101,116,82,101,115,112,111,110,115,101,66,121,78,97,109, +101,40,115,101,108,102,44,32,110,97,109,101,41,13,10,32,32,108,111,99, +97,108,32,114,101,115,112,111,110,115,101,32,61,32,115,101,108,102,46,114, +101,115,112,111,110,115,101,115,91,110,97,109,101,93,13,10,32,32,105,102, +32,110,111,116,32,114,101,115,112,111,110,115,101,32,116,104,101,110,13,10, +32,32,32,32,101,114,114,111,114,40,40,39,85,110,107,110,111,119,110,32, +99,111,108,108,105,115,105,111,110,32,116,121,112,101,58,32,37,115,32,40, +37,115,41,39,41,58,102,111,114,109,97,116,40,110,97,109,101,44,32,116, +121,112,101,40,110,97,109,101,41,41,41,13,10,32,32,101,110,100,13,10, +32,32,114,101,116,117,114,110,32,114,101,115,112,111,110,115,101,13,10,101, +110,100,13,10,13,10,13,10,45,45,32,77,105,115,99,32,80,117,98,108, +105,99,32,77,101,116,104,111,100,115,13,10,13,10,102,117,110,99,116,105, 111,110,32,87,111,114,108,100,58,97,100,100,82,101,115,112,111,110,115,101, -40,110,97,109,101,44,32,114,101,115,112,111,110,115,101,41,10,32,32,115, -101,108,102,46,114,101,115,112,111,110,115,101,115,91,110,97,109,101,93,32, -61,32,114,101,115,112,111,110,115,101,10,101,110,100,10,10,102,117,110,99, -116,105,111,110,32,87,111,114,108,100,58,112,114,111,106,101,99,116,40,105, -116,101,109,44,32,120,44,121,44,119,44,104,44,32,103,111,97,108,88,44, -32,103,111,97,108,89,44,32,102,105,108,116,101,114,41,10,32,32,97,115, -115,101,114,116,73,115,82,101,99,116,40,120,44,121,44,119,44,104,41,10, -10,32,32,103,111,97,108,88,32,61,32,103,111,97,108,88,32,111,114,32, -120,10,32,32,103,111,97,108,89,32,61,32,103,111,97,108,89,32,111,114, -32,121,10,32,32,102,105,108,116,101,114,32,32,61,32,102,105,108,116,101, -114,32,32,111,114,32,100,101,102,97,117,108,116,70,105,108,116,101,114,10, -10,32,32,108,111,99,97,108,32,99,111,108,108,105,115,105,111,110,115,44, -32,108,101,110,32,61,32,123,125,44,32,48,10,10,32,32,108,111,99,97, -108,32,118,105,115,105,116,101,100,32,61,32,123,125,10,32,32,105,102,32, -105,116,101,109,32,126,61,32,110,105,108,32,116,104,101,110,32,118,105,115, -105,116,101,100,91,105,116,101,109,93,32,61,32,116,114,117,101,32,101,110, -100,10,10,32,32,45,45,32,84,104,105,115,32,99,111,117,108,100,32,112, -114,111,98,97,98,108,121,32,98,101,32,100,111,110,101,32,119,105,116,104, -32,108,101,115,115,32,99,101,108,108,115,32,117,115,105,110,103,32,97,32, -112,111,108,121,103,111,110,32,114,97,115,116,101,114,32,111,118,101,114,32, -116,104,101,32,99,101,108,108,115,32,105,110,115,116,101,97,100,32,111,102, -32,97,10,32,32,45,45,32,98,111,117,110,100,105,110,103,32,114,101,99, -116,32,111,102,32,116,104,101,32,119,104,111,108,101,32,109,111,118,101,109, -101,110,116,46,32,67,111,110,100,105,116,105,111,110,97,108,32,116,111,32, -98,117,105,108,100,105,110,103,32,97,32,113,117,101,114,121,80,111,108,121, -103,111,110,32,109,101,116,104,111,100,10,32,32,108,111,99,97,108,32,116, -108,44,32,116,116,32,61,32,109,105,110,40,103,111,97,108,88,44,32,120, -41,44,32,32,32,32,32,32,32,109,105,110,40,103,111,97,108,89,44,32, -121,41,10,32,32,108,111,99,97,108,32,116,114,44,32,116,98,32,61,32, -109,97,120,40,103,111,97,108,88,32,43,32,119,44,32,120,43,119,41,44, -32,109,97,120,40,103,111,97,108,89,32,43,32,104,44,32,121,43,104,41, +40,110,97,109,101,44,32,114,101,115,112,111,110,115,101,41,13,10,32,32, +115,101,108,102,46,114,101,115,112,111,110,115,101,115,91,110,97,109,101,93, +32,61,32,114,101,115,112,111,110,115,101,13,10,101,110,100,13,10,13,10, +102,117,110,99,116,105,111,110,32,87,111,114,108,100,58,112,114,111,106,101, +99,116,40,105,116,101,109,44,32,120,44,121,44,119,44,104,44,32,103,111, +97,108,88,44,32,103,111,97,108,89,44,32,102,105,108,116,101,114,41,13, +10,32,32,97,115,115,101,114,116,73,115,82,101,99,116,40,120,44,121,44, +119,44,104,41,13,10,13,10,32,32,103,111,97,108,88,32,61,32,103,111, +97,108,88,32,111,114,32,120,13,10,32,32,103,111,97,108,89,32,61,32, +103,111,97,108,89,32,111,114,32,121,13,10,32,32,102,105,108,116,101,114, +32,32,61,32,102,105,108,116,101,114,32,32,111,114,32,100,101,102,97,117, +108,116,70,105,108,116,101,114,13,10,13,10,32,32,108,111,99,97,108,32, +99,111,108,108,105,115,105,111,110,115,44,32,108,101,110,32,61,32,123,125, +44,32,48,13,10,13,10,32,32,108,111,99,97,108,32,118,105,115,105,116, +101,100,32,61,32,123,125,13,10,32,32,105,102,32,105,116,101,109,32,126, +61,32,110,105,108,32,116,104,101,110,32,118,105,115,105,116,101,100,91,105, +116,101,109,93,32,61,32,116,114,117,101,32,101,110,100,13,10,13,10,32, +32,45,45,32,84,104,105,115,32,99,111,117,108,100,32,112,114,111,98,97, +98,108,121,32,98,101,32,100,111,110,101,32,119,105,116,104,32,108,101,115, +115,32,99,101,108,108,115,32,117,115,105,110,103,32,97,32,112,111,108,121, +103,111,110,32,114,97,115,116,101,114,32,111,118,101,114,32,116,104,101,32, +99,101,108,108,115,32,105,110,115,116,101,97,100,32,111,102,32,97,13,10, +32,32,45,45,32,98,111,117,110,100,105,110,103,32,114,101,99,116,32,111, +102,32,116,104,101,32,119,104,111,108,101,32,109,111,118,101,109,101,110,116, +46,32,67,111,110,100,105,116,105,111,110,97,108,32,116,111,32,98,117,105, +108,100,105,110,103,32,97,32,113,117,101,114,121,80,111,108,121,103,111,110, +32,109,101,116,104,111,100,13,10,32,32,108,111,99,97,108,32,116,108,44, +32,116,116,32,61,32,109,105,110,40,103,111,97,108,88,44,32,120,41,44, +32,32,32,32,32,32,32,109,105,110,40,103,111,97,108,89,44,32,121,41, +13,10,32,32,108,111,99,97,108,32,116,114,44,32,116,98,32,61,32,109, +97,120,40,103,111,97,108,88,32,43,32,119,44,32,120,43,119,41,44,32, +109,97,120,40,103,111,97,108,89,32,43,32,104,44,32,121,43,104,41,13, 10,32,32,108,111,99,97,108,32,116,119,44,32,116,104,32,61,32,116,114, -45,116,108,44,32,116,98,45,116,116,10,10,32,32,108,111,99,97,108,32, -99,108,44,99,116,44,99,119,44,99,104,32,61,32,103,114,105,100,95,116, -111,67,101,108,108,82,101,99,116,40,115,101,108,102,46,99,101,108,108,83, -105,122,101,44,32,116,108,44,116,116,44,116,119,44,116,104,41,10,10,32, -32,108,111,99,97,108,32,100,105,99,116,73,116,101,109,115,73,110,67,101, -108,108,82,101,99,116,32,61,32,103,101,116,68,105,99,116,73,116,101,109, -115,73,110,67,101,108,108,82,101,99,116,40,115,101,108,102,44,32,99,108, -44,99,116,44,99,119,44,99,104,41,10,10,32,32,102,111,114,32,111,116, -104,101,114,44,95,32,105,110,32,112,97,105,114,115,40,100,105,99,116,73, -116,101,109,115,73,110,67,101,108,108,82,101,99,116,41,32,100,111,10,32, -32,32,32,105,102,32,110,111,116,32,118,105,115,105,116,101,100,91,111,116, -104,101,114,93,32,116,104,101,110,10,32,32,32,32,32,32,118,105,115,105, -116,101,100,91,111,116,104,101,114,93,32,61,32,116,114,117,101,10,10,32, -32,32,32,32,32,108,111,99,97,108,32,114,101,115,112,111,110,115,101,78, -97,109,101,32,61,32,102,105,108,116,101,114,40,105,116,101,109,44,32,111, -116,104,101,114,41,10,32,32,32,32,32,32,105,102,32,114,101,115,112,111, -110,115,101,78,97,109,101,32,116,104,101,110,10,32,32,32,32,32,32,32, -32,108,111,99,97,108,32,111,120,44,111,121,44,111,119,44,111,104,32,32, -32,61,32,115,101,108,102,58,103,101,116,82,101,99,116,40,111,116,104,101, -114,41,10,32,32,32,32,32,32,32,32,108,111,99,97,108,32,99,111,108, -32,32,32,32,32,32,32,32,32,32,32,61,32,114,101,99,116,95,100,101, -116,101,99,116,67,111,108,108,105,115,105,111,110,40,120,44,121,44,119,44, -104,44,32,111,120,44,111,121,44,111,119,44,111,104,44,32,103,111,97,108, -88,44,32,103,111,97,108,89,41,10,10,32,32,32,32,32,32,32,32,105, -102,32,99,111,108,32,116,104,101,110,10,32,32,32,32,32,32,32,32,32, -32,99,111,108,46,111,116,104,101,114,32,32,32,32,61,32,111,116,104,101, -114,10,32,32,32,32,32,32,32,32,32,32,99,111,108,46,105,116,101,109, -32,32,32,32,32,61,32,105,116,101,109,10,32,32,32,32,32,32,32,32, -32,32,99,111,108,46,116,121,112,101,32,32,32,32,32,61,32,114,101,115, -112,111,110,115,101,78,97,109,101,10,10,32,32,32,32,32,32,32,32,32, -32,108,101,110,32,61,32,108,101,110,32,43,32,49,10,32,32,32,32,32, -32,32,32,32,32,99,111,108,108,105,115,105,111,110,115,91,108,101,110,93, -32,61,32,99,111,108,10,32,32,32,32,32,32,32,32,101,110,100,10,32, -32,32,32,32,32,101,110,100,10,32,32,32,32,101,110,100,10,32,32,101, -110,100,10,10,32,32,116,97,98,108,101,46,115,111,114,116,40,99,111,108, -108,105,115,105,111,110,115,44,32,115,111,114,116,66,121,84,105,65,110,100, -68,105,115,116,97,110,99,101,41,10,10,32,32,114,101,116,117,114,110,32, -99,111,108,108,105,115,105,111,110,115,44,32,108,101,110,10,101,110,100,10, -10,102,117,110,99,116,105,111,110,32,87,111,114,108,100,58,99,111,117,110, -116,67,101,108,108,115,40,41,10,32,32,108,111,99,97,108,32,99,111,117, -110,116,32,61,32,48,10,32,32,102,111,114,32,95,44,114,111,119,32,105, -110,32,112,97,105,114,115,40,115,101,108,102,46,114,111,119,115,41,32,100, -111,10,32,32,32,32,102,111,114,32,95,44,95,32,105,110,32,112,97,105, -114,115,40,114,111,119,41,32,100,111,10,32,32,32,32,32,32,99,111,117, -110,116,32,61,32,99,111,117,110,116,32,43,32,49,10,32,32,32,32,101, -110,100,10,32,32,101,110,100,10,32,32,114,101,116,117,114,110,32,99,111, -117,110,116,10,101,110,100,10,10,102,117,110,99,116,105,111,110,32,87,111, -114,108,100,58,104,97,115,73,116,101,109,40,105,116,101,109,41,10,32,32, -114,101,116,117,114,110,32,110,111,116,32,110,111,116,32,115,101,108,102,46, -114,101,99,116,115,91,105,116,101,109,93,10,101,110,100,10,10,102,117,110, -99,116,105,111,110,32,87,111,114,108,100,58,103,101,116,73,116,101,109,115, -40,41,10,32,32,108,111,99,97,108,32,105,116,101,109,115,44,32,108,101, -110,32,61,32,123,125,44,32,48,10,32,32,102,111,114,32,105,116,101,109, -44,95,32,105,110,32,112,97,105,114,115,40,115,101,108,102,46,114,101,99, -116,115,41,32,100,111,10,32,32,32,32,108,101,110,32,61,32,108,101,110, -32,43,32,49,10,32,32,32,32,105,116,101,109,115,91,108,101,110,93,32, -61,32,105,116,101,109,10,32,32,101,110,100,10,32,32,114,101,116,117,114, -110,32,105,116,101,109,115,44,32,108,101,110,10,101,110,100,10,10,102,117, -110,99,116,105,111,110,32,87,111,114,108,100,58,99,111,117,110,116,73,116, -101,109,115,40,41,10,32,32,108,111,99,97,108,32,108,101,110,32,61,32, -48,10,32,32,102,111,114,32,95,32,105,110,32,112,97,105,114,115,40,115, -101,108,102,46,114,101,99,116,115,41,32,100,111,32,108,101,110,32,61,32, -108,101,110,32,43,32,49,32,101,110,100,10,32,32,114,101,116,117,114,110, -32,108,101,110,10,101,110,100,10,10,102,117,110,99,116,105,111,110,32,87, -111,114,108,100,58,103,101,116,82,101,99,116,40,105,116,101,109,41,10,32, -32,108,111,99,97,108,32,114,101,99,116,32,61,32,115,101,108,102,46,114, -101,99,116,115,91,105,116,101,109,93,10,32,32,105,102,32,110,111,116,32, -114,101,99,116,32,116,104,101,110,10,32,32,32,32,101,114,114,111,114,40, -39,73,116,101,109,32,39,32,46,46,32,116,111,115,116,114,105,110,103,40, -105,116,101,109,41,32,46,46,32,39,32,109,117,115,116,32,98,101,32,97, -100,100,101,100,32,116,111,32,116,104,101,32,119,111,114,108,100,32,98,101, -102,111,114,101,32,103,101,116,116,105,110,103,32,105,116,115,32,114,101,99, -116,46,32,85,115,101,32,119,111,114,108,100,58,97,100,100,40,105,116,101, -109,44,32,120,44,121,44,119,44,104,41,32,116,111,32,97,100,100,32,105, -116,32,102,105,114,115,116,46,39,41,10,32,32,101,110,100,10,32,32,114, -101,116,117,114,110,32,114,101,99,116,46,120,44,32,114,101,99,116,46,121, -44,32,114,101,99,116,46,119,44,32,114,101,99,116,46,104,10,101,110,100, -10,10,102,117,110,99,116,105,111,110,32,87,111,114,108,100,58,116,111,87, -111,114,108,100,40,99,120,44,32,99,121,41,10,32,32,114,101,116,117,114, -110,32,103,114,105,100,95,116,111,87,111,114,108,100,40,115,101,108,102,46, -99,101,108,108,83,105,122,101,44,32,99,120,44,32,99,121,41,10,101,110, -100,10,10,102,117,110,99,116,105,111,110,32,87,111,114,108,100,58,116,111, -67,101,108,108,40,120,44,121,41,10,32,32,114,101,116,117,114,110,32,103, -114,105,100,95,116,111,67,101,108,108,40,115,101,108,102,46,99,101,108,108, -83,105,122,101,44,32,120,44,32,121,41,10,101,110,100,10,10,10,45,45, -45,32,81,117,101,114,121,32,109,101,116,104,111,100,115,10,10,102,117,110, +45,116,108,44,32,116,98,45,116,116,13,10,13,10,32,32,108,111,99,97, +108,32,99,108,44,99,116,44,99,119,44,99,104,32,61,32,103,114,105,100, +95,116,111,67,101,108,108,82,101,99,116,40,115,101,108,102,46,99,101,108, +108,83,105,122,101,44,32,116,108,44,116,116,44,116,119,44,116,104,41,13, +10,13,10,32,32,108,111,99,97,108,32,100,105,99,116,73,116,101,109,115, +73,110,67,101,108,108,82,101,99,116,32,61,32,103,101,116,68,105,99,116, +73,116,101,109,115,73,110,67,101,108,108,82,101,99,116,40,115,101,108,102, +44,32,99,108,44,99,116,44,99,119,44,99,104,41,13,10,13,10,32,32, +102,111,114,32,111,116,104,101,114,44,95,32,105,110,32,112,97,105,114,115, +40,100,105,99,116,73,116,101,109,115,73,110,67,101,108,108,82,101,99,116, +41,32,100,111,13,10,32,32,32,32,105,102,32,110,111,116,32,118,105,115, +105,116,101,100,91,111,116,104,101,114,93,32,116,104,101,110,13,10,32,32, +32,32,32,32,118,105,115,105,116,101,100,91,111,116,104,101,114,93,32,61, +32,116,114,117,101,13,10,13,10,32,32,32,32,32,32,108,111,99,97,108, +32,114,101,115,112,111,110,115,101,78,97,109,101,32,61,32,102,105,108,116, +101,114,40,105,116,101,109,44,32,111,116,104,101,114,41,13,10,32,32,32, +32,32,32,105,102,32,114,101,115,112,111,110,115,101,78,97,109,101,32,116, +104,101,110,13,10,32,32,32,32,32,32,32,32,108,111,99,97,108,32,111, +120,44,111,121,44,111,119,44,111,104,32,32,32,61,32,115,101,108,102,58, +103,101,116,82,101,99,116,40,111,116,104,101,114,41,13,10,32,32,32,32, +32,32,32,32,108,111,99,97,108,32,99,111,108,32,32,32,32,32,32,32, +32,32,32,32,61,32,114,101,99,116,95,100,101,116,101,99,116,67,111,108, +108,105,115,105,111,110,40,120,44,121,44,119,44,104,44,32,111,120,44,111, +121,44,111,119,44,111,104,44,32,103,111,97,108,88,44,32,103,111,97,108, +89,41,13,10,13,10,32,32,32,32,32,32,32,32,105,102,32,99,111,108, +32,116,104,101,110,13,10,32,32,32,32,32,32,32,32,32,32,99,111,108, +46,111,116,104,101,114,32,32,32,32,61,32,111,116,104,101,114,13,10,32, +32,32,32,32,32,32,32,32,32,99,111,108,46,105,116,101,109,32,32,32, +32,32,61,32,105,116,101,109,13,10,32,32,32,32,32,32,32,32,32,32, +99,111,108,46,116,121,112,101,32,32,32,32,32,61,32,114,101,115,112,111, +110,115,101,78,97,109,101,13,10,13,10,32,32,32,32,32,32,32,32,32, +32,108,101,110,32,61,32,108,101,110,32,43,32,49,13,10,32,32,32,32, +32,32,32,32,32,32,99,111,108,108,105,115,105,111,110,115,91,108,101,110, +93,32,61,32,99,111,108,13,10,32,32,32,32,32,32,32,32,101,110,100, +13,10,32,32,32,32,32,32,101,110,100,13,10,32,32,32,32,101,110,100, +13,10,32,32,101,110,100,13,10,13,10,32,32,116,97,98,108,101,46,115, +111,114,116,40,99,111,108,108,105,115,105,111,110,115,44,32,115,111,114,116, +66,121,84,105,65,110,100,68,105,115,116,97,110,99,101,41,13,10,13,10, +32,32,114,101,116,117,114,110,32,99,111,108,108,105,115,105,111,110,115,44, +32,108,101,110,13,10,101,110,100,13,10,13,10,102,117,110,99,116,105,111, +110,32,87,111,114,108,100,58,99,111,117,110,116,67,101,108,108,115,40,41, +13,10,32,32,108,111,99,97,108,32,99,111,117,110,116,32,61,32,48,13, +10,32,32,102,111,114,32,95,44,114,111,119,32,105,110,32,112,97,105,114, +115,40,115,101,108,102,46,114,111,119,115,41,32,100,111,13,10,32,32,32, +32,102,111,114,32,95,44,95,32,105,110,32,112,97,105,114,115,40,114,111, +119,41,32,100,111,13,10,32,32,32,32,32,32,99,111,117,110,116,32,61, +32,99,111,117,110,116,32,43,32,49,13,10,32,32,32,32,101,110,100,13, +10,32,32,101,110,100,13,10,32,32,114,101,116,117,114,110,32,99,111,117, +110,116,13,10,101,110,100,13,10,13,10,102,117,110,99,116,105,111,110,32, +87,111,114,108,100,58,104,97,115,73,116,101,109,40,105,116,101,109,41,13, +10,32,32,114,101,116,117,114,110,32,110,111,116,32,110,111,116,32,115,101, +108,102,46,114,101,99,116,115,91,105,116,101,109,93,13,10,101,110,100,13, +10,13,10,102,117,110,99,116,105,111,110,32,87,111,114,108,100,58,103,101, +116,73,116,101,109,115,40,41,13,10,32,32,108,111,99,97,108,32,105,116, +101,109,115,44,32,108,101,110,32,61,32,123,125,44,32,48,13,10,32,32, +102,111,114,32,105,116,101,109,44,95,32,105,110,32,112,97,105,114,115,40, +115,101,108,102,46,114,101,99,116,115,41,32,100,111,13,10,32,32,32,32, +108,101,110,32,61,32,108,101,110,32,43,32,49,13,10,32,32,32,32,105, +116,101,109,115,91,108,101,110,93,32,61,32,105,116,101,109,13,10,32,32, +101,110,100,13,10,32,32,114,101,116,117,114,110,32,105,116,101,109,115,44, +32,108,101,110,13,10,101,110,100,13,10,13,10,102,117,110,99,116,105,111, +110,32,87,111,114,108,100,58,99,111,117,110,116,73,116,101,109,115,40,41, +13,10,32,32,108,111,99,97,108,32,108,101,110,32,61,32,48,13,10,32, +32,102,111,114,32,95,32,105,110,32,112,97,105,114,115,40,115,101,108,102, +46,114,101,99,116,115,41,32,100,111,32,108,101,110,32,61,32,108,101,110, +32,43,32,49,32,101,110,100,13,10,32,32,114,101,116,117,114,110,32,108, +101,110,13,10,101,110,100,13,10,13,10,102,117,110,99,116,105,111,110,32, +87,111,114,108,100,58,103,101,116,82,101,99,116,40,105,116,101,109,41,13, +10,32,32,108,111,99,97,108,32,114,101,99,116,32,61,32,115,101,108,102, +46,114,101,99,116,115,91,105,116,101,109,93,13,10,32,32,105,102,32,110, +111,116,32,114,101,99,116,32,116,104,101,110,13,10,32,32,32,32,101,114, +114,111,114,40,39,73,116,101,109,32,39,32,46,46,32,116,111,115,116,114, +105,110,103,40,105,116,101,109,41,32,46,46,32,39,32,109,117,115,116,32, +98,101,32,97,100,100,101,100,32,116,111,32,116,104,101,32,119,111,114,108, +100,32,98,101,102,111,114,101,32,103,101,116,116,105,110,103,32,105,116,115, +32,114,101,99,116,46,32,85,115,101,32,119,111,114,108,100,58,97,100,100, +40,105,116,101,109,44,32,120,44,121,44,119,44,104,41,32,116,111,32,97, +100,100,32,105,116,32,102,105,114,115,116,46,39,41,13,10,32,32,101,110, +100,13,10,32,32,114,101,116,117,114,110,32,114,101,99,116,46,120,44,32, +114,101,99,116,46,121,44,32,114,101,99,116,46,119,44,32,114,101,99,116, +46,104,13,10,101,110,100,13,10,13,10,102,117,110,99,116,105,111,110,32, +87,111,114,108,100,58,116,111,87,111,114,108,100,40,99,120,44,32,99,121, +41,13,10,32,32,114,101,116,117,114,110,32,103,114,105,100,95,116,111,87, +111,114,108,100,40,115,101,108,102,46,99,101,108,108,83,105,122,101,44,32, +99,120,44,32,99,121,41,13,10,101,110,100,13,10,13,10,102,117,110,99, +116,105,111,110,32,87,111,114,108,100,58,116,111,67,101,108,108,40,120,44, +121,41,13,10,32,32,114,101,116,117,114,110,32,103,114,105,100,95,116,111, +67,101,108,108,40,115,101,108,102,46,99,101,108,108,83,105,122,101,44,32, +120,44,32,121,41,13,10,101,110,100,13,10,13,10,13,10,45,45,45,32, +81,117,101,114,121,32,109,101,116,104,111,100,115,13,10,13,10,102,117,110, 99,116,105,111,110,32,87,111,114,108,100,58,113,117,101,114,121,82,101,99, -116,40,120,44,121,44,119,44,104,44,32,102,105,108,116,101,114,41,10,10, -32,32,97,115,115,101,114,116,73,115,82,101,99,116,40,120,44,121,44,119, -44,104,41,10,10,32,32,108,111,99,97,108,32,99,108,44,99,116,44,99, -119,44,99,104,32,61,32,103,114,105,100,95,116,111,67,101,108,108,82,101, -99,116,40,115,101,108,102,46,99,101,108,108,83,105,122,101,44,32,120,44, -121,44,119,44,104,41,10,32,32,108,111,99,97,108,32,100,105,99,116,73, -116,101,109,115,73,110,67,101,108,108,82,101,99,116,32,61,32,103,101,116, -68,105,99,116,73,116,101,109,115,73,110,67,101,108,108,82,101,99,116,40, -115,101,108,102,44,32,99,108,44,99,116,44,99,119,44,99,104,41,10,10, -32,32,108,111,99,97,108,32,105,116,101,109,115,44,32,108,101,110,32,61, -32,123,125,44,32,48,10,10,32,32,108,111,99,97,108,32,114,101,99,116, -10,32,32,102,111,114,32,105,116,101,109,44,95,32,105,110,32,112,97,105, -114,115,40,100,105,99,116,73,116,101,109,115,73,110,67,101,108,108,82,101, -99,116,41,32,100,111,10,32,32,32,32,114,101,99,116,32,61,32,115,101, -108,102,46,114,101,99,116,115,91,105,116,101,109,93,10,32,32,32,32,105, -102,32,40,110,111,116,32,102,105,108,116,101,114,32,111,114,32,102,105,108, -116,101,114,40,105,116,101,109,41,41,10,32,32,32,32,97,110,100,32,114, -101,99,116,95,105,115,73,110,116,101,114,115,101,99,116,105,110,103,40,120, -44,121,44,119,44,104,44,32,114,101,99,116,46,120,44,32,114,101,99,116, -46,121,44,32,114,101,99,116,46,119,44,32,114,101,99,116,46,104,41,10, -32,32,32,32,116,104,101,110,10,32,32,32,32,32,32,108,101,110,32,61, -32,108,101,110,32,43,32,49,10,32,32,32,32,32,32,105,116,101,109,115, -91,108,101,110,93,32,61,32,105,116,101,109,10,32,32,32,32,101,110,100, -10,32,32,101,110,100,10,10,32,32,114,101,116,117,114,110,32,105,116,101, -109,115,44,32,108,101,110,10,101,110,100,10,10,102,117,110,99,116,105,111, -110,32,87,111,114,108,100,58,113,117,101,114,121,80,111,105,110,116,40,120, -44,121,44,32,102,105,108,116,101,114,41,10,32,32,108,111,99,97,108,32, -99,120,44,99,121,32,61,32,115,101,108,102,58,116,111,67,101,108,108,40, -120,44,121,41,10,32,32,108,111,99,97,108,32,100,105,99,116,73,116,101, -109,115,73,110,67,101,108,108,82,101,99,116,32,61,32,103,101,116,68,105, -99,116,73,116,101,109,115,73,110,67,101,108,108,82,101,99,116,40,115,101, -108,102,44,32,99,120,44,99,121,44,49,44,49,41,10,10,32,32,108,111, -99,97,108,32,105,116,101,109,115,44,32,108,101,110,32,61,32,123,125,44, -32,48,10,10,32,32,108,111,99,97,108,32,114,101,99,116,10,32,32,102, -111,114,32,105,116,101,109,44,95,32,105,110,32,112,97,105,114,115,40,100, -105,99,116,73,116,101,109,115,73,110,67,101,108,108,82,101,99,116,41,32, -100,111,10,32,32,32,32,114,101,99,116,32,61,32,115,101,108,102,46,114, -101,99,116,115,91,105,116,101,109,93,10,32,32,32,32,105,102,32,40,110, -111,116,32,102,105,108,116,101,114,32,111,114,32,102,105,108,116,101,114,40, -105,116,101,109,41,41,10,32,32,32,32,97,110,100,32,114,101,99,116,95, -99,111,110,116,97,105,110,115,80,111,105,110,116,40,114,101,99,116,46,120, -44,32,114,101,99,116,46,121,44,32,114,101,99,116,46,119,44,32,114,101, -99,116,46,104,44,32,120,44,32,121,41,10,32,32,32,32,116,104,101,110, -10,32,32,32,32,32,32,108,101,110,32,61,32,108,101,110,32,43,32,49, -10,32,32,32,32,32,32,105,116,101,109,115,91,108,101,110,93,32,61,32, -105,116,101,109,10,32,32,32,32,101,110,100,10,32,32,101,110,100,10,10, -32,32,114,101,116,117,114,110,32,105,116,101,109,115,44,32,108,101,110,10, -101,110,100,10,10,102,117,110,99,116,105,111,110,32,87,111,114,108,100,58, -113,117,101,114,121,83,101,103,109,101,110,116,40,120,49,44,32,121,49,44, -32,120,50,44,32,121,50,44,32,102,105,108,116,101,114,41,10,32,32,108, -111,99,97,108,32,105,116,101,109,73,110,102,111,44,32,108,101,110,32,61, -32,103,101,116,73,110,102,111,65,98,111,117,116,73,116,101,109,115,84,111, -117,99,104,101,100,66,121,83,101,103,109,101,110,116,40,115,101,108,102,44, -32,120,49,44,32,121,49,44,32,120,50,44,32,121,50,44,32,102,105,108, -116,101,114,41,10,32,32,108,111,99,97,108,32,105,116,101,109,115,32,61, -32,123,125,10,32,32,102,111,114,32,105,61,49,44,32,108,101,110,32,100, -111,10,32,32,32,32,105,116,101,109,115,91,105,93,32,61,32,105,116,101, -109,73,110,102,111,91,105,93,46,105,116,101,109,10,32,32,101,110,100,10, -32,32,114,101,116,117,114,110,32,105,116,101,109,115,44,32,108,101,110,10, -101,110,100,10,10,102,117,110,99,116,105,111,110,32,87,111,114,108,100,58, -113,117,101,114,121,83,101,103,109,101,110,116,87,105,116,104,67,111,111,114, -100,115,40,120,49,44,32,121,49,44,32,120,50,44,32,121,50,44,32,102, -105,108,116,101,114,41,10,32,32,108,111,99,97,108,32,105,116,101,109,73, -110,102,111,44,32,108,101,110,32,61,32,103,101,116,73,110,102,111,65,98, -111,117,116,73,116,101,109,115,84,111,117,99,104,101,100,66,121,83,101,103, -109,101,110,116,40,115,101,108,102,44,32,120,49,44,32,121,49,44,32,120, -50,44,32,121,50,44,32,102,105,108,116,101,114,41,10,32,32,108,111,99, -97,108,32,100,120,44,32,100,121,32,32,32,32,32,32,32,32,61,32,120, -50,45,120,49,44,32,121,50,45,121,49,10,32,32,108,111,99,97,108,32, -105,110,102,111,44,32,116,105,49,44,32,116,105,50,10,32,32,102,111,114, -32,105,61,49,44,32,108,101,110,32,100,111,10,32,32,32,32,105,110,102, -111,32,32,61,32,105,116,101,109,73,110,102,111,91,105,93,10,32,32,32, -32,116,105,49,32,32,32,61,32,105,110,102,111,46,116,105,49,10,32,32, -32,32,116,105,50,32,32,32,61,32,105,110,102,111,46,116,105,50,10,10, -32,32,32,32,105,110,102,111,46,119,101,105,103,104,116,32,32,61,32,110, -105,108,10,32,32,32,32,105,110,102,111,46,120,49,32,32,32,32,32,32, -61,32,120,49,32,43,32,100,120,32,42,32,116,105,49,10,32,32,32,32, -105,110,102,111,46,121,49,32,32,32,32,32,32,61,32,121,49,32,43,32, -100,121,32,42,32,116,105,49,10,32,32,32,32,105,110,102,111,46,120,50, -32,32,32,32,32,32,61,32,120,49,32,43,32,100,120,32,42,32,116,105, -50,10,32,32,32,32,105,110,102,111,46,121,50,32,32,32,32,32,32,61, -32,121,49,32,43,32,100,121,32,42,32,116,105,50,10,32,32,101,110,100, -10,32,32,114,101,116,117,114,110,32,105,116,101,109,73,110,102,111,44,32, -108,101,110,10,101,110,100,10,10,10,45,45,45,32,77,97,105,110,32,109, -101,116,104,111,100,115,10,10,102,117,110,99,116,105,111,110,32,87,111,114, -108,100,58,97,100,100,40,105,116,101,109,44,32,120,44,121,44,119,44,104, -41,10,32,32,108,111,99,97,108,32,114,101,99,116,32,61,32,115,101,108, -102,46,114,101,99,116,115,91,105,116,101,109,93,10,32,32,105,102,32,114, -101,99,116,32,116,104,101,110,10,32,32,32,32,101,114,114,111,114,40,39, -73,116,101,109,32,39,32,46,46,32,116,111,115,116,114,105,110,103,40,105, -116,101,109,41,32,46,46,32,39,32,97,100,100,101,100,32,116,111,32,116, -104,101,32,119,111,114,108,100,32,116,119,105,99,101,46,39,41,10,32,32, -101,110,100,10,32,32,97,115,115,101,114,116,73,115,82,101,99,116,40,120, -44,121,44,119,44,104,41,10,10,32,32,115,101,108,102,46,114,101,99,116, -115,91,105,116,101,109,93,32,61,32,123,120,61,120,44,121,61,121,44,119, -61,119,44,104,61,104,125,10,10,32,32,108,111,99,97,108,32,99,108,44, +116,40,120,44,121,44,119,44,104,44,32,102,105,108,116,101,114,41,13,10, +13,10,32,32,97,115,115,101,114,116,73,115,82,101,99,116,40,120,44,121, +44,119,44,104,41,13,10,13,10,32,32,108,111,99,97,108,32,99,108,44, 99,116,44,99,119,44,99,104,32,61,32,103,114,105,100,95,116,111,67,101, 108,108,82,101,99,116,40,115,101,108,102,46,99,101,108,108,83,105,122,101, -44,32,120,44,121,44,119,44,104,41,10,32,32,102,111,114,32,99,121,32, -61,32,99,116,44,32,99,116,43,99,104,45,49,32,100,111,10,32,32,32, -32,102,111,114,32,99,120,32,61,32,99,108,44,32,99,108,43,99,119,45, -49,32,100,111,10,32,32,32,32,32,32,97,100,100,73,116,101,109,84,111, -67,101,108,108,40,115,101,108,102,44,32,105,116,101,109,44,32,99,120,44, -32,99,121,41,10,32,32,32,32,101,110,100,10,32,32,101,110,100,10,10, -32,32,114,101,116,117,114,110,32,105,116,101,109,10,101,110,100,10,10,102, -117,110,99,116,105,111,110,32,87,111,114,108,100,58,114,101,109,111,118,101, -40,105,116,101,109,41,10,32,32,108,111,99,97,108,32,120,44,121,44,119, -44,104,32,61,32,115,101,108,102,58,103,101,116,82,101,99,116,40,105,116, -101,109,41,10,10,32,32,115,101,108,102,46,114,101,99,116,115,91,105,116, -101,109,93,32,61,32,110,105,108,10,32,32,108,111,99,97,108,32,99,108, -44,99,116,44,99,119,44,99,104,32,61,32,103,114,105,100,95,116,111,67, -101,108,108,82,101,99,116,40,115,101,108,102,46,99,101,108,108,83,105,122, -101,44,32,120,44,121,44,119,44,104,41,10,32,32,102,111,114,32,99,121, -32,61,32,99,116,44,32,99,116,43,99,104,45,49,32,100,111,10,32,32, -32,32,102,111,114,32,99,120,32,61,32,99,108,44,32,99,108,43,99,119, -45,49,32,100,111,10,32,32,32,32,32,32,114,101,109,111,118,101,73,116, -101,109,70,114,111,109,67,101,108,108,40,115,101,108,102,44,32,105,116,101, -109,44,32,99,120,44,32,99,121,41,10,32,32,32,32,101,110,100,10,32, -32,101,110,100,10,101,110,100,10,10,102,117,110,99,116,105,111,110,32,87, -111,114,108,100,58,117,112,100,97,116,101,40,105,116,101,109,44,32,120,50, -44,121,50,44,119,50,44,104,50,41,10,32,32,108,111,99,97,108,32,120, -49,44,121,49,44,119,49,44,104,49,32,61,32,115,101,108,102,58,103,101, -116,82,101,99,116,40,105,116,101,109,41,10,32,32,119,50,44,104,50,32, -61,32,119,50,32,111,114,32,119,49,44,32,104,50,32,111,114,32,104,49, -10,32,32,97,115,115,101,114,116,73,115,82,101,99,116,40,120,50,44,121, -50,44,119,50,44,104,50,41,10,10,32,32,105,102,32,120,49,32,126,61, -32,120,50,32,111,114,32,121,49,32,126,61,32,121,50,32,111,114,32,119, -49,32,126,61,32,119,50,32,111,114,32,104,49,32,126,61,32,104,50,32, -116,104,101,110,10,10,32,32,32,32,108,111,99,97,108,32,99,101,108,108, -83,105,122,101,32,61,32,115,101,108,102,46,99,101,108,108,83,105,122,101, -10,32,32,32,32,108,111,99,97,108,32,99,108,49,44,99,116,49,44,99, -119,49,44,99,104,49,32,61,32,103,114,105,100,95,116,111,67,101,108,108, -82,101,99,116,40,99,101,108,108,83,105,122,101,44,32,120,49,44,121,49, -44,119,49,44,104,49,41,10,32,32,32,32,108,111,99,97,108,32,99,108, -50,44,99,116,50,44,99,119,50,44,99,104,50,32,61,32,103,114,105,100, -95,116,111,67,101,108,108,82,101,99,116,40,99,101,108,108,83,105,122,101, -44,32,120,50,44,121,50,44,119,50,44,104,50,41,10,10,32,32,32,32, -105,102,32,99,108,49,32,126,61,32,99,108,50,32,111,114,32,99,116,49, -32,126,61,32,99,116,50,32,111,114,32,99,119,49,32,126,61,32,99,119, -50,32,111,114,32,99,104,49,32,126,61,32,99,104,50,32,116,104,101,110, -10,10,32,32,32,32,32,32,108,111,99,97,108,32,99,114,49,44,32,99, -98,49,32,61,32,99,108,49,43,99,119,49,45,49,44,32,99,116,49,43, -99,104,49,45,49,10,32,32,32,32,32,32,108,111,99,97,108,32,99,114, -50,44,32,99,98,50,32,61,32,99,108,50,43,99,119,50,45,49,44,32, -99,116,50,43,99,104,50,45,49,10,32,32,32,32,32,32,108,111,99,97, -108,32,99,121,79,117,116,10,10,32,32,32,32,32,32,102,111,114,32,99, -121,32,61,32,99,116,49,44,32,99,98,49,32,100,111,10,32,32,32,32, -32,32,32,32,99,121,79,117,116,32,61,32,99,121,32,60,32,99,116,50, -32,111,114,32,99,121,32,62,32,99,98,50,10,32,32,32,32,32,32,32, -32,102,111,114,32,99,120,32,61,32,99,108,49,44,32,99,114,49,32,100, -111,10,32,32,32,32,32,32,32,32,32,32,105,102,32,99,121,79,117,116, -32,111,114,32,99,120,32,60,32,99,108,50,32,111,114,32,99,120,32,62, -32,99,114,50,32,116,104,101,110,10,32,32,32,32,32,32,32,32,32,32, -32,32,114,101,109,111,118,101,73,116,101,109,70,114,111,109,67,101,108,108, -40,115,101,108,102,44,32,105,116,101,109,44,32,99,120,44,32,99,121,41, -10,32,32,32,32,32,32,32,32,32,32,101,110,100,10,32,32,32,32,32, -32,32,32,101,110,100,10,32,32,32,32,32,32,101,110,100,10,10,32,32, -32,32,32,32,102,111,114,32,99,121,32,61,32,99,116,50,44,32,99,98, -50,32,100,111,10,32,32,32,32,32,32,32,32,99,121,79,117,116,32,61, -32,99,121,32,60,32,99,116,49,32,111,114,32,99,121,32,62,32,99,98, -49,10,32,32,32,32,32,32,32,32,102,111,114,32,99,120,32,61,32,99, -108,50,44,32,99,114,50,32,100,111,10,32,32,32,32,32,32,32,32,32, -32,105,102,32,99,121,79,117,116,32,111,114,32,99,120,32,60,32,99,108, -49,32,111,114,32,99,120,32,62,32,99,114,49,32,116,104,101,110,10,32, -32,32,32,32,32,32,32,32,32,32,32,97,100,100,73,116,101,109,84,111, -67,101,108,108,40,115,101,108,102,44,32,105,116,101,109,44,32,99,120,44, -32,99,121,41,10,32,32,32,32,32,32,32,32,32,32,101,110,100,10,32, -32,32,32,32,32,32,32,101,110,100,10,32,32,32,32,32,32,101,110,100, -10,10,32,32,32,32,101,110,100,10,10,32,32,32,32,108,111,99,97,108, -32,114,101,99,116,32,61,32,115,101,108,102,46,114,101,99,116,115,91,105, -116,101,109,93,10,32,32,32,32,114,101,99,116,46,120,44,32,114,101,99, -116,46,121,44,32,114,101,99,116,46,119,44,32,114,101,99,116,46,104,32, -61,32,120,50,44,121,50,44,119,50,44,104,50,10,10,32,32,101,110,100, -10,101,110,100,10,10,102,117,110,99,116,105,111,110,32,87,111,114,108,100, -58,109,111,118,101,40,105,116,101,109,44,32,103,111,97,108,88,44,32,103, -111,97,108,89,44,32,102,105,108,116,101,114,41,10,32,32,108,111,99,97, -108,32,97,99,116,117,97,108,88,44,32,97,99,116,117,97,108,89,44,32, -99,111,108,115,44,32,108,101,110,32,61,32,115,101,108,102,58,99,104,101, -99,107,40,105,116,101,109,44,32,103,111,97,108,88,44,32,103,111,97,108, -89,44,32,102,105,108,116,101,114,41,10,10,32,32,115,101,108,102,58,117, -112,100,97,116,101,40,105,116,101,109,44,32,97,99,116,117,97,108,88,44, -32,97,99,116,117,97,108,89,41,10,10,32,32,114,101,116,117,114,110,32, -97,99,116,117,97,108,88,44,32,97,99,116,117,97,108,89,44,32,99,111, -108,115,44,32,108,101,110,10,101,110,100,10,10,102,117,110,99,116,105,111, -110,32,87,111,114,108,100,58,99,104,101,99,107,40,105,116,101,109,44,32, -103,111,97,108,88,44,32,103,111,97,108,89,44,32,102,105,108,116,101,114, -41,10,32,32,102,105,108,116,101,114,32,61,32,102,105,108,116,101,114,32, -111,114,32,100,101,102,97,117,108,116,70,105,108,116,101,114,10,10,32,32, -108,111,99,97,108,32,118,105,115,105,116,101,100,32,61,32,123,91,105,116, -101,109,93,32,61,32,116,114,117,101,125,10,32,32,108,111,99,97,108,32, -118,105,115,105,116,101,100,70,105,108,116,101,114,32,61,32,102,117,110,99, -116,105,111,110,40,105,116,109,44,32,111,116,104,101,114,41,10,32,32,32, +44,32,120,44,121,44,119,44,104,41,13,10,32,32,108,111,99,97,108,32, +100,105,99,116,73,116,101,109,115,73,110,67,101,108,108,82,101,99,116,32, +61,32,103,101,116,68,105,99,116,73,116,101,109,115,73,110,67,101,108,108, +82,101,99,116,40,115,101,108,102,44,32,99,108,44,99,116,44,99,119,44, +99,104,41,13,10,13,10,32,32,108,111,99,97,108,32,105,116,101,109,115, +44,32,108,101,110,32,61,32,123,125,44,32,48,13,10,13,10,32,32,108, +111,99,97,108,32,114,101,99,116,13,10,32,32,102,111,114,32,105,116,101, +109,44,95,32,105,110,32,112,97,105,114,115,40,100,105,99,116,73,116,101, +109,115,73,110,67,101,108,108,82,101,99,116,41,32,100,111,13,10,32,32, +32,32,114,101,99,116,32,61,32,115,101,108,102,46,114,101,99,116,115,91, +105,116,101,109,93,13,10,32,32,32,32,105,102,32,40,110,111,116,32,102, +105,108,116,101,114,32,111,114,32,102,105,108,116,101,114,40,105,116,101,109, +41,41,13,10,32,32,32,32,97,110,100,32,114,101,99,116,95,105,115,73, +110,116,101,114,115,101,99,116,105,110,103,40,120,44,121,44,119,44,104,44, +32,114,101,99,116,46,120,44,32,114,101,99,116,46,121,44,32,114,101,99, +116,46,119,44,32,114,101,99,116,46,104,41,13,10,32,32,32,32,116,104, +101,110,13,10,32,32,32,32,32,32,108,101,110,32,61,32,108,101,110,32, +43,32,49,13,10,32,32,32,32,32,32,105,116,101,109,115,91,108,101,110, +93,32,61,32,105,116,101,109,13,10,32,32,32,32,101,110,100,13,10,32, +32,101,110,100,13,10,13,10,32,32,114,101,116,117,114,110,32,105,116,101, +109,115,44,32,108,101,110,13,10,101,110,100,13,10,13,10,102,117,110,99, +116,105,111,110,32,87,111,114,108,100,58,113,117,101,114,121,80,111,105,110, +116,40,120,44,121,44,32,102,105,108,116,101,114,41,13,10,32,32,108,111, +99,97,108,32,99,120,44,99,121,32,61,32,115,101,108,102,58,116,111,67, +101,108,108,40,120,44,121,41,13,10,32,32,108,111,99,97,108,32,100,105, +99,116,73,116,101,109,115,73,110,67,101,108,108,82,101,99,116,32,61,32, +103,101,116,68,105,99,116,73,116,101,109,115,73,110,67,101,108,108,82,101, +99,116,40,115,101,108,102,44,32,99,120,44,99,121,44,49,44,49,41,13, +10,13,10,32,32,108,111,99,97,108,32,105,116,101,109,115,44,32,108,101, +110,32,61,32,123,125,44,32,48,13,10,13,10,32,32,108,111,99,97,108, +32,114,101,99,116,13,10,32,32,102,111,114,32,105,116,101,109,44,95,32, +105,110,32,112,97,105,114,115,40,100,105,99,116,73,116,101,109,115,73,110, +67,101,108,108,82,101,99,116,41,32,100,111,13,10,32,32,32,32,114,101, +99,116,32,61,32,115,101,108,102,46,114,101,99,116,115,91,105,116,101,109, +93,13,10,32,32,32,32,105,102,32,40,110,111,116,32,102,105,108,116,101, +114,32,111,114,32,102,105,108,116,101,114,40,105,116,101,109,41,41,13,10, +32,32,32,32,97,110,100,32,114,101,99,116,95,99,111,110,116,97,105,110, +115,80,111,105,110,116,40,114,101,99,116,46,120,44,32,114,101,99,116,46, +121,44,32,114,101,99,116,46,119,44,32,114,101,99,116,46,104,44,32,120, +44,32,121,41,13,10,32,32,32,32,116,104,101,110,13,10,32,32,32,32, +32,32,108,101,110,32,61,32,108,101,110,32,43,32,49,13,10,32,32,32, +32,32,32,105,116,101,109,115,91,108,101,110,93,32,61,32,105,116,101,109, +13,10,32,32,32,32,101,110,100,13,10,32,32,101,110,100,13,10,13,10, +32,32,114,101,116,117,114,110,32,105,116,101,109,115,44,32,108,101,110,13, +10,101,110,100,13,10,13,10,102,117,110,99,116,105,111,110,32,87,111,114, +108,100,58,113,117,101,114,121,83,101,103,109,101,110,116,40,120,49,44,32, +121,49,44,32,120,50,44,32,121,50,44,32,102,105,108,116,101,114,41,13, +10,32,32,108,111,99,97,108,32,105,116,101,109,73,110,102,111,44,32,108, +101,110,32,61,32,103,101,116,73,110,102,111,65,98,111,117,116,73,116,101, +109,115,84,111,117,99,104,101,100,66,121,83,101,103,109,101,110,116,40,115, +101,108,102,44,32,120,49,44,32,121,49,44,32,120,50,44,32,121,50,44, +32,102,105,108,116,101,114,41,13,10,32,32,108,111,99,97,108,32,105,116, +101,109,115,32,61,32,123,125,13,10,32,32,102,111,114,32,105,61,49,44, +32,108,101,110,32,100,111,13,10,32,32,32,32,105,116,101,109,115,91,105, +93,32,61,32,105,116,101,109,73,110,102,111,91,105,93,46,105,116,101,109, +13,10,32,32,101,110,100,13,10,32,32,114,101,116,117,114,110,32,105,116, +101,109,115,44,32,108,101,110,13,10,101,110,100,13,10,13,10,102,117,110, +99,116,105,111,110,32,87,111,114,108,100,58,113,117,101,114,121,83,101,103, +109,101,110,116,87,105,116,104,67,111,111,114,100,115,40,120,49,44,32,121, +49,44,32,120,50,44,32,121,50,44,32,102,105,108,116,101,114,41,13,10, +32,32,108,111,99,97,108,32,105,116,101,109,73,110,102,111,44,32,108,101, +110,32,61,32,103,101,116,73,110,102,111,65,98,111,117,116,73,116,101,109, +115,84,111,117,99,104,101,100,66,121,83,101,103,109,101,110,116,40,115,101, +108,102,44,32,120,49,44,32,121,49,44,32,120,50,44,32,121,50,44,32, +102,105,108,116,101,114,41,13,10,32,32,108,111,99,97,108,32,100,120,44, +32,100,121,32,32,32,32,32,32,32,32,61,32,120,50,45,120,49,44,32, +121,50,45,121,49,13,10,32,32,108,111,99,97,108,32,105,110,102,111,44, +32,116,105,49,44,32,116,105,50,13,10,32,32,102,111,114,32,105,61,49, +44,32,108,101,110,32,100,111,13,10,32,32,32,32,105,110,102,111,32,32, +61,32,105,116,101,109,73,110,102,111,91,105,93,13,10,32,32,32,32,116, +105,49,32,32,32,61,32,105,110,102,111,46,116,105,49,13,10,32,32,32, +32,116,105,50,32,32,32,61,32,105,110,102,111,46,116,105,50,13,10,13, +10,32,32,32,32,105,110,102,111,46,119,101,105,103,104,116,32,32,61,32, +110,105,108,13,10,32,32,32,32,105,110,102,111,46,120,49,32,32,32,32, +32,32,61,32,120,49,32,43,32,100,120,32,42,32,116,105,49,13,10,32, +32,32,32,105,110,102,111,46,121,49,32,32,32,32,32,32,61,32,121,49, +32,43,32,100,121,32,42,32,116,105,49,13,10,32,32,32,32,105,110,102, +111,46,120,50,32,32,32,32,32,32,61,32,120,49,32,43,32,100,120,32, +42,32,116,105,50,13,10,32,32,32,32,105,110,102,111,46,121,50,32,32, +32,32,32,32,61,32,121,49,32,43,32,100,121,32,42,32,116,105,50,13, +10,32,32,101,110,100,13,10,32,32,114,101,116,117,114,110,32,105,116,101, +109,73,110,102,111,44,32,108,101,110,13,10,101,110,100,13,10,13,10,13, +10,45,45,45,32,77,97,105,110,32,109,101,116,104,111,100,115,13,10,13, +10,102,117,110,99,116,105,111,110,32,87,111,114,108,100,58,97,100,100,40, +105,116,101,109,44,32,120,44,121,44,119,44,104,41,13,10,32,32,108,111, +99,97,108,32,114,101,99,116,32,61,32,115,101,108,102,46,114,101,99,116, +115,91,105,116,101,109,93,13,10,32,32,105,102,32,114,101,99,116,32,116, +104,101,110,13,10,32,32,32,32,101,114,114,111,114,40,39,73,116,101,109, +32,39,32,46,46,32,116,111,115,116,114,105,110,103,40,105,116,101,109,41, +32,46,46,32,39,32,97,100,100,101,100,32,116,111,32,116,104,101,32,119, +111,114,108,100,32,116,119,105,99,101,46,39,41,13,10,32,32,101,110,100, +13,10,32,32,97,115,115,101,114,116,73,115,82,101,99,116,40,120,44,121, +44,119,44,104,41,13,10,13,10,32,32,115,101,108,102,46,114,101,99,116, +115,91,105,116,101,109,93,32,61,32,123,120,61,120,44,121,61,121,44,119, +61,119,44,104,61,104,125,13,10,13,10,32,32,108,111,99,97,108,32,99, +108,44,99,116,44,99,119,44,99,104,32,61,32,103,114,105,100,95,116,111, +67,101,108,108,82,101,99,116,40,115,101,108,102,46,99,101,108,108,83,105, +122,101,44,32,120,44,121,44,119,44,104,41,13,10,32,32,102,111,114,32, +99,121,32,61,32,99,116,44,32,99,116,43,99,104,45,49,32,100,111,13, +10,32,32,32,32,102,111,114,32,99,120,32,61,32,99,108,44,32,99,108, +43,99,119,45,49,32,100,111,13,10,32,32,32,32,32,32,97,100,100,73, +116,101,109,84,111,67,101,108,108,40,115,101,108,102,44,32,105,116,101,109, +44,32,99,120,44,32,99,121,41,13,10,32,32,32,32,101,110,100,13,10, +32,32,101,110,100,13,10,13,10,32,32,114,101,116,117,114,110,32,105,116, +101,109,13,10,101,110,100,13,10,13,10,102,117,110,99,116,105,111,110,32, +87,111,114,108,100,58,114,101,109,111,118,101,40,105,116,101,109,41,13,10, +32,32,108,111,99,97,108,32,120,44,121,44,119,44,104,32,61,32,115,101, +108,102,58,103,101,116,82,101,99,116,40,105,116,101,109,41,13,10,13,10, +32,32,115,101,108,102,46,114,101,99,116,115,91,105,116,101,109,93,32,61, +32,110,105,108,13,10,32,32,108,111,99,97,108,32,99,108,44,99,116,44, +99,119,44,99,104,32,61,32,103,114,105,100,95,116,111,67,101,108,108,82, +101,99,116,40,115,101,108,102,46,99,101,108,108,83,105,122,101,44,32,120, +44,121,44,119,44,104,41,13,10,32,32,102,111,114,32,99,121,32,61,32, +99,116,44,32,99,116,43,99,104,45,49,32,100,111,13,10,32,32,32,32, +102,111,114,32,99,120,32,61,32,99,108,44,32,99,108,43,99,119,45,49, +32,100,111,13,10,32,32,32,32,32,32,114,101,109,111,118,101,73,116,101, +109,70,114,111,109,67,101,108,108,40,115,101,108,102,44,32,105,116,101,109, +44,32,99,120,44,32,99,121,41,13,10,32,32,32,32,101,110,100,13,10, +32,32,101,110,100,13,10,101,110,100,13,10,13,10,102,117,110,99,116,105, +111,110,32,87,111,114,108,100,58,117,112,100,97,116,101,40,105,116,101,109, +44,32,120,50,44,121,50,44,119,50,44,104,50,41,13,10,32,32,108,111, +99,97,108,32,120,49,44,121,49,44,119,49,44,104,49,32,61,32,115,101, +108,102,58,103,101,116,82,101,99,116,40,105,116,101,109,41,13,10,32,32, +119,50,44,104,50,32,61,32,119,50,32,111,114,32,119,49,44,32,104,50, +32,111,114,32,104,49,13,10,32,32,97,115,115,101,114,116,73,115,82,101, +99,116,40,120,50,44,121,50,44,119,50,44,104,50,41,13,10,13,10,32, +32,105,102,32,120,49,32,126,61,32,120,50,32,111,114,32,121,49,32,126, +61,32,121,50,32,111,114,32,119,49,32,126,61,32,119,50,32,111,114,32, +104,49,32,126,61,32,104,50,32,116,104,101,110,13,10,13,10,32,32,32, +32,108,111,99,97,108,32,99,101,108,108,83,105,122,101,32,61,32,115,101, +108,102,46,99,101,108,108,83,105,122,101,13,10,32,32,32,32,108,111,99, +97,108,32,99,108,49,44,99,116,49,44,99,119,49,44,99,104,49,32,61, +32,103,114,105,100,95,116,111,67,101,108,108,82,101,99,116,40,99,101,108, +108,83,105,122,101,44,32,120,49,44,121,49,44,119,49,44,104,49,41,13, +10,32,32,32,32,108,111,99,97,108,32,99,108,50,44,99,116,50,44,99, +119,50,44,99,104,50,32,61,32,103,114,105,100,95,116,111,67,101,108,108, +82,101,99,116,40,99,101,108,108,83,105,122,101,44,32,120,50,44,121,50, +44,119,50,44,104,50,41,13,10,13,10,32,32,32,32,105,102,32,99,108, +49,32,126,61,32,99,108,50,32,111,114,32,99,116,49,32,126,61,32,99, +116,50,32,111,114,32,99,119,49,32,126,61,32,99,119,50,32,111,114,32, +99,104,49,32,126,61,32,99,104,50,32,116,104,101,110,13,10,13,10,32, +32,32,32,32,32,108,111,99,97,108,32,99,114,49,44,32,99,98,49,32, +61,32,99,108,49,43,99,119,49,45,49,44,32,99,116,49,43,99,104,49, +45,49,13,10,32,32,32,32,32,32,108,111,99,97,108,32,99,114,50,44, +32,99,98,50,32,61,32,99,108,50,43,99,119,50,45,49,44,32,99,116, +50,43,99,104,50,45,49,13,10,32,32,32,32,32,32,108,111,99,97,108, +32,99,121,79,117,116,13,10,13,10,32,32,32,32,32,32,102,111,114,32, +99,121,32,61,32,99,116,49,44,32,99,98,49,32,100,111,13,10,32,32, +32,32,32,32,32,32,99,121,79,117,116,32,61,32,99,121,32,60,32,99, +116,50,32,111,114,32,99,121,32,62,32,99,98,50,13,10,32,32,32,32, +32,32,32,32,102,111,114,32,99,120,32,61,32,99,108,49,44,32,99,114, +49,32,100,111,13,10,32,32,32,32,32,32,32,32,32,32,105,102,32,99, +121,79,117,116,32,111,114,32,99,120,32,60,32,99,108,50,32,111,114,32, +99,120,32,62,32,99,114,50,32,116,104,101,110,13,10,32,32,32,32,32, +32,32,32,32,32,32,32,114,101,109,111,118,101,73,116,101,109,70,114,111, +109,67,101,108,108,40,115,101,108,102,44,32,105,116,101,109,44,32,99,120, +44,32,99,121,41,13,10,32,32,32,32,32,32,32,32,32,32,101,110,100, +13,10,32,32,32,32,32,32,32,32,101,110,100,13,10,32,32,32,32,32, +32,101,110,100,13,10,13,10,32,32,32,32,32,32,102,111,114,32,99,121, +32,61,32,99,116,50,44,32,99,98,50,32,100,111,13,10,32,32,32,32, +32,32,32,32,99,121,79,117,116,32,61,32,99,121,32,60,32,99,116,49, +32,111,114,32,99,121,32,62,32,99,98,49,13,10,32,32,32,32,32,32, +32,32,102,111,114,32,99,120,32,61,32,99,108,50,44,32,99,114,50,32, +100,111,13,10,32,32,32,32,32,32,32,32,32,32,105,102,32,99,121,79, +117,116,32,111,114,32,99,120,32,60,32,99,108,49,32,111,114,32,99,120, +32,62,32,99,114,49,32,116,104,101,110,13,10,32,32,32,32,32,32,32, +32,32,32,32,32,97,100,100,73,116,101,109,84,111,67,101,108,108,40,115, +101,108,102,44,32,105,116,101,109,44,32,99,120,44,32,99,121,41,13,10, +32,32,32,32,32,32,32,32,32,32,101,110,100,13,10,32,32,32,32,32, +32,32,32,101,110,100,13,10,32,32,32,32,32,32,101,110,100,13,10,13, +10,32,32,32,32,101,110,100,13,10,13,10,32,32,32,32,108,111,99,97, +108,32,114,101,99,116,32,61,32,115,101,108,102,46,114,101,99,116,115,91, +105,116,101,109,93,13,10,32,32,32,32,114,101,99,116,46,120,44,32,114, +101,99,116,46,121,44,32,114,101,99,116,46,119,44,32,114,101,99,116,46, +104,32,61,32,120,50,44,121,50,44,119,50,44,104,50,13,10,13,10,32, +32,101,110,100,13,10,101,110,100,13,10,13,10,102,117,110,99,116,105,111, +110,32,87,111,114,108,100,58,109,111,118,101,40,105,116,101,109,44,32,103, +111,97,108,88,44,32,103,111,97,108,89,44,32,102,105,108,116,101,114,41, +13,10,32,32,108,111,99,97,108,32,97,99,116,117,97,108,88,44,32,97, +99,116,117,97,108,89,44,32,99,111,108,115,44,32,108,101,110,32,61,32, +115,101,108,102,58,99,104,101,99,107,40,105,116,101,109,44,32,103,111,97, +108,88,44,32,103,111,97,108,89,44,32,102,105,108,116,101,114,41,13,10, +13,10,32,32,115,101,108,102,58,117,112,100,97,116,101,40,105,116,101,109, +44,32,97,99,116,117,97,108,88,44,32,97,99,116,117,97,108,89,41,13, +10,13,10,32,32,114,101,116,117,114,110,32,97,99,116,117,97,108,88,44, +32,97,99,116,117,97,108,89,44,32,99,111,108,115,44,32,108,101,110,13, +10,101,110,100,13,10,13,10,102,117,110,99,116,105,111,110,32,87,111,114, +108,100,58,99,104,101,99,107,40,105,116,101,109,44,32,103,111,97,108,88, +44,32,103,111,97,108,89,44,32,102,105,108,116,101,114,41,13,10,32,32, +102,105,108,116,101,114,32,61,32,102,105,108,116,101,114,32,111,114,32,100, +101,102,97,117,108,116,70,105,108,116,101,114,13,10,13,10,32,32,108,111, +99,97,108,32,118,105,115,105,116,101,100,32,61,32,123,91,105,116,101,109, +93,32,61,32,116,114,117,101,125,13,10,32,32,108,111,99,97,108,32,118, +105,115,105,116,101,100,70,105,108,116,101,114,32,61,32,102,117,110,99,116, +105,111,110,40,105,116,109,44,32,111,116,104,101,114,41,13,10,32,32,32, 32,105,102,32,118,105,115,105,116,101,100,91,111,116,104,101,114,93,32,116, 104,101,110,32,114,101,116,117,114,110,32,102,97,108,115,101,32,101,110,100, -10,32,32,32,32,114,101,116,117,114,110,32,102,105,108,116,101,114,40,105, -116,109,44,32,111,116,104,101,114,41,10,32,32,101,110,100,10,10,32,32, -108,111,99,97,108,32,99,111,108,115,44,32,108,101,110,32,61,32,123,125, -44,32,48,10,10,32,32,108,111,99,97,108,32,120,44,121,44,119,44,104, -32,61,32,115,101,108,102,58,103,101,116,82,101,99,116,40,105,116,101,109, -41,10,10,32,32,108,111,99,97,108,32,112,114,111,106,101,99,116,101,100, -95,99,111,108,115,44,32,112,114,111,106,101,99,116,101,100,95,108,101,110, -32,61,32,115,101,108,102,58,112,114,111,106,101,99,116,40,105,116,101,109, -44,32,120,44,121,44,119,44,104,44,32,103,111,97,108,88,44,103,111,97, -108,89,44,32,118,105,115,105,116,101,100,70,105,108,116,101,114,41,10,10, -32,32,119,104,105,108,101,32,112,114,111,106,101,99,116,101,100,95,108,101, -110,32,62,32,48,32,100,111,10,32,32,32,32,108,111,99,97,108,32,99, -111,108,32,61,32,112,114,111,106,101,99,116,101,100,95,99,111,108,115,91, -49,93,10,32,32,32,32,108,101,110,32,32,32,32,32,32,32,61,32,108, -101,110,32,43,32,49,10,32,32,32,32,99,111,108,115,91,108,101,110,93, -32,61,32,99,111,108,10,10,32,32,32,32,118,105,115,105,116,101,100,91, -99,111,108,46,111,116,104,101,114,93,32,61,32,116,114,117,101,10,10,32, -32,32,32,108,111,99,97,108,32,114,101,115,112,111,110,115,101,32,61,32, -103,101,116,82,101,115,112,111,110,115,101,66,121,78,97,109,101,40,115,101, -108,102,44,32,99,111,108,46,116,121,112,101,41,10,10,32,32,32,32,103, -111,97,108,88,44,32,103,111,97,108,89,44,32,112,114,111,106,101,99,116, -101,100,95,99,111,108,115,44,32,112,114,111,106,101,99,116,101,100,95,108, -101,110,32,61,32,114,101,115,112,111,110,115,101,40,10,32,32,32,32,32, -32,115,101,108,102,44,10,32,32,32,32,32,32,99,111,108,44,10,32,32, -32,32,32,32,120,44,32,121,44,32,119,44,32,104,44,10,32,32,32,32, -32,32,103,111,97,108,88,44,32,103,111,97,108,89,44,10,32,32,32,32, -32,32,118,105,115,105,116,101,100,70,105,108,116,101,114,10,32,32,32,32, -41,10,32,32,101,110,100,10,10,32,32,114,101,116,117,114,110,32,103,111, -97,108,88,44,32,103,111,97,108,89,44,32,99,111,108,115,44,32,108,101, -110,10,101,110,100,10,10,10,45,45,32,80,117,98,108,105,99,32,108,105, -98,114,97,114,121,32,102,117,110,99,116,105,111,110,115,10,10,98,117,109, -112,46,110,101,119,87,111,114,108,100,32,61,32,102,117,110,99,116,105,111, -110,40,99,101,108,108,83,105,122,101,41,10,32,32,99,101,108,108,83,105, -122,101,32,61,32,99,101,108,108,83,105,122,101,32,111,114,32,54,52,10, -32,32,97,115,115,101,114,116,73,115,80,111,115,105,116,105,118,101,78,117, -109,98,101,114,40,99,101,108,108,83,105,122,101,44,32,39,99,101,108,108, -83,105,122,101,39,41,10,32,32,108,111,99,97,108,32,119,111,114,108,100, -32,61,32,115,101,116,109,101,116,97,116,97,98,108,101,40,123,10,32,32, -32,32,99,101,108,108,83,105,122,101,32,32,32,32,32,32,32,61,32,99, -101,108,108,83,105,122,101,44,10,32,32,32,32,114,101,99,116,115,32,32, -32,32,32,32,32,32,32,32,61,32,123,125,44,10,32,32,32,32,114,111, -119,115,32,32,32,32,32,32,32,32,32,32,32,61,32,123,125,44,10,32, -32,32,32,110,111,110,69,109,112,116,121,67,101,108,108,115,32,32,61,32, -123,125,44,10,32,32,32,32,114,101,115,112,111,110,115,101,115,32,61,32, -123,125,10,32,32,125,44,32,87,111,114,108,100,95,109,116,41,10,10,32, -32,119,111,114,108,100,58,97,100,100,82,101,115,112,111,110,115,101,40,39, -116,111,117,99,104,39,44,32,116,111,117,99,104,41,10,32,32,119,111,114, -108,100,58,97,100,100,82,101,115,112,111,110,115,101,40,39,99,114,111,115, -115,39,44,32,99,114,111,115,115,41,10,32,32,119,111,114,108,100,58,97, -100,100,82,101,115,112,111,110,115,101,40,39,115,108,105,100,101,39,44,32, -115,108,105,100,101,41,10,32,32,119,111,114,108,100,58,97,100,100,82,101, -115,112,111,110,115,101,40,39,98,111,117,110,99,101,39,44,32,98,111,117, -110,99,101,41,10,10,32,32,114,101,116,117,114,110,32,119,111,114,108,100, -10,101,110,100,10,10,98,117,109,112,46,114,101,99,116,32,61,32,123,10, -32,32,103,101,116,78,101,97,114,101,115,116,67,111,114,110,101,114,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,61,32,114,101,99,116,95,103, -101,116,78,101,97,114,101,115,116,67,111,114,110,101,114,44,10,32,32,103, -101,116,83,101,103,109,101,110,116,73,110,116,101,114,115,101,99,116,105,111, -110,73,110,100,105,99,101,115,32,61,32,114,101,99,116,95,103,101,116,83, -101,103,109,101,110,116,73,110,116,101,114,115,101,99,116,105,111,110,73,110, -100,105,99,101,115,44,10,32,32,103,101,116,68,105,102,102,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,61, -32,114,101,99,116,95,103,101,116,68,105,102,102,44,10,32,32,99,111,110, -116,97,105,110,115,80,111,105,110,116,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,61,32,114,101,99,116,95,99,111,110,116,97,105, -110,115,80,111,105,110,116,44,10,32,32,105,115,73,110,116,101,114,115,101, -99,116,105,110,103,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,61,32,114,101,99,116,95,105,115,73,110,116,101,114,115,101,99,116,105, -110,103,44,10,32,32,103,101,116,83,113,117,97,114,101,68,105,115,116,97, -110,99,101,32,32,32,32,32,32,32,32,32,32,32,32,32,61,32,114,101, -99,116,95,103,101,116,83,113,117,97,114,101,68,105,115,116,97,110,99,101, -44,10,32,32,100,101,116,101,99,116,67,111,108,108,105,115,105,111,110,32, +13,10,32,32,32,32,114,101,116,117,114,110,32,102,105,108,116,101,114,40, +105,116,109,44,32,111,116,104,101,114,41,13,10,32,32,101,110,100,13,10, +13,10,32,32,108,111,99,97,108,32,99,111,108,115,44,32,108,101,110,32, +61,32,123,125,44,32,48,13,10,13,10,32,32,108,111,99,97,108,32,120, +44,121,44,119,44,104,32,61,32,115,101,108,102,58,103,101,116,82,101,99, +116,40,105,116,101,109,41,13,10,13,10,32,32,108,111,99,97,108,32,112, +114,111,106,101,99,116,101,100,95,99,111,108,115,44,32,112,114,111,106,101, +99,116,101,100,95,108,101,110,32,61,32,115,101,108,102,58,112,114,111,106, +101,99,116,40,105,116,101,109,44,32,120,44,121,44,119,44,104,44,32,103, +111,97,108,88,44,103,111,97,108,89,44,32,118,105,115,105,116,101,100,70, +105,108,116,101,114,41,13,10,13,10,32,32,119,104,105,108,101,32,112,114, +111,106,101,99,116,101,100,95,108,101,110,32,62,32,48,32,100,111,13,10, +32,32,32,32,108,111,99,97,108,32,99,111,108,32,61,32,112,114,111,106, +101,99,116,101,100,95,99,111,108,115,91,49,93,13,10,32,32,32,32,108, +101,110,32,32,32,32,32,32,32,61,32,108,101,110,32,43,32,49,13,10, +32,32,32,32,99,111,108,115,91,108,101,110,93,32,61,32,99,111,108,13, +10,13,10,32,32,32,32,118,105,115,105,116,101,100,91,99,111,108,46,111, +116,104,101,114,93,32,61,32,116,114,117,101,13,10,13,10,32,32,32,32, +108,111,99,97,108,32,114,101,115,112,111,110,115,101,32,61,32,103,101,116, +82,101,115,112,111,110,115,101,66,121,78,97,109,101,40,115,101,108,102,44, +32,99,111,108,46,116,121,112,101,41,13,10,13,10,32,32,32,32,103,111, +97,108,88,44,32,103,111,97,108,89,44,32,112,114,111,106,101,99,116,101, +100,95,99,111,108,115,44,32,112,114,111,106,101,99,116,101,100,95,108,101, +110,32,61,32,114,101,115,112,111,110,115,101,40,13,10,32,32,32,32,32, +32,115,101,108,102,44,13,10,32,32,32,32,32,32,99,111,108,44,13,10, +32,32,32,32,32,32,120,44,32,121,44,32,119,44,32,104,44,13,10,32, +32,32,32,32,32,103,111,97,108,88,44,32,103,111,97,108,89,44,13,10, +32,32,32,32,32,32,118,105,115,105,116,101,100,70,105,108,116,101,114,13, +10,32,32,32,32,41,13,10,32,32,101,110,100,13,10,13,10,32,32,114, +101,116,117,114,110,32,103,111,97,108,88,44,32,103,111,97,108,89,44,32, +99,111,108,115,44,32,108,101,110,13,10,101,110,100,13,10,13,10,13,10, +45,45,32,80,117,98,108,105,99,32,108,105,98,114,97,114,121,32,102,117, +110,99,116,105,111,110,115,13,10,13,10,98,117,109,112,46,110,101,119,87, +111,114,108,100,32,61,32,102,117,110,99,116,105,111,110,40,99,101,108,108, +83,105,122,101,41,13,10,32,32,99,101,108,108,83,105,122,101,32,61,32, +99,101,108,108,83,105,122,101,32,111,114,32,54,52,13,10,32,32,97,115, +115,101,114,116,73,115,80,111,115,105,116,105,118,101,78,117,109,98,101,114, +40,99,101,108,108,83,105,122,101,44,32,39,99,101,108,108,83,105,122,101, +39,41,13,10,32,32,108,111,99,97,108,32,119,111,114,108,100,32,61,32, +115,101,116,109,101,116,97,116,97,98,108,101,40,123,13,10,32,32,32,32, +99,101,108,108,83,105,122,101,32,32,32,32,32,32,32,61,32,99,101,108, +108,83,105,122,101,44,13,10,32,32,32,32,114,101,99,116,115,32,32,32, +32,32,32,32,32,32,32,61,32,123,125,44,13,10,32,32,32,32,114,111, +119,115,32,32,32,32,32,32,32,32,32,32,32,61,32,123,125,44,13,10, +32,32,32,32,110,111,110,69,109,112,116,121,67,101,108,108,115,32,32,61, +32,123,125,44,13,10,32,32,32,32,114,101,115,112,111,110,115,101,115,32, +61,32,123,125,13,10,32,32,125,44,32,87,111,114,108,100,95,109,116,41, +13,10,13,10,32,32,119,111,114,108,100,58,97,100,100,82,101,115,112,111, +110,115,101,40,39,116,111,117,99,104,39,44,32,116,111,117,99,104,41,13, +10,32,32,119,111,114,108,100,58,97,100,100,82,101,115,112,111,110,115,101, +40,39,99,114,111,115,115,39,44,32,99,114,111,115,115,41,13,10,32,32, +119,111,114,108,100,58,97,100,100,82,101,115,112,111,110,115,101,40,39,115, +108,105,100,101,39,44,32,115,108,105,100,101,41,13,10,32,32,119,111,114, +108,100,58,97,100,100,82,101,115,112,111,110,115,101,40,39,98,111,117,110, +99,101,39,44,32,98,111,117,110,99,101,41,13,10,13,10,32,32,114,101, +116,117,114,110,32,119,111,114,108,100,13,10,101,110,100,13,10,13,10,98, +117,109,112,46,114,101,99,116,32,61,32,123,13,10,32,32,103,101,116,78, +101,97,114,101,115,116,67,111,114,110,101,114,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,61,32,114,101,99,116,95,103,101,116,78,101,97,114, +101,115,116,67,111,114,110,101,114,44,13,10,32,32,103,101,116,83,101,103, +109,101,110,116,73,110,116,101,114,115,101,99,116,105,111,110,73,110,100,105, +99,101,115,32,61,32,114,101,99,116,95,103,101,116,83,101,103,109,101,110, +116,73,110,116,101,114,115,101,99,116,105,111,110,73,110,100,105,99,101,115, +44,13,10,32,32,103,101,116,68,105,102,102,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,61,32,114,101,99, +116,95,103,101,116,68,105,102,102,44,13,10,32,32,99,111,110,116,97,105, +110,115,80,111,105,110,116,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,61,32,114,101,99,116,95,99,111,110,116,97,105,110,115,80, +111,105,110,116,44,13,10,32,32,105,115,73,110,116,101,114,115,101,99,116, +105,110,103,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,61, +32,114,101,99,116,95,105,115,73,110,116,101,114,115,101,99,116,105,110,103, +44,13,10,32,32,103,101,116,83,113,117,97,114,101,68,105,115,116,97,110, +99,101,32,32,32,32,32,32,32,32,32,32,32,32,32,61,32,114,101,99, +116,95,103,101,116,83,113,117,97,114,101,68,105,115,116,97,110,99,101,44, +13,10,32,32,100,101,116,101,99,116,67,111,108,108,105,115,105,111,110,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,61,32,114,101,99,116, -95,100,101,116,101,99,116,67,111,108,108,105,115,105,111,110,10,125,10,10, -98,117,109,112,46,114,101,115,112,111,110,115,101,115,32,61,32,123,10,32, -32,116,111,117,99,104,32,32,61,32,116,111,117,99,104,44,10,32,32,99, -114,111,115,115,32,32,61,32,99,114,111,115,115,44,10,32,32,115,108,105, -100,101,32,32,61,32,115,108,105,100,101,44,10,32,32,98,111,117,110,99, -101,32,61,32,98,111,117,110,99,101,10,125,10,10,45,45,45,45,45,45, -45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, +95,100,101,116,101,99,116,67,111,108,108,105,115,105,111,110,13,10,125,13, +10,13,10,98,117,109,112,46,114,101,115,112,111,110,115,101,115,32,61,32, +123,13,10,32,32,116,111,117,99,104,32,32,61,32,116,111,117,99,104,44, +13,10,32,32,99,114,111,115,115,32,32,61,32,99,114,111,115,115,44,13, +10,32,32,115,108,105,100,101,32,32,61,32,115,108,105,100,101,44,13,10, +32,32,98,111,117,110,99,101,32,61,32,98,111,117,110,99,101,13,10,125, +13,10,13,10,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,45,45,45,45,45,45,45,10,45,45,32,69,120,112,111,114,116,32,116, -111,32,74,105,110,46,32,10,45,45,45,45,45,45,45,45,45,45,45,45, +45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,13,10, +45,45,32,69,120,112,111,114,116,32,116,111,32,74,105,110,46,32,13,10, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,45,10,10,106,105,110,46,112,104,121,115,105,99,115,32,61,32,98,117, -109,112,10,0 +45,45,45,45,45,45,45,45,45,45,45,45,45,45,13,10,13,10,106,105, +110,46,112,104,121,115,105,99,115,32,61,32,98,117,109,112,13,10,0 }; diff --git a/src/libjin/graphics/gl.cpp b/src/libjin/graphics/gl.cpp index a5d1043..b90a29b 100644 --- a/src/libjin/graphics/gl.cpp +++ b/src/libjin/graphics/gl.cpp @@ -37,7 +37,7 @@ namespace JinEngine { } - bool OpenGL::initContext() + bool OpenGL::loadGL() { // Init glad library. if (!gladLoadGLLoader(SDL_GL_GetProcAddress)) diff --git a/src/libjin/graphics/gl.h b/src/libjin/graphics/gl.h index 7876ffd..e97ebb6 100644 --- a/src/libjin/graphics/gl.h +++ b/src/libjin/graphics/gl.h @@ -56,7 +56,7 @@ namespace JinEngine OpenGL(); ~OpenGL(); - bool initContext(); + bool loadGL(); void init(); diff --git a/src/libjin/graphics/window.cpp b/src/libjin/graphics/window.cpp index 5701772..6171c9d 100644 --- a/src/libjin/graphics/window.cpp +++ b/src/libjin/graphics/window.cpp @@ -86,7 +86,7 @@ namespace JinEngine if (ctx == NULL) return false; - gl.initContext(); + gl.loadGL(); SDL_GL_SetSwapInterval(vsync ? 1 : 0); SDL_GL_MakeCurrent(mWnd, ctx); -- cgit v1.1-26-g67d0