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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/*!A cross-platform build utility based on Lua
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright (C) 2015-present, TBOOX Open Source Group.
*
* @author ruki
* @file engine.h
*
*/
#ifndef XM_ENGINE_H
#define XM_ENGINE_H
/* //////////////////////////////////////////////////////////////////////////////////////
* includes
*/
#include "prefix.h"
/* //////////////////////////////////////////////////////////////////////////////////////
* extern
*/
__tb_extern_c_enter__
/* //////////////////////////////////////////////////////////////////////////////////////
* types
*/
/// the xmake engine type
typedef struct {tb_int_t dummy;} const* xm_engine_ref_t;
/// the lni initializer callback type
typedef tb_void_t (*xm_engine_lni_initalizer_cb_t)(xm_engine_ref_t engine, lua_State* lua);
/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
*/
/*! init the engine
*
* @param name the engine name
* @param lni_initalizer the lni initializer
*
* @return the engine
*/
xm_engine_ref_t xm_engine_init(tb_char_t const* name, xm_engine_lni_initalizer_cb_t lni_initalizer);
/*! exit the engine
*
* @param engine the engine
*/
tb_void_t xm_engine_exit(xm_engine_ref_t engine);
/*! do the main entry of the engine
*
* @param engine the engine
* @param argc the argument count of the console
* @param argv the argument list of the console
* @param taskargv the argument list of sub-task, e.g. taskargv(lua -vD lua.main) for xmake lua -vD lua.main arg1 arg2 ..
*
* @return the error code of main()
*/
tb_int_t xm_engine_main(xm_engine_ref_t engine, tb_int_t argc, tb_char_t** argv, tb_char_t** taskargv);
/*! register lni modules in the engine, @note we need to call it in lni_initalizer()
*
* @param engine the engine
* @param module the lni module name
* @param funcs the lni module functions
*/
tb_void_t xm_engine_register(xm_engine_ref_t engine, tb_char_t const* module, luaL_Reg const funcs[]);
/*! add the embed files
*
* @param name the engine name
* @param data the embedfiles data
* @param size the data size
*/
tb_void_t xm_engine_add_embedfiles(xm_engine_ref_t engine, tb_byte_t const* data, tb_size_t size);
/*! run main entry of the engine singleton
*
* @param name the engine name
* @param argc the argument count of the console
* @param argv the argument list of the console
* @param taskargv the argument list of sub-task, e.g. taskargv(lua -vD lua.main) for xmake lua -vD lua.main arg1 arg2 ..
* @param lni_initalizer the lni initializer
*
* @return the error code of main()
*/
tb_int_t xm_engine_run(tb_char_t const* name, tb_int_t argc, tb_char_t** argv, tb_char_t** taskargv, xm_engine_lni_initalizer_cb_t lni_initalizer);
/* //////////////////////////////////////////////////////////////////////////////////////
* extern
*/
__tb_extern_c_leave__
#endif
|