-
Notifications
You must be signed in to change notification settings - Fork 0
/
hui_hulua.h
executable file
·105 lines (95 loc) · 2.02 KB
/
hui_hulua.h
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
#ifndef __HUI_HULUA_H__
#define __HUI_HULUA_H__
#include "hulib.h"
#include "hulua.h"
class LUA :public thread ,public Mutex
{
public:
class node
{
public:
node()
{
log_d("new node\n");
}
~node()
{
log_d("del node\n");
}
virtual void DO(lua_State * L)
{
}
};
class node_dofile :public node
{
public:
hustr m_file;
node_dofile(const char * file)
{
m_file = file;
}
void DO(lua_State * L)
{
log_i("lua dofile %s\n",m_file.nstr());
hulua::dofile(L, m_file);
log_i("lua dofile %s OK\n",m_file.nstr());
}
};
class node_dostring :public node
{
public:
hustr m_str;
node_dostring(const char * str)
{
m_str = str;
}
void DO(lua_State * L)
{
log_i("lua dostring %s\n",m_str.nstr());
hulua::dostring(L, m_str);
log_i("lua dostring %s OK\n",m_str.nstr());
}
};
typedef SmartPtr<node> SPNode;
queue< SPNode > q;
lua_State* L;
int run();
int destory();
int init();
LUA();
~LUA();
// operator lua_State *()
// {
// return L;
// }
void dofile(const char * file)
{
q.addele(new node_dofile(file));
}
void dostring(const char * str)
{
q.addele(new node_dostring(str));
}
#define regele(ele) add(new element_lua_node(ele))
void add(node * ele)
{
q.addele(ele);
}
static void show_error(const char* error)
{
errexitf("_ALERT -> %s\n", error);
}
template<typename F>
void register_func(const char * name,F func)
{
hulua::def(L, name, func);
}
template<typename T>
T call(const char * fun)
{
return hulua::call<int>(L, fun);
}
};
int lua_command(lua_State * L);
extern LUA lua;
#endif //__HUI_HULUA_H__