Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions VM/src/llprim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "llsl.h"
#include "llprim.h"

struct PrimParamsSetterMethod
struct PrimParamSetterMethod
{
const char *name;
const char *sem;
Expand All @@ -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)
{
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion VM/src/llprim_set_primitive_params.inl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/SLConformance.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
38 changes: 19 additions & 19 deletions tests/conformance/llprim.lua
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand All @@ -22,15 +22,15 @@ 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)
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,
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tools/gen_primparams_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading