-
Notifications
You must be signed in to change notification settings - Fork 0
/
luaproc.h
executable file
·132 lines (121 loc) · 3.64 KB
/
luaproc.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef __LUA_PROC_H__
#define __LUA_PROC_H__
#include "xmlproc.h"
#include "hui_hulua.h"
typedef void (*lua_create)(const char * name);
map<hustr,lua_create> hui_lua_create_Instance;
int register_Instance(const char * classname, const char * funcname)
{
printf("register_Instance\n");
if(hui_lua_create_Instance.find(classname)!=hui_lua_create_Instance.end())
{
hui_lua_create_Instance[classname](funcname);
return 0;
}
else
{
printf("can't find Instance [%s]\n",classname);
return -1;
}
}
class lua_test_page : public element
{
public:
int x;
int y;
lua_test_page()
{
xpos = 0;
ypos = 0;
id = 0;
}
~lua_test_page()
{
}
static void lua_create(const char * name)
{
printf("lua create\n");
//usage: lua call
/*
* register_Instance("lua_test_page","test");
test.x=0;
test.y=0;
test.width=480;
test.height=272;
test:LuaFlushConfig();
*/
// hulua::class_add<lua_test_page>(lua, "lua_test_page");
// hulua::class_mem<lua_test_page>(lua, "x", &lua_test_page::x);
// hulua::class_mem<lua_test_page>(lua, "y", &lua_test_page::y);
// hulua::class_mem<lua_test_page>(lua, "width", &lua_test_page::width);
// hulua::class_mem<lua_test_page>(lua, "height", &lua_test_page::height);
// hulua::class_def<lua_test_page>(lua, "LuaFlushConfig", &lua_test_page::LuaFlushConfig);
//
// hulua::set(lua, name, new lua_test_page);
}
void LuaFlushConfig()
{
printf("LuaFlushConfig x=%d\n",x);
printf("LuaFlushConfig y=%d\n",y);
printf("LuaFlushConfig ypos=%d\n",ypos);
m_proc = g_cur_xml;
//mgr = g_cur_xml;
// SetBuffer(GetWidth(), GetHeight());
SetRes(0,"./a.png");
Flush();
}
void doDelete()
{
}
// void doGetInfo(info & info)
// {
// GetElementInfo(info);
// info.AddInfo("id", id);
// info.AddInfo("xpos", xpos);
// info.AddInfo("ypos", ypos);
// }
// void doFlushConfig()
// {
// PraseElement();
// id = m_mp["id"]->getvalue_int();
// xpos = m_mp["xpos"]->getvalue_int();
// ypos = m_mp["ypos"]->getvalue_int();
//
// for (int i = 0; i < m_mp.count("node"); i++)
// {
// printf("doFlushConfig %d %s\r\n",i, m_mp["node"][i]->getvalue());
// SetRes(i, m_mp["node"][i]->getvalue());
// }
//
// ParseModifRes();
// Flush();
// }
void doRender()
{
//image::RenderFrom(&res[id], xpos, ypos, GetWidth(), GetHeight(), 0, 0);
}
int xpos;
int ypos;
int id;
};
class luaproc: public xmlproc
{
public:
luaproc(const char * dlfile)
{
lua.dofile(dlfile);
}
void doLoader()
{
UnDoneProc();
hui_lua_create_Instance["lua_test_page"] = lua_test_page::lua_create;
lua.register_func("register_Instance",register_Instance);
int result = lua.call<int>("main");
printf("call--\n");
DoneProc();
}
~luaproc()
{
}
};
#endif //__LUA_PROC_H__