-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathfluent_builder_descriptors.cpp
More file actions
123 lines (121 loc) · 4.35 KB
/
Copy pathfluent_builder_descriptors.cpp
File metadata and controls
123 lines (121 loc) · 4.35 KB
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
// http-params
static const FluentParamDescriptor kHTTPRequestParamsDescs[] = {
{"method", 's', 0},
{"mimetype", 's', 1},
{"body_maxlength", 'i', 2},
{"verify_cert", 'b', 3},
{"verbose_throttle", 'b', 4},
{"custom_header", 'M', 5},
{"pragma_no_cache", 'b', 6},
{"user_agent", 's', 7},
{"accept", 'N', 8},
{"extended_error", 'b', 9},
};
static FluentBuilderDef* kHTTPRequestParamsDef = fluent_builder_def_build(kHTTPRequestParamsDescs, std::size(kHTTPRequestParamsDescs));
auto request = [](lua_State* L) -> int {
const auto* def = (const FluentBuilderDef*)lua_tolightuserdata(L, lua_upvalueindex(1));
slua_fluent_serialize(L, 2, def);
int rules_idx = lua_gettop(L);
lua_rawgetfield(L, LUA_BASEGLOBALSINDEX, "ll");
lua_rawgetfield(L, -1, "HTTPRequest");
lua_pushvalue(L, 1);
lua_pushvalue(L, rules_idx);
if (lua_isnoneornil(L, 3)) lua_pushliteral(L, ""); else lua_pushvalue(L, 3);
lua_call(L, 3, 1);
return 1;
};
slua_register_fluent_fn(L, "llhttp", "request", request, kHTTPRequestParamsDef);
// particle-params
static const FluentParamDescriptor kParticleParamsDescs[] = {
{"flags", 'i', 0},
{"color_begin", 'v', 1},
{"alpha_begin", 'f', 2},
{"color_end", 'v', 3},
{"alpha_end", 'f', 4},
{"scale_begin", 'v', 5},
{"scale_end", 'v', 6},
{"part_max_age", 'f', 7},
{"accel", 'v', 8},
{"pattern", 'i', 9},
{"angle_inner", 'f', 10},
{"angle_outer", 'f', 11},
{"texture", 'a', 12},
{"burst_rate", 'f', 13},
{"burst_count", 'i', 15},
{"burst_radius", 'f', 16},
{"burst_speed_min", 'f', 17},
{"burst_speed_max", 'f', 18},
{"src_max_age", 'f', 19},
{"target_key", 'k', 20},
{"omega", 'v', 21},
{"angle_begin", 'f', 22},
{"angle_end", 'f', 23},
{"blend_func_source", 'i', 24},
{"blend_func_dest", 'i', 25},
{"glow_begin", 'f', 26},
{"glow_end", 'f', 27},
};
static const FluentFlagDescriptor kParticleParamFlagDescs[] = {
{"color_interp", 0x1, 0},
{"scale_interp", 0x2, 0},
{"bounce", 0x4, 0},
{"wind", 0x8, 0},
{"follow", 0x10, 0},
{"follow_velocity", 0x20, 0},
{"target_pos", 0x40, 0},
{"target_linear", 0x80, 0},
{"emissive", 0x100, 0},
{"ribbon", 0x400, 0},
};
static FluentBuilderDef* kParticleParamsDef = []() {
auto* d = fluent_builder_def_build(kParticleParamsDescs, std::size(kParticleParamsDescs));
fluent_builder_def_add_flags(d, kParticleParamFlagDescs, std::size(kParticleParamFlagDescs));
return d;
}();
auto particle_system = [](lua_State* L) -> int {
const auto* def = (const FluentBuilderDef*)lua_tolightuserdata(L, lua_upvalueindex(1));
int link = lua_isnoneornil(L, 2) ? SLUA_LINK_THIS : luaL_checkinteger(L, 2);
slua_fluent_serialize(L, 1, def);
int rules_idx = lua_gettop(L);
lua_rawgetfield(L, LUA_BASEGLOBALSINDEX, "ll");
lua_rawgetfield(L, -1, "LinkParticleSystem");
lua_pushinteger(L, link);
lua_pushvalue(L, rules_idx);
lua_call(L, 2, 0);
return 0;
};
slua_register_fluent_fn(L, "llprim", "particleSystem", particle_system, kParticleParamsDef);
// prim-media-params
static const FluentParamDescriptor kPrimMediaParamsDescs[] = {
{"alt_image_enable", 'b', 0},
{"controls", 'i', 1},
{"current_url", 's', 2},
{"home_url", 's', 3},
{"auto_loop", 'b', 4},
{"auto_play", 'b', 5},
{"auto_scale", 'b', 6},
{"auto_zoom", 'b', 7},
{"first_click_interact", 'b', 8},
{"width_pixels", 'i', 9},
{"height_pixels", 'i', 10},
{"whitelist_enable", 'b', 11},
{"whitelist", 'C', 12},
{"perms_interact", 'i', 13},
{"perms_control", 'i', 14},
};
static FluentBuilderDef* kPrimMediaParamsDef = fluent_builder_def_build(kPrimMediaParamsDescs, std::size(kPrimMediaParamsDescs));
auto set_media = [](lua_State* L) -> int {
const auto* def = (const FluentBuilderDef*)lua_tolightuserdata(L, lua_upvalueindex(1));
int face = luaL_checkinteger(L, 1);
int link = lua_isnoneornil(L, 3) ? SLUA_LINK_THIS : luaL_checkinteger(L, 3);
slua_fluent_serialize(L, 2, def);
int rules_idx = lua_gettop(L);
lua_rawgetfield(L, LUA_BASEGLOBALSINDEX, "ll");
lua_rawgetfield(L, -1, "SetLinkMedia");
lua_pushinteger(L, link);
lua_pushinteger(L, face);
lua_pushvalue(L, rules_idx);
lua_call(L, 3, 1);
return 1;
};
slua_register_fluent_fn(L, "llprim", "setMedia", set_media, kPrimMediaParamsDef);