<NME> api_application.c
<BEF> ADDFILE
<MSG> Application lua api

<DFF> @@ -0,0 +1,14 @@
+#include <cetech/luasystem/luasystem.h>
+
+#define API_NAME "Application"
+
+static int _application_quit(lua_State *l) {
+    void application_quit();
+
+    application_quit();
+    return 0;
+}
+
+void _register_lua_application_api() {
+    LUA.add_module_function(API_NAME, "quit", _application_quit);
+}
\ No newline at end of file

{'commit': 'diff --git a/CMakeLists.txt b/CMakeLists.txt\nindex c8a3361c4..9587f73a1 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -128,8 +128,10 @@ set(SOURCE_FILES\n         sources/celib/log/private/log_system.c\n \n         sources/cetech/luasystem/private/lua_system.c\n-        sources/cetech/luasystem/private/api_log.c\n-        sources/cetech/luasystem/private/api_keyboard.c\n+        sources/cetech/luasystem/private/api/api_keyboard.c\n+        sources/cetech/luasystem/private/api/api_log.c\n+        sources/cetech/luasystem/private/api/api_mouse.c\n+        sources/cetech/luasystem/private/api/api_application.c\n \n         sources/cetech/configsystem/private/config_system.c\n         sources/cetech/consoleserver/private/console_server.c\n@@ -148,6 +150,8 @@ set(SOURCE_FILES\n         sources/cetech/machine/private/sdl_machine.c\n         sources/cetech/input/private/keyboard.c\n         sources/cetech/input/private/mouse.c\n+\n+\n )\n \n ################################################################################\ndiff --git a/playground/src/playground/addexistingdialog.py b/playground/src/playground/addexistingdialog.py\nindex 0a1d1671c..be5749422 100644\n--- a/playground/src/playground/addexistingdialog.py\n+++ b/playground/src/playground/addexistingdialog.py\n@@ -15,7 +15,7 @@ class AddExistItemDialog(QDialog, Ui_Dialog):\n     def open_dir(self):\n         selected_dir = QFileDialog.getExistingDirectory(self, "Select Directory")\n \n-        if cetechproject.validate_project(selected_dir):\n+        if project.validate_project(selected_dir):\n             self.project_dir_edit.setText(selected_dir)\n \n     def done(self, r):\n@@ -25,7 +25,7 @@ class AddExistItemDialog(QDialog, Ui_Dialog):\n                                      QMessageBox.Yes, QMessageBox.Yes)\n                 return\n \n-            if not cetechproject.validate_project(self.project_dir_edit.text()):\n+            if not project.validate_project(self.project_dir_edit.text()):\n                 return\n             else:\n                 super(AddExistItemDialog, self).done(r)\ndiff --git a/sources/celib/log/tests/test_log.cc b/sources/celib/log/tests/test_log.cc\nindex f13c69e6b..08ba110ac 100644\n--- a/sources/celib/log/tests/test_log.cc\n+++ b/sources/celib/log/tests/test_log.cc\n@@ -26,14 +26,14 @@ static struct LogEntry {\n     char worker_id;\n } LastLogEntry;\n \n-#define NULL_ENTRY_INIT { \\\n+#define NULL_ENTRY_INIT (struct LogEntry) { \\\n         .level = LOG_ERROR, \\\n         .time = 0, \\\n         .worker_id = 0, \\\n         .where = 0, \\\n         .msg = 0, \\\n-        .data = 0, \\\n-};\n+        .data = 0 \\\n+}\n \n void test_handler(enum log_level level,\n                   time_t time,\ndiff --git a/sources/cetech/application/private/application.c b/sources/cetech/application/private/application.c\nindex 5af43fe35..4c56c214a 100644\n--- a/sources/cetech/application/private/application.c\n+++ b/sources/cetech/application/private/application.c\n@@ -31,22 +31,6 @@ static char _get_worker_id() {\n     return 0;\n }\n \n-//==============================================================================\n-// LUA inteface\n-//==============================================================================\n-#define LUA_MODULE_NAME "App"\n-\n-static int _application_quit(lua_State *l) {\n-    void application_quit();\n-\n-    application_quit();\n-    return 0;\n-}\n-\n-static void _register_lua_fce() {\n-    LUA.add_module_function(LUA_MODULE_NAME, "quit", _application_quit);\n-}\n-\n //==============================================================================\n // Interface\n //==============================================================================\n@@ -81,7 +65,6 @@ int application_init(int argc, char **argv) {\n     };\n \n     windowsys_init();\n-    _register_lua_fce();\n \n     return 1;\n }\n@@ -101,7 +84,7 @@ void application_shutdown() {\n     log_shutdown();\n }\n \n-void dump_event() {\n+static void _dump_event() {\n     struct event_header *event = machine_event_begin();\n \n     u32 size = 0;\n@@ -134,7 +117,6 @@ void dump_event() {\n         }\n         event = machine_event_next(event);\n     }\n-\n }\n \n void application_start() {\n@@ -149,7 +131,7 @@ void application_start() {\n     _G.is_running = 1;\n     while (_G.is_running) {\n         machine_begin_frame();\n-        dump_event();\n+        _dump_event();\n \n         keyboard_process();\n         mouse_process();\ndiff --git a/sources/cetech/luasystem/private/api/api_application.c b/sources/cetech/luasystem/private/api/api_application.c\nnew file mode 100644\nindex 000000000..511e1b0c0\n--- /dev/null\n+++ b/sources/cetech/luasystem/private/api/api_application.c\n@@ -0,0 +1,14 @@\n+#include <cetech/luasystem/luasystem.h>\n+\n+#define API_NAME "Application"\n+\n+static int _application_quit(lua_State *l) {\n+    void application_quit();\n+\n+    application_quit();\n+    return 0;\n+}\n+\n+void _register_lua_application_api() {\n+    LUA.add_module_function(API_NAME, "quit", _application_quit);\n+}\n\\ No newline at end of file\ndiff --git a/sources/cetech/luasystem/private/api_keyboard.c b/sources/cetech/luasystem/private/api/api_keyboard.c\nsimilarity index 100%\nrename from sources/cetech/luasystem/private/api_keyboard.c\nrename to sources/cetech/luasystem/private/api/api_keyboard.c\ndiff --git a/sources/cetech/luasystem/private/api_log.c b/sources/cetech/luasystem/private/api/api_log.c\nsimilarity index 100%\nrename from sources/cetech/luasystem/private/api_log.c\nrename to sources/cetech/luasystem/private/api/api_log.c\ndiff --git a/sources/cetech/luasystem/private/api_mouse.c b/sources/cetech/luasystem/private/api/api_mouse.c\nsimilarity index 100%\nrename from sources/cetech/luasystem/private/api_mouse.c\nrename to sources/cetech/luasystem/private/api/api_mouse.c\ndiff --git a/sources/cetech/luasystem/private/lua_system.c b/sources/cetech/luasystem/private/lua_system.c\nindex 431e38f5f..f14db5b2d 100644\n--- a/sources/cetech/luasystem/private/lua_system.c\n+++ b/sources/cetech/luasystem/private/lua_system.c\n@@ -220,6 +220,19 @@ static int _cmd_execute_string(mpack_node_t args, mpack_writer_t *writer) {\n }\n \n \n+#define REGISTER_LUA_API(name) \\\n+    void _register_lua_##name##_api();\\\n+    _register_lua_##name##_api();\n+\n+\n+static void _register_all_api() {\n+    REGISTER_LUA_API(log);\n+    REGISTER_LUA_API(keyboard);\n+    REGISTER_LUA_API(mouse);\n+    REGISTER_LUA_API(application);\n+\n+}\n+\n static void _init() {\n     log_info(LOG_WHERE, "Init");\n \n@@ -228,11 +241,7 @@ static void _init() {\n \n     luaL_openlibs(_G.L);\n \n-    void _register_lua_log_api();\n-    _register_lua_log_api();\n-\n-    void _register_lua_keyboard_api();\n-    _register_lua_keyboard_api();\n+    _register_all_api();\n \n     _add_module_function("plugin", "reload", _reload_plugin);\n \n', 'commit_subject': 'Application lua api', 'repo_name': 'cyberegoorg/cetech', 'committer': {'name': 'Ondra Voves', 'email': 'e27ffd790ea191cd6fa89fdd6959be50743b8fc0@gmail.com', 'time_sec': '1471459745', 'tz_offset': '120', 'date': {'seconds': '1471459745'}}, 'commit_tree': 'df99a6b84a0642e645edb9f1e5a15adcf81c81db', 'commit_message': 'Application lua api\n', 'language_name': 'Shell', 'license': 'cc0-1.0', 'hunks': '@@ -0,0 +1,14 @@\n+#include <cetech/luasystem/luasystem.h>\n+\n+#define API_NAME "Application"\n+\n+static int _application_quit(lua_State *l) {\n+    void application_quit();\n+\n+    application_quit();\n+    return 0;\n+}\n+\n+void _register_lua_application_api() {\n+    LUA.add_module_function(API_NAME, "quit", _application_quit);\n+}\n\\ No newline at end of file\n', 'addition_count': 14, 'deletion_count': 0, 'src_file': '/dev/null', 'tgt_file': 'b/sources/cetech/luasystem/private/api/api_application.c', 'file_extension': '.c', 'before_file': 'ADDFILE', 'message': 'Application lua api\n', 'author_name': 'Ondra Voves', 'lang': 'c'}