Skip to content

Commit 2879903

Browse files
authored
Merge pull request #143 from secondlife/rider/fluent
Rulesets for table-based function params
2 parents 8a5eefc + 8824092 commit 2879903

19 files changed

Lines changed: 1322 additions & 139 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ stage/
3636

3737
# Editors
3838
.vscode
39+
*.code-workspace

gen_all_definitions.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mkdir -p "$outdir" "$outdir/cpp" "$outdir/templated" "$outdir/experimental" "$ou
77

88
DEFS="./lsl_definitions.yaml"
99
SLUA="./slua_definitions.yaml"
10-
CMD="python gen_definitions.py"
10+
CMD="$(command -v python3 || command -v python) gen_definitions.py"
1111

1212
# Viewer outputs
1313
$CMD $DEFS syntax "$outdir/lsl_keywords.xml"
@@ -33,6 +33,7 @@ $CMD $DEFS gen_lscript_interface "$outdir/cpp/lscript_interface.cpp"
3333
$CMD $DEFS gen_mono_bind_interfaces "$outdir/cpp/mono_bind_interfaces.cpp"
3434
$CMD $DEFS gen_lua_registrations 1 "$outdir/cpp/lua_registrations.cpp"
3535
$CMD $DEFS gen_lua_constant_definitions "$outdir/cpp/lua_constant_definitions.cpp"
36+
$CMD $DEFS gen_fluent_builder_descriptors "$outdir/cpp/fluent_builder_descriptors.cpp"
3637
$CMD $DEFS gen_lscript_library_bind_pure "$outdir/cpp/lscript_library_bind_pure.cpp"
3738
$CMD $DEFS gen_tree_header_file "$outdir/cpp/lscript_tree.h"
3839
$CMD $DEFS gen_tree_source_file "$outdir/cpp/lscript_tree.cpp"
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// http-params
2+
static const FluentParamDescriptor kHTTPRequestParamsDescs[] = {
3+
{"method", 's', 0},
4+
{"mimetype", 's', 1},
5+
{"body_maxlength", 'i', 2},
6+
{"verify_cert", 'b', 3},
7+
{"verbose_throttle", 'b', 4},
8+
{"custom_header", 'M', 5},
9+
{"pragma_no_cache", 'b', 6},
10+
{"user_agent", 's', 7},
11+
{"accept", 'N', 8},
12+
{"extended_error", 'b', 9},
13+
};
14+
static FluentBuilderDef* kHTTPRequestParamsDef = fluent_builder_def_build(kHTTPRequestParamsDescs, std::size(kHTTPRequestParamsDescs));
15+
auto request = [](lua_State* L) -> int {
16+
const auto* def = (const FluentBuilderDef*)lua_tolightuserdata(L, lua_upvalueindex(1));
17+
slua_fluent_serialize(L, 2, def);
18+
int rules_idx = lua_gettop(L);
19+
lua_rawgetfield(L, LUA_BASEGLOBALSINDEX, "ll");
20+
lua_rawgetfield(L, -1, "HTTPRequest");
21+
lua_pushvalue(L, 1);
22+
lua_pushvalue(L, rules_idx);
23+
if (lua_isnoneornil(L, 3)) lua_pushliteral(L, ""); else lua_pushvalue(L, 3);
24+
lua_call(L, 3, 1);
25+
return 1;
26+
};
27+
slua_register_fluent_fn(L, "llhttp", "request", request, kHTTPRequestParamsDef);
28+
29+
// particle-params
30+
static const FluentParamDescriptor kParticleParamsDescs[] = {
31+
{"flags", 'i', 0},
32+
{"color_begin", 'v', 1},
33+
{"alpha_begin", 'f', 2},
34+
{"color_end", 'v', 3},
35+
{"alpha_end", 'f', 4},
36+
{"scale_begin", 'v', 5},
37+
{"scale_end", 'v', 6},
38+
{"part_max_age", 'f', 7},
39+
{"accel", 'v', 8},
40+
{"pattern", 'i', 9},
41+
{"angle_inner", 'f', 10},
42+
{"angle_outer", 'f', 11},
43+
{"texture", 'a', 12},
44+
{"burst_rate", 'f', 13},
45+
{"burst_count", 'i', 15},
46+
{"burst_radius", 'f', 16},
47+
{"burst_speed_min", 'f', 17},
48+
{"burst_speed_max", 'f', 18},
49+
{"src_max_age", 'f', 19},
50+
{"target_key", 'k', 20},
51+
{"omega", 'v', 21},
52+
{"angle_begin", 'f', 22},
53+
{"angle_end", 'f', 23},
54+
{"blend_func_source", 'i', 24},
55+
{"blend_func_dest", 'i', 25},
56+
{"glow_begin", 'f', 26},
57+
{"glow_end", 'f', 27},
58+
};
59+
static const FluentFlagDescriptor kParticleParamFlagDescs[] = {
60+
{"color_interp", 0x1, 0},
61+
{"scale_interp", 0x2, 0},
62+
{"bounce", 0x4, 0},
63+
{"wind", 0x8, 0},
64+
{"follow", 0x10, 0},
65+
{"follow_velocity", 0x20, 0},
66+
{"target_pos", 0x40, 0},
67+
{"target_linear", 0x80, 0},
68+
{"emissive", 0x100, 0},
69+
{"ribbon", 0x400, 0},
70+
};
71+
static FluentBuilderDef* kParticleParamsDef = []() {
72+
auto* d = fluent_builder_def_build(kParticleParamsDescs, std::size(kParticleParamsDescs));
73+
fluent_builder_def_add_flags(d, kParticleParamFlagDescs, std::size(kParticleParamFlagDescs));
74+
return d;
75+
}();
76+
auto particle_system = [](lua_State* L) -> int {
77+
const auto* def = (const FluentBuilderDef*)lua_tolightuserdata(L, lua_upvalueindex(1));
78+
int link = lua_isnoneornil(L, 2) ? SLUA_LINK_THIS : luaL_checkinteger(L, 2);
79+
slua_fluent_serialize(L, 1, def);
80+
int rules_idx = lua_gettop(L);
81+
lua_rawgetfield(L, LUA_BASEGLOBALSINDEX, "ll");
82+
lua_rawgetfield(L, -1, "LinkParticleSystem");
83+
lua_pushinteger(L, link);
84+
lua_pushvalue(L, rules_idx);
85+
lua_call(L, 2, 0);
86+
return 0;
87+
};
88+
slua_register_fluent_fn(L, "llprim", "particleSystem", particle_system, kParticleParamsDef);
89+
90+
// prim-media-params
91+
static const FluentParamDescriptor kPrimMediaParamsDescs[] = {
92+
{"alt_image_enable", 'b', 0},
93+
{"controls", 'i', 1},
94+
{"current_url", 's', 2},
95+
{"home_url", 's', 3},
96+
{"auto_loop", 'b', 4},
97+
{"auto_play", 'b', 5},
98+
{"auto_scale", 'b', 6},
99+
{"auto_zoom", 'b', 7},
100+
{"first_click_interact", 'b', 8},
101+
{"width_pixels", 'i', 9},
102+
{"height_pixels", 'i', 10},
103+
{"whitelist_enable", 'b', 11},
104+
{"whitelist", 'C', 12},
105+
{"perms_interact", 'i', 13},
106+
{"perms_control", 'i', 14},
107+
};
108+
static FluentBuilderDef* kPrimMediaParamsDef = fluent_builder_def_build(kPrimMediaParamsDescs, std::size(kPrimMediaParamsDescs));
109+
auto set_media = [](lua_State* L) -> int {
110+
const auto* def = (const FluentBuilderDef*)lua_tolightuserdata(L, lua_upvalueindex(1));
111+
int face = luaL_checkinteger(L, 1);
112+
int link = lua_isnoneornil(L, 3) ? SLUA_LINK_THIS : luaL_checkinteger(L, 3);
113+
slua_fluent_serialize(L, 2, def);
114+
int rules_idx = lua_gettop(L);
115+
lua_rawgetfield(L, LUA_BASEGLOBALSINDEX, "ll");
116+
lua_rawgetfield(L, -1, "SetLinkMedia");
117+
lua_pushinteger(L, link);
118+
lua_pushinteger(L, face);
119+
lua_pushvalue(L, rules_idx);
120+
lua_call(L, 3, 1);
121+
return 1;
122+
};
123+
slua_register_fluent_fn(L, "llprim", "setMedia", set_media, kPrimMediaParamsDef);

generated/experimental/enums.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -814,11 +814,11 @@ enum ParticleParam {
814814
PART_END_GLOW = 27
815815
};
816816
enum ParticleSourcePattern {
817-
DROP = 0x1
818-
EXPLODE = 0x2
819-
ANGLE = 0x4
820-
ANGLE_CONE = 0x8
821-
ANGLE_CONE_EMPTY = 0x10
817+
DROP = 1
818+
EXPLODE = 2
819+
ANGLE = 4
820+
ANGLE_CONE = 8
821+
ANGLE_CONE_EMPTY = 16
822822
};
823823
enum PassMode {
824824
IF_NOT_HANDLED = 0

generated/lsl_keywords_pretty.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,7 +2470,7 @@ This file is auto-generated by https://github.com/secondlife/lsl-definitions. --
24702470
<key>HTTP_CUSTOM_HEADER</key>
24712471
<map>
24722472
<key>tooltip</key>
2473-
<string>Adds a custom HTTP header (name and value pair) to the request. Up to 8 custom headers can be configured per request. Some default or sensitive headers are blocked for security reasons.</string>
2473+
<string>Adds custom HTTP headers to the request (up to 8 per request). At the SLua level, provide a string-keyed table mapping header names to values; the serializer emits one HTTP_CUSTOM_HEADER/key/value triple per entry. Some default or sensitive headers are blocked for security reasons.</string>
24742474
<key>type</key>
24752475
<string>integer</string>
24762476
<key>value</key>
@@ -5643,7 +5643,7 @@ vector force
56435643
<key>PRIM_MEDIA_WHITELIST</key>
56445644
<map>
56455645
<key>tooltip</key>
5646-
<string>String. Gets or sets the whitelist as a string of escaped, comma-separated URLs (supports up to 64 URLs or 1024 characters, whichever comes first).</string>
5646+
<string>Gets or sets the media whitelist as an array of URL strings (up to 64 URLs or 1024 characters, whichever comes first). At the SLua level, provide a {string} array; the serializer encodes it as an escaped, comma-separated string for the underlying LSL API.</string>
56475647
<key>type</key>
56485648
<string>integer</string>
56495649
<key>value</key>

generated/lua_keywords_pretty.xml

Lines changed: 138 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,21 @@ export type DateTypeResult = {
198198
isdst: boolean?,
199199
}</string>
200200
</map>
201+
<key>HttpRequestParams</key>
202+
<map>
203+
<key>tooltip</key>
204+
<string>HTTP request parameter table. Pass to ll.httpRequest() to configure an HTTP request.</string>
205+
</map>
206+
<key>MediaParams</key>
207+
<map>
208+
<key>tooltip</key>
209+
<string>Prim face media parameter table. Pass to llprim.SetMedia() to configure media on a face.</string>
210+
</map>
211+
<key>ParticleParams</key>
212+
<map>
213+
<key>tooltip</key>
214+
<string>Particle system parameter table. Pass to llprim.ParticleSystem() to emit particles.</string>
215+
</map>
201216
<key>list</key>
202217
<map>
203218
<key>tooltip</key>
@@ -2723,7 +2738,7 @@ export type rotation = quaternion</string>
27232738
<key>HTTP_CUSTOM_HEADER</key>
27242739
<map>
27252740
<key>tooltip</key>
2726-
<string>Adds a custom HTTP header (name and value pair) to the request. Up to 8 custom headers can be configured per request. Some default or sensitive headers are blocked for security reasons.</string>
2741+
<string>Adds custom HTTP headers to the request (up to 8 per request). At the SLua level, provide a string-keyed table mapping header names to values; the serializer emits one HTTP_CUSTOM_HEADER/key/value triple per entry. Some default or sensitive headers are blocked for security reasons.</string>
27272742
<key>type</key>
27282743
<string>number</string>
27292744
<key>value</key>
@@ -5916,7 +5931,7 @@ vector force
59165931
<key>PRIM_MEDIA_WHITELIST</key>
59175932
<map>
59185933
<key>tooltip</key>
5919-
<string>String. Gets or sets the whitelist as a string of escaped, comma-separated URLs (supports up to 64 URLs or 1024 characters, whichever comes first).</string>
5934+
<string>Gets or sets the media whitelist as an array of URL strings (up to 64 URLs or 1024 characters, whichever comes first). At the SLua level, provide a {string} array; the serializer encodes it as an escaped, comma-separated string for the underlying LSL API.</string>
59205935
<key>type</key>
59215936
<string>number</string>
59225937
<key>value</key>
@@ -13217,6 +13232,54 @@ Returns true if result is non-zero.</string>
1321713232
<key>tooltip</key>
1321813233
<string>Encodes a string or buffer to base64</string>
1321913234
</map>
13235+
<key>llhttp</key>
13236+
<map>
13237+
<key>energy</key>
13238+
<real>-1.0</real>
13239+
<key>tooltip</key>
13240+
<string>Utilities for making HTTP requests.</string>
13241+
</map>
13242+
<key>llhttp.request</key>
13243+
<map>
13244+
<key>arguments</key>
13245+
<array>
13246+
<map>
13247+
<key>url</key>
13248+
<map>
13249+
<key>tooltip</key>
13250+
<string></string>
13251+
<key>type</key>
13252+
<string>string</string>
13253+
</map>
13254+
</map>
13255+
<map>
13256+
<key>params</key>
13257+
<map>
13258+
<key>tooltip</key>
13259+
<string></string>
13260+
<key>type</key>
13261+
<string>HttpRequestParams?</string>
13262+
</map>
13263+
</map>
13264+
<map>
13265+
<key>body</key>
13266+
<map>
13267+
<key>tooltip</key>
13268+
<string></string>
13269+
<key>type</key>
13270+
<string>string?</string>
13271+
</map>
13272+
</map>
13273+
</array>
13274+
<key>energy</key>
13275+
<real>10.0</real>
13276+
<key>return</key>
13277+
<string>uuid</string>
13278+
<key>sleep</key>
13279+
<real>0.0</real>
13280+
<key>tooltip</key>
13281+
<string>Send an HTTP request. Returns a key identifying the request, which is delivered via the http_response event. Omit body for requests that do not need a body (e.g. GET).</string>
13282+
</map>
1322013283
<key>lljson</key>
1322113284
<map>
1322213285
<key>energy</key>
@@ -13359,6 +13422,79 @@ Returns true if result is non-zero.</string>
1335913422
<key>tooltip</key>
1336013423
<string>Utilities for working with prims / objects</string>
1336113424
</map>
13425+
<key>llprim.particleSystem</key>
13426+
<map>
13427+
<key>arguments</key>
13428+
<array>
13429+
<map>
13430+
<key>params</key>
13431+
<map>
13432+
<key>tooltip</key>
13433+
<string></string>
13434+
<key>type</key>
13435+
<string>ParticleParams?</string>
13436+
</map>
13437+
</map>
13438+
<map>
13439+
<key>link</key>
13440+
<map>
13441+
<key>tooltip</key>
13442+
<string></string>
13443+
<key>type</key>
13444+
<string>number?</string>
13445+
</map>
13446+
</map>
13447+
</array>
13448+
<key>energy</key>
13449+
<real>10.0</real>
13450+
<key>return</key>
13451+
<string>()</string>
13452+
<key>sleep</key>
13453+
<real>0.0</real>
13454+
<key>tooltip</key>
13455+
<string>Emit a particle system from a ParticleParams table. Omit link to apply to the current prim.</string>
13456+
</map>
13457+
<key>llprim.setMedia</key>
13458+
<map>
13459+
<key>arguments</key>
13460+
<array>
13461+
<map>
13462+
<key>face</key>
13463+
<map>
13464+
<key>tooltip</key>
13465+
<string></string>
13466+
<key>type</key>
13467+
<string>number</string>
13468+
</map>
13469+
</map>
13470+
<map>
13471+
<key>params</key>
13472+
<map>
13473+
<key>tooltip</key>
13474+
<string></string>
13475+
<key>type</key>
13476+
<string>MediaParams?</string>
13477+
</map>
13478+
</map>
13479+
<map>
13480+
<key>link</key>
13481+
<map>
13482+
<key>tooltip</key>
13483+
<string></string>
13484+
<key>type</key>
13485+
<string>number?</string>
13486+
</map>
13487+
</map>
13488+
</array>
13489+
<key>energy</key>
13490+
<real>10.0</real>
13491+
<key>return</key>
13492+
<string>number</string>
13493+
<key>sleep</key>
13494+
<real>0.0</real>
13495+
<key>tooltip</key>
13496+
<string>Configure media on a specific face. Omit link to apply to the current prim.</string>
13497+
</map>
1336213498
<key>math</key>
1336313499
<map>
1336413500
<key>energy</key>

0 commit comments

Comments
 (0)