summaryrefslogtreecommitdiff
path: root/indra/llcommon
AgeCommit message (Collapse)Author
2024-09-20Merge branch 'release/luau-scripting' into lua-script-argsNat Goodspeed
2024-09-20Add ability to pass command-line arguments to a Lua script.Nat Goodspeed
Introduce `ScriptCommand` class that parses a command line into a script name and optional args, using bash-like quoting and escaping. `ScriptCommand` searches for a file with that script name on a passed list of directories; the directories may be specified relative to a particular base directory. `ScriptCommand` supports the special case of a script name containing unescaped spaces. It guarantees that either the returned script file exists, or its `error()` string is non-empty. Replace `LLLeap::create()` logic, from which `ScriptCommand` was partly derived, with a `ScriptCommand` instance. Make `LLLUAmanager::runScriptFile()` use a `ScriptCommand` instance to parse the passed command line. Subsume `LLAppViewer::init()` script-path-searching logic for `--luafile` into `ScriptCommand`. In fact that lambda now simply calls `LLLUAmanager::runScriptFile()`. Make `lluau::dostring()` accept an optional vector of script argument strings. Following PUC-Rio Lua convention, pass these arguments into a Lua script as the predefined global `arg`, and also as the script's `...` argument. `LuaState::expr()` also accepts and passes through script argument strings. Change the log tag for the Lua script interruption message: if we want it, we can still enable it, but we don't necessarily want it along with all other "Lua" DEBUG messages. Remove `LuaState::script_finished_fn`, which isn't used any more. Also remove the corresponding `LLLUAmanager::script_finished_fn`. This allows us to simplify `~LuaState()` slightly, as well as the parameter signatures for `LLLUAmanager::runScriptFile()` and `runScriptLine()`.
2024-09-16Add LLFloaterAbout info (esp. GPU info) to Frame Profile stats dumpNat Goodspeed
With the About info added, `getProfileStatsContext()` need not redundantly add `"channel"`, `"version"` or `"region"`. Slightly improve the efficiency of `LlsdToJson()` and `LlsdFromJson()` by preallocating the known size of the source array or map. (Unfortunately the C++ `LLSD` class offers us no way to preallocate a map.) In `LLAppViewer::getViewerInfo()`, avoid immediate successive calls to `gAgent.getRegion()`.
2024-09-16WIP: edits in support of Lua script argsNat Goodspeed
2024-09-13Merge pull request #2548 from secondlife/lua-frame-profilenat-goodspeed
Make Develop->Render Tests->Frame Profile dump JSON to a file too (#2412)
2024-09-12Merge branch 'develop' into release/luau-scriptingNat Goodspeed
2024-09-12Disable happy-path destructor semantics when unwinding C++ stack.Nat Goodspeed
If the C++ runtime is already handling an exception, don't try to launch more Lua operations.
2024-09-12Work around broken MS `std::basic_ostream`.Nat Goodspeed
MSVC's `std::basic_ostream<CHAR>` template is not implemented in a general way: it can only be instantiated for certain specific `CHAR` types. Declaring a `std::basic_ostringstream<llwchar>` fails on MSVC with C2941. Fortunately both llstring.cpp functions that build a `LLWString` incrementally have the same characteristics: (a) they each build it one character at a time, and (b) the length of the result `LLWString` won't exceed the known length of the input string. So it works to declare a `std::vector<llwchar>`, `reserve()` the input length and `push_back()` individual characters. Then we can use `LLWString`'s range constructor to immediately allocate the right size.
2024-09-12Specialize `std::numpunct<llwchar>` to fix broken MS `basic_ostream`.Nat Goodspeed
MSVC's `std::basic_ostream<CHAR>` template is not implemented in a general way: it can only be instantiated for certain specific `CHAR` types. Declaring a `std::basic_ostringstream<llwchar>` fails on MSVC with C2941. The ugly workaround from Stack Overflow is to clone-and-edit Microsoft's `std::numpunct` template, locally specializing it for the desired `CHAR` type.
2024-09-10Profile guided optimizationsRunitaiLinden
2024-09-10In llstring.cpp, build result strings using basic_ostringstream<T>.Nat Goodspeed
Many of the string conversion functions in llstring.cpp would build their result strings using successive concatenation operations, piece by piece. This can be expensive in allocations. Instead, use a std::basic_ostringstream of char type appropriate to the return string type to aggregate piecewise string building.
2024-09-10Fix risky signature of `wchar_to_utf8chars()`. Add `ll_convert()` alias.Nat Goodspeed
`wchar_to_utf8chars()` used to require a `char*` output buffer with no length, assuming that its caller knew enough to provide a buffer of sufficient length. In fact a `char[8]` buffer suffices, but nothing in the header indicated that. Eliminate the output parameter and return `std::string`. Fix the few existing callers. Also set an `ll_convert_alias` so that `ll_convert_to<std::string>(llwchar)` directly calls `wchar_to_utf8chars()`. Replace instances of the workaround `wstring_to_utf8str(LLWString(1, llwchar))`.
2024-09-10llinstancetracker.h was missing an #include from last merge.Nat Goodspeed
2024-09-10Pass std::string_view by value, not by const reference.Nat Goodspeed
Consensus seems to be that (a) string_view is, in effect, already a reference, (b) it's small enough to make pass-by-value reasonable and (c) the optimizer can reason about values way better than it can about references.
2024-09-09Merge branch 'develop' into release/luau-scriptingNat Goodspeed
2024-09-09Changes towards C++20 compatibility (#2520)Ansariel Hiller
2024-09-06Avoid VC fatal warning when trying to fix un/signed comparison.Nat Goodspeed
2024-09-06Introduce LuaFeature debug setting, default off.Nat Goodspeed
Make central Lua engine functionality conditional on that flag.
2024-09-06Introduce llless(), and use it for llmin(), llmax().Nat Goodspeed
Add tests to verify that llless() correctly handles signed <=> unsigned comparison, which native "<" does not.
2024-09-05Merge branch 'release/luau-scripting' into lua-merge-devNat Goodspeed
2024-09-05Fix Windows build errors from develop => release/luau-scripting.Nat Goodspeed
2024-09-05Fix build errors from merging develop into release/luau-scripting.Nat Goodspeed
2024-09-05In llcoromutex.h, pull in llcoro::RMutex from develop branch.Nat Goodspeed
Also add develop branch's comments about llcoro::LockType being deprecated.
2024-09-05Fix a merge glitch in llcoros.h.Nat Goodspeed
2024-09-05Merge branch 'develop' into release/luau-scriptingNat Goodspeed
2024-09-05Fixed md5 buffer not being correctly zero-initialized and refactored code. ↵TJ
(#2507)
2024-09-05Fix a few trailing whitespaces.Nat Goodspeed
2024-09-05Merge branch 'release/luau-scripting' into lua-resultsetNat Goodspeed
2024-09-04Windows build fixesNat Goodspeed
2024-09-04Extract coroutine-aware synchronization primitives to new header.Nat Goodspeed
Changes on new main and changes on Lua project branch combined into a header circularity. Resolved by hoisting coroutine-aware synchronization primitives out to a new llcoromutex.h file in the `llcoro` namespace, rather than being literally members of the `LLCoros` class. But retained `using` declarations in `LLCoros` for backwards compatibility.
2024-09-03Fix a bug in ResultSet::getSliceStart().Nat Goodspeed
When asked to retrieve a slice starting at an `index > 0`, `getSliceStart()` was returning an LLSD array whose first `index` entries were `isUndefined()`, followed by the desired data. Fix to omit those undefined entries.
2024-09-03Add Lua traceback to errors from calling lluau::expr().Nat Goodspeed
That includes scripts run by LLLUAmanager::runScriptFile(), runScriptLine() et al.
2024-09-03Break out llinventorylistener.cpp's InvResultSet as LL::ResultSet.Nat Goodspeed
We may well want to leverage that API for additional queries that could potentially return large datasets.
2024-09-03In lua_what() and lua_stack(), try to report a function's name.Nat Goodspeed
2024-09-02Make `pairs()`, `ipairs()` forward to original funcs if no metamethods.Nat Goodspeed
That is, our replacement `pairs()` forwards the call to built-in `pairs()` when the passed object has no `__iter()` metamethod. Similarly, our replacement `ipairs()` forwards to built-in `ipairs()` when the passed object has no `__index()` metamethod. This allows for the possibility that the built-in `pairs()` and `ipairs()` functions engage more efficient implementations than the obvious ones.
2024-08-31Make global pairs(), ipairs() honor metamethods.Nat Goodspeed
Specifically, make pairs(obj) honor obj's __iter() metamethod if any. Make ipairs(obj) honor obj's __index() metamethod, if any. Given the semantics of the __index() metamethod, though, this only works for a proxy table if the proxy has no array entries (int keys) of its own.
2024-08-30Add LLIntTracker<T>, an LLInstanceTracker<T, int> with generated keys.Nat Goodspeed
The point of LLIntTracker is to generate its keys implicitly, so that its int getKey() can be treated more or less like an instance pointer, with the added bonus that the key can be passed around via LLSD. LLIntTracker generates random int keys to try to make it a little harder for one script to mess with an LLIntTracker instance belonging to another.
2024-08-30Change LLInstanceTracker::destruct() to erase().Nat Goodspeed
One could argue that LLInstanceTracker is a container of sorts, and erase() is more conventional. This affects no other code, as destruct() is not currently referenced.
2024-08-29Support next(), pairs(), ipairs() for LL.setdtor() table proxies.Nat Goodspeed
Replace the global next(), pairs() and ipairs() functions with a C++ function that drills down through layers of setdtor() proxy objects and then forwards the updated arguments to the original global function. Add a Luau __iter() metamethod to setdtor() proxy objects that, like other proxy metamethods, drills down to the underlying _target object. __iter() recognizes the case of a _target table which itself has a __iter() metamethod. Also add __idiv() metamethod to support integer division. Add tests for proxy // division, next(proxy), next(proxy, key), pairs(proxy), ipairs(proxy) and 'for k, v in proxy'. Also test the case where the table wrapped in the proxy has an __iter() metamethod of its own.
2024-08-29Add Lua script name to log messages.Nat Goodspeed
2024-08-28Ditch trailing spaces.Nat Goodspeed
2024-08-28Merge branch 'main' into release/luau-scripting.Nat Goodspeed
2024-08-28Prevent erroneous assignment to LL.setdtor() proxy._target field.Nat Goodspeed
Trim redundant output from test_setdtor.lua.
2024-08-28Attempt to get better file/line info for LL_ERRS crahses in bugsplat. (#2447)Brad Linden
secondlife/viewer#2445
2024-08-28Add `LL.setdtor()` function to add a "destructor" to any Lua object.Nat Goodspeed
`setdtor('description', object, function)` returns a proxy userdata object referencing object and function. When the proxy is garbage-collected, or at the end of the script, its destructor calls `function(object)`. The original object may be retrieved as `proxy._target`, e.g. to pass it to the `table` library. The proxy also has a metatable with metamethods supporting arithmetic operations, string concatenation, length and table indexing. For other operations, retrieve `proxy._target`. (But don't assign to `proxy._target`. It will appear to work, in that subsequent references to `proxy._target` will retrieve the replacement object -- however, the destructor will still call `function(original object)`.) Fix bugs in `lua_setfieldv()`, `lua_rawgetfield()` and `lua_rawsetfield()`. Add C++ functions `lua_destroyuserdata()` to explicitly destroy a `lua_emplace<T>()` userdata object, plus `lua_destroybounduserdata()`. The latter can bind such a userdata object as an upvalue to pass to `LL.atexit()`. Make `LL.help()` and `LL.leaphelp()` help text include the `LL.` prefix.
2024-08-28Remove obsolete, unreferenced DESTRINGIZE(), DEWSTRINGIZE() macros.Nat Goodspeed
2024-08-27code clean upMnikolenko Productengine
2024-08-26Improve safety of macOS available RAM calcuations at suggestion of Ansariel ↵Brad Linden
and Beq (#2423)
2024-08-26secondlife/viewer#2391: Remove avatar rigging "callstack" loggingCosmic Linden
2024-08-26Remove or suppress left over debug messages in hot paths (#2392)Rye Mutt