summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-06-17 11:18:09 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-06-17 11:18:09 -0400
commit5b6a5c757deaba3c2b361eb49f2e61630fe3eb47 (patch)
tree14e69fcce05d56625bd16082d54f55909c33d72a /indra/newview
parentab9cb6fcd96c1c29650d844b5fd76e2ebbf5f2df (diff)
Store script's LuaListener in userdata in lua_State's Registry.
Instead of deriving LuaListener from LLInstanceTracker with an int key, generating a unique int key and storing that key in the Registry, use new lua_emplace<LuaState>() to store the LuaListener directly in a Lua userdata object in the Lua Registry. Because lua_emplace<T>() uses LL.atexit() to guarantee that ~LuaState will destroy the T object, we no longer need ~LuaState() to make a special call specifically to destroy the LuaListener, if any. So we no longer need LuaState::getListener() separate from obtainListener(). Since LuaListener is no longer an LLInstanceTracker subclass, make LuaState::obtainListener() return LuaListener& rather than LuaListener::ptr_t.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llluamanager.cpp10
-rw-r--r--indra/newview/tests/llluamanager_test.cpp2
2 files changed, 6 insertions, 6 deletions
diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp
index 5aa47d7566..8b6f7a4698 100644
--- a/indra/newview/llluamanager.cpp
+++ b/indra/newview/llluamanager.cpp
@@ -139,10 +139,10 @@ lua_function(get_event_pumps,
"post_on(commandpump, ...) to engage LLEventAPI operations (see helpleap()).")
{
luaL_checkstack(L, 2, nullptr);
- auto listener{ LuaState::obtainListener(L) };
+ auto& listener{ LuaState::obtainListener(L) };
// return the reply pump name and the command pump name on caller's lua_State
- lua_pushstdstring(L, listener->getReplyName());
- lua_pushstdstring(L, listener->getCommandName());
+ lua_pushstdstring(L, listener.getReplyName());
+ lua_pushstdstring(L, listener.getCommandName());
return 2;
}
@@ -153,8 +153,8 @@ lua_function(get_event_next,
"event becomes available.")
{
luaL_checkstack(L, 2, nullptr);
- auto listener{ LuaState::obtainListener(L) };
- const auto& [pump, data]{ listener->getNext() };
+ auto& listener{ LuaState::obtainListener(L) };
+ const auto& [pump, data]{ listener.getNext() };
lua_pushstdstring(L, pump);
lua_pushllsd(L, data);
lluau::set_interrupts_counter(L, 0);
diff --git a/indra/newview/tests/llluamanager_test.cpp b/indra/newview/tests/llluamanager_test.cpp
index cf1bf25b5c..2d525f7913 100644
--- a/indra/newview/tests/llluamanager_test.cpp
+++ b/indra/newview/tests/llluamanager_test.cpp
@@ -398,7 +398,7 @@ namespace tut
LuaState L;
auto future = LLLUAmanager::startScriptLine(L, lua);
- auto replyname{ L.obtainListener()->getReplyName() };
+ auto replyname{ L.obtainListener().getReplyName() };
auto& replypump{ LLEventPumps::instance().obtain(replyname) };
// LuaState::expr() periodically interrupts a running chunk to ensure
// the rest of our coroutines get cycles. Nonetheless, for this test