aboutsummaryrefslogtreecommitdiff
path: root/src/lua/embed/embed.h
blob: b5e1334bb522346a708dfce839aaff4a344b20f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef __JIN_LUA_EMBED_H
#define __JIN_LUA_EMBED_H
#include <cstring>

namespace JinEngine
{
    namespace Embed
    {
    
        // Embed structure.
        struct jin_Embed
        {
            const char* file, *source;
        };

        // Embed scripts.
        #include "scripts/graphics.lua.h" 
        #include "scripts/keyboard.lua.h" 
        #include "scripts/mouse.lua.h"    
        #include "scripts/boot.lua.h"     

        // In order.
        static const jin_Embed modules[] = {
            { "graphics.lua", graphics_lua },
            { "keyboard.lua", keyboard_lua },
            { "mouse.lua",    mouse_lua    },
            { "boot.lua",     boot_lua     },
            { 0,              0            }
        };

        static void run(lua_State* L)
        {
            for (int i = 0; modules[i].file; ++i)
            {
                const char* file = modules[i].file, *source = modules[i].source;
                if (luax_loadbuffer(L, source, strlen(source), file) == 0)
                    lua_call(L, 0, 0);
            }
        }

    } // namespace Embed
} // namespace JinEngine 

#endif