<NME> lua_resource.h
<BEF> ADDFILE
<MSG> ENGINE-153 - Reformat privates files - split luasys

<DFF> @@ -0,0 +1,57 @@
+#ifndef CETECH_LUA_RESOURCE_H
+#define CETECH_LUA_RESOURCE_H
+
+
+void *lua_resource_loader(struct vio *input,
+                          struct cel_allocator *allocator) {
+    const i64 size = cel_vio_size(input);
+    char *data = CEL_ALLOCATE(allocator, char, size);
+    cel_vio_read(input, data, 1, size);
+
+    return data;
+}
+
+void lua_resource_unloader(void *new_data,
+                           struct cel_allocator *allocator) {
+    CEL_DEALLOCATE(allocator, new_data);
+}
+
+void lua_resource_online(stringid64_t name,
+                         void *data) {
+}
+
+void lua_resource_offline(stringid64_t name,
+                          void *data) {
+
+}
+
+void *lua_resource_reloader(stringid64_t name,
+                            void *old_data,
+                            void *new_data,
+                            struct cel_allocator *allocator) {
+    CEL_DEALLOCATE(allocator, old_data);
+
+    struct lua_resource *resource = new_data;
+    char *data = (char *) (resource + 1);
+
+    luaL_loadbuffer(_G.L, data, resource->size, "<unknown>");
+
+    if (lua_pcall(_G.L, 0, 0, 0)) {
+        const char *last_error = lua_tostring(_G.L, -1);
+        lua_pop(_G.L, 1);
+        log_error(LOG_WHERE, "%s", last_error);
+    }
+
+    return new_data;
+}
+
+static const resource_callbacks_t lua_resource_callback = {
+        .loader = lua_resource_loader,
+        .unloader =lua_resource_unloader,
+        .online =lua_resource_online,
+        .offline =lua_resource_offline,
+        .reloader = lua_resource_reloader
+};
+
+
+#endif //CETECH_LUA_RESOURCE_H

{'commit': 'diff --git a/engine/sources/engine/luasys/private/lua_resource.h b/engine/sources/engine/luasys/private/lua_resource.h\nnew file mode 100644\nindex 000000000..c640c39c1\n--- /dev/null\n+++ b/engine/sources/engine/luasys/private/lua_resource.h\n@@ -0,0 +1,57 @@\n+#ifndef CETECH_LUA_RESOURCE_H\n+#define CETECH_LUA_RESOURCE_H\n+\n+\n+void *lua_resource_loader(struct vio *input,\n+                          struct cel_allocator *allocator) {\n+    const i64 size = cel_vio_size(input);\n+    char *data = CEL_ALLOCATE(allocator, char, size);\n+    cel_vio_read(input, data, 1, size);\n+\n+    return data;\n+}\n+\n+void lua_resource_unloader(void *new_data,\n+                           struct cel_allocator *allocator) {\n+    CEL_DEALLOCATE(allocator, new_data);\n+}\n+\n+void lua_resource_online(stringid64_t name,\n+                         void *data) {\n+}\n+\n+void lua_resource_offline(stringid64_t name,\n+                          void *data) {\n+\n+}\n+\n+void *lua_resource_reloader(stringid64_t name,\n+                            void *old_data,\n+                            void *new_data,\n+                            struct cel_allocator *allocator) {\n+    CEL_DEALLOCATE(allocator, old_data);\n+\n+    struct lua_resource *resource = new_data;\n+    char *data = (char *) (resource + 1);\n+\n+    luaL_loadbuffer(_G.L, data, resource->size, "<unknown>");\n+\n+    if (lua_pcall(_G.L, 0, 0, 0)) {\n+        const char *last_error = lua_tostring(_G.L, -1);\n+        lua_pop(_G.L, 1);\n+        log_error(LOG_WHERE, "%s", last_error);\n+    }\n+\n+    return new_data;\n+}\n+\n+static const resource_callbacks_t lua_resource_callback = {\n+        .loader = lua_resource_loader,\n+        .unloader =lua_resource_unloader,\n+        .online =lua_resource_online,\n+        .offline =lua_resource_offline,\n+        .reloader = lua_resource_reloader\n+};\n+\n+\n+#endif //CETECH_LUA_RESOURCE_H\ndiff --git a/engine/sources/engine/luasys/private/luasys.c b/engine/sources/engine/luasys/private/luasys.c\nindex e20523785..d45135dc4 100644\n--- a/engine/sources/engine/luasys/private/luasys.c\n+++ b/engine/sources/engine/luasys/private/luasys.c\n@@ -115,58 +115,7 @@ cel_quatf_t *_new_tmp_quat() {\n //==============================================================================\n // Lua resource\n //==============================================================================\n-\n-void *lua_resource_loader(struct vio *input,\n-                          struct cel_allocator *allocator) {\n-    const i64 size = cel_vio_size(input);\n-    char *data = CEL_ALLOCATE(allocator, char, size);\n-    cel_vio_read(input, data, 1, size);\n-\n-    return data;\n-}\n-\n-void lua_resource_unloader(void *new_data,\n-                           struct cel_allocator *allocator) {\n-    CEL_DEALLOCATE(allocator, new_data);\n-}\n-\n-void lua_resource_online(stringid64_t name,\n-                         void *data) {\n-}\n-\n-void lua_resource_offline(stringid64_t name,\n-                          void *data) {\n-\n-}\n-\n-void *lua_resource_reloader(stringid64_t name,\n-                            void *old_data,\n-                            void *new_data,\n-                            struct cel_allocator *allocator) {\n-    CEL_DEALLOCATE(allocator, old_data);\n-\n-    struct lua_resource *resource = new_data;\n-    char *data = (char *) (resource + 1);\n-\n-    luaL_loadbuffer(_G.L, data, resource->size, "<unknown>");\n-\n-    if (lua_pcall(_G.L, 0, 0, 0)) {\n-        const char *last_error = lua_tostring(_G.L, -1);\n-        lua_pop(_G.L, 1);\n-        log_error(LOG_WHERE, "%s", last_error);\n-    }\n-\n-    return new_data;\n-}\n-\n-static const resource_callbacks_t lua_resource_callback = {\n-        .loader = lua_resource_loader,\n-        .unloader =lua_resource_unloader,\n-        .online =lua_resource_online,\n-        .offline =lua_resource_offline,\n-        .reloader = lua_resource_reloader\n-};\n-\n+#include "lua_resource.h"\n \n //==============================================================================\n // Game\n', 'commit_subject': 'ENGINE-153 - Reformat privates files - split luasys', 'repo_name': 'cyberegoorg/cetech', 'committer': {'name': 'Ondra Voves', 'email': 'a6f730fbf1f3d74d6f3faf191093f4121e4ecc86@cyberego.org', 'time_sec': '1489953094', 'tz_offset': '60', 'date': {'seconds': '1489953094'}}, 'commit_tree': '6a358bb5e48d4a84e38daa4148dd6fb1bf615dd7', 'commit_message': 'ENGINE-153 - Reformat privates files - split luasys\n', 'language_name': 'Python', 'license': 'cc0-1.0', 'hunks': '@@ -0,0 +1,57 @@\n+#ifndef CETECH_LUA_RESOURCE_H\n+#define CETECH_LUA_RESOURCE_H\n+\n+\n+void *lua_resource_loader(struct vio *input,\n+                          struct cel_allocator *allocator) {\n+    const i64 size = cel_vio_size(input);\n+    char *data = CEL_ALLOCATE(allocator, char, size);\n+    cel_vio_read(input, data, 1, size);\n+\n+    return data;\n+}\n+\n+void lua_resource_unloader(void *new_data,\n+                           struct cel_allocator *allocator) {\n+    CEL_DEALLOCATE(allocator, new_data);\n+}\n+\n+void lua_resource_online(stringid64_t name,\n+                         void *data) {\n+}\n+\n+void lua_resource_offline(stringid64_t name,\n+                          void *data) {\n+\n+}\n+\n+void *lua_resource_reloader(stringid64_t name,\n+                            void *old_data,\n+                            void *new_data,\n+                            struct cel_allocator *allocator) {\n+    CEL_DEALLOCATE(allocator, old_data);\n+\n+    struct lua_resource *resource = new_data;\n+    char *data = (char *) (resource + 1);\n+\n+    luaL_loadbuffer(_G.L, data, resource->size, "<unknown>");\n+\n+    if (lua_pcall(_G.L, 0, 0, 0)) {\n+        const char *last_error = lua_tostring(_G.L, -1);\n+        lua_pop(_G.L, 1);\n+        log_error(LOG_WHERE, "%s", last_error);\n+    }\n+\n+    return new_data;\n+}\n+\n+static const resource_callbacks_t lua_resource_callback = {\n+        .loader = lua_resource_loader,\n+        .unloader =lua_resource_unloader,\n+        .online =lua_resource_online,\n+        .offline =lua_resource_offline,\n+        .reloader = lua_resource_reloader\n+};\n+\n+\n+#endif //CETECH_LUA_RESOURCE_H\n', 'addition_count': 57, 'deletion_count': 0, 'src_file': '/dev/null', 'tgt_file': 'b/engine/sources/engine/luasys/private/lua_resource.h', 'file_extension': '.h', 'before_file': 'ADDFILE', 'message': 'ENGINE-153 - Reformat privates files - split luasys\n', 'author_name': 'Ondra Voves', 'lang': 'h'}