diff --git a/VM/src/llprim.cpp b/VM/src/llprim.cpp index f743f06e..a7a02005 100644 --- a/VM/src/llprim.cpp +++ b/VM/src/llprim.cpp @@ -6,7 +6,7 @@ #include "llsl.h" #include "llprim.h" -struct PrimParamsSetterMethod +struct PrimParamSetterMethod { const char *name; const char *sem; @@ -18,7 +18,7 @@ struct PrimParamsSetterMethod // Pull in the generated descriptors based on lsl_definitions.yaml #include "llprim_set_primitive_params.inl" -// Shared wrapper for every ParamsSetter method. +// Shared wrapper for every ParamSetter method. // Uses upvalues to determine what to push and with what semantics static int prim_params_rule_wrapper(lua_State *L) { @@ -177,7 +177,7 @@ void luaSL_setup_llprim_module(lua_State *L) lua_setfield(L, mt, "__index"); lua_setreadonly(L, mt, true); - lua_setfield(L, -2, "ParamsSetter"); + lua_setfield(L, -2, "ParamSetter"); lua_setreadonly(L, -1, true); lua_setglobal(L, "llprim"); diff --git a/VM/src/llprim_set_primitive_params.inl b/VM/src/llprim_set_primitive_params.inl index 0daa80f2..80250e80 100644 --- a/VM/src/llprim_set_primitive_params.inl +++ b/VM/src/llprim_set_primitive_params.inl @@ -1,7 +1,7 @@ // AUTO-GENERATED by tools/gen_primparams_methods.py, do not edit // Derived from lsl_definitions.yaml -static const PrimParamsSetterMethod SET_PRIMITIVE_PARAMS_METHODS[] = { +static const PrimParamSetterMethod SET_PRIMITIVE_PARAMS_METHODS[] = { { "targetLink", "i", 34, -1 }, // LINK_TARGET { "physicsMaterial", "i", 2, -1 }, // MATERIAL { "physical", "b", 3, -1 }, // PHYSICS diff --git a/tests/SLConformance.test.cpp b/tests/SLConformance.test.cpp index 807868aa..8bf29c38 100644 --- a/tests/SLConformance.test.cpp +++ b/tests/SLConformance.test.cpp @@ -980,7 +980,7 @@ TEST_CASE("LLTimers") } static const luaL_Reg test_ll_prim_lib[] = { - // llprim.ParamsSetter:apply() routes through this on the base globals. + // llprim.ParamSetter:apply() routes through this on the base globals. // We capture its args into Lua globals so the test can verify them. {"SetLinkPrimitiveParamsFast", [](lua_State *L) { luaL_checkinteger(L, 1); diff --git a/tests/conformance/llprim.lua b/tests/conformance/llprim.lua index c2ea2227..f786d3df 100644 --- a/tests/conformance/llprim.lua +++ b/tests/conformance/llprim.lua @@ -1,9 +1,9 @@ --- Test suite for the llprim module, currently just llprim.ParamsSetter. +-- Test suite for the llprim module, currently just llprim.ParamSetter. -local ParamsSetter = llprim.ParamsSetter +local ParamSetter = llprim.ParamSetter -- `setmetatable()` should work just fine, `.new()` is just sugar for it. -local rules = setmetatable({}, ParamsSetter) +local rules = setmetatable({}, ParamSetter) -- Chaining returns self, the table is the rules list assert(rules:size(vector(1, 2, 3)) == rules) @@ -12,7 +12,7 @@ assert(rules[1] == PRIM_SIZE) assert(rules[2] == vector(1, 2, 3)) -- Multiple rules accumulate in order. -rules = ParamsSetter.new() +rules = ParamSetter.new() :pos(vector(0, 0, 0)) :size(vector(1, 1, 1)) :physicsMaterial(2) @@ -22,7 +22,7 @@ assert(rules[3] == PRIM_SIZE and rules[4] == vector(1, 1, 1)) assert(rules[5] == PRIM_MATERIAL and rules[6] == 2) -- face_target rules take a face index as the first arg. -rules = ParamsSetter.new():color(0, vector(1, 0.5, 0), 0.75) +rules = ParamSetter.new():color(0, vector(1, 0.5, 0), 0.75) assert(#rules == 4) assert(rules[1] == PRIM_COLOR) assert(rules[2] == 0) @@ -30,7 +30,7 @@ assert(rules[3] == vector(1, 0.5, 0)) assert(rules[4] == 0.75) -- PRIM_TYPE variants prepend the discriminator automatically -rules = ParamsSetter.new():primTypeBox( +rules = ParamSetter.new():primTypeBox( 0, vector(0, 1, 0), 0.0, @@ -45,34 +45,34 @@ assert(rules[3] == 0 and rules[8] == vector(0, 0, 0)) -- Boolean semantic accepts bool or int and stores native integer. -- Technically allows any integer, though, as that's the case with -- the underlying SPP implementation. -rules = ParamsSetter.new():physical(true) +rules = ParamSetter.new():physical(true) assert(rules[1] == PRIM_PHYSICS and rules[2] == 1) -rules = ParamsSetter.new():physical(false) +rules = ParamSetter.new():physical(false) assert(rules[1] == PRIM_PHYSICS and rules[2] == 0) -rules = ParamsSetter.new():physical(1) +rules = ParamSetter.new():physical(1) assert(rules[1] == PRIM_PHYSICS and rules[2] == 1) -- String semantic. -rules = ParamsSetter.new():name("foo") +rules = ParamSetter.new():name("foo") assert(rules[1] == PRIM_NAME and rules[2] == "foo") -- Rotation semantic -rules = ParamsSetter.new():rot(quaternion(0, 0, 0, 1)) +rules = ParamSetter.new():rot(quaternion(0, 0, 0, 1)) assert(rules[1] == PRIM_ROTATION) assert(rules[2] == quaternion(0, 0, 0, 1)) -- Type mismatches are raised from the wrapper itself. -assert(not pcall(function() ParamsSetter.new():size("not a vector") end)) -assert(not pcall(function() ParamsSetter.new():color("face", vector(1,1,1), 1.0) end)) +assert(not pcall(function() ParamSetter.new():size("not a vector") end)) +assert(not pcall(function() ParamSetter.new():color("face", vector(1,1,1), 1.0) end)) -- Make sure we don't do the stupid number->string coercion that Lua likes to do -assert(not pcall(function() ParamsSetter.new():name(42) end)) +assert(not pcall(function() ParamSetter.new():name(42) end)) -- Non-nullable rules reject nil. -assert(not pcall(function() ParamsSetter.new():size(nil) end)) +assert(not pcall(function() ParamSetter.new():size(nil) end)) -- The GLTF rulesets allow specifying `""` to clear overrides for basically all rules. -- Mixed: some args real, others "". -rules = ParamsSetter.new():gltfBaseColor(1, "sometexture", "", "", 0.0, +rules = ParamSetter.new():gltfBaseColor(1, "sometexture", "", "", 0.0, vector(1, 1, 1), "", 0, "", true) assert(rules[1] == PRIM_GLTF_BASE_COLOR) assert(rules[2] == 1) @@ -102,8 +102,8 @@ local expected_methods = { "new", "apply", } for _, name in expected_methods do - assert(type(ParamsSetter[name]) == "function", - `expected ParamsSetter.{name} to be a function`) + assert(type(ParamSetter[name]) == "function", + `expected ParamSetter.{name} to be a function`) end -- apply() routes the rule list through ll.SetLinkPrimitiveParamsFast on @@ -112,7 +112,7 @@ end captured_apply_link = nil captured_apply_rules = nil -rules = ParamsSetter.new():pos(vector(1, 2, 3)):physicsMaterial(2) +rules = ParamSetter.new():pos(vector(1, 2, 3)):physicsMaterial(2) rules:apply() assert(captured_apply_link == LINK_THIS) assert(captured_apply_rules == rules) diff --git a/tools/gen_primparams_methods.py b/tools/gen_primparams_methods.py index 7eb26790..b3cf7214 100644 --- a/tools/gen_primparams_methods.py +++ b/tools/gen_primparams_methods.py @@ -58,7 +58,7 @@ def render(spec) -> str: "// AUTO-GENERATED by tools/gen_primparams_methods.py, do not edit", "// Derived from lsl_definitions.yaml", "", - "static const PrimParamsSetterMethod SET_PRIMITIVE_PARAMS_METHODS[] = {", + "static const PrimParamSetterMethod SET_PRIMITIVE_PARAMS_METHODS[] = {", ] for m in spec.methods: sem = semantic_for(m)