summaryrefslogtreecommitdiff
path: root/src/value.rs
AgeCommit message (Collapse)Author
2023-08-03Optimize async functionality:Alex Orlenko
Rewrite using the new `push_into_stack()`/`from_stack()` methods. Also store thread state (pointer) in `Thread` struct to avoid getting it every time. Async userdata methods still need to have arguments stored in ref thread as stack is empty on every poll().
2023-08-01impl Drop for MultiValueAlex Orlenko
This action would automatically return container to the pool on drop (instead of doing it manually)
2023-07-31New (unsafe and private) methods for IntoLua/FromLua traits: ↵Alex Orlenko
push_into_stack/from_stack. They allow to push Value directly to Lua stack or get Value from Lua stack without creating MultiValue container. This approach is a big optimization opportunity and already demonstrated great results. For instance, obtaining `&T` for userdata methods are now work directly from stack value without copying to auxiliary stack.
2023-07-26Set `__type` metatable field for Luau instead of `__name`.Alex Orlenko
Other Lua versions continue to use `__name` field. Also make `MetaMethod` enum non-exhaustive (and add `Type` variant) Closes #295
2023-07-11Use `__tostring` if `__name` is not available when pretty printing userdata ↵Alex Orlenko
values
2023-07-08Change Lua ref types Debug print from `Ref{index}` to `Ref{pointer}`Alex Orlenko
The index is always uniq per instance, but pointer can exactly tell when several values reference to the same Lua internal value.
2023-06-20Add a dedicated type for Luau vector.Alex Orlenko
Refactor existing implementation and add 4-dimensional vectors support.
2023-05-28Include (known) userdata type to Value debug pretty-printAlex Orlenko
2023-05-27Add `Value::to_string()` method similar to `luaL_tolstring`.Alex Orlenko
It uses `__tostring` metamethod if set. Closes #279
2023-05-06Add `Value::NULL` constantAlex Orlenko
2023-04-14Remove usage of crate::ffi (clippy)Alex Orlenko
2023-04-11Add pretty-print to the Debug formatting to Value to Table.Alex Orlenko
This would allow dumping any Lua variable in human readable form.
2023-03-16Rename `error` to `cause` in `Error::BadArgument`Alex Orlenko
2023-03-14Improve error reporting when calling Rust functions from Lua.Alex Orlenko
In particular new error type `Error::BadArgument` added to help identify bad argument position or name (eg `self` for userdata).
2022-12-30Rename MultiValue cache to poolAlex Orlenko
2022-12-19Rename ToLua/ToLuaMulti -> IntoLua/IntoLuaMultiAlex Orlenko
2022-12-19Refactor LuaInner stateAlex Orlenko
Add static_assertions to check for auto traits impl on compilation stage Bump MSRV to 1.63 (required for `Ref::filter_map`)
2022-12-15Fix subtraction overflow when calculating index for `MultiValue::get()`.Alex Orlenko
Return `None` instead of panic in debug mode. Fixes #232
2022-10-22Replace Lua::ref_thread_execAlex Orlenko
2022-07-17Fix clippy warningsAlex Orlenko
2022-07-01Add `MultiValue::get` & add clear error in `Index`Eric Long
2022-06-29Implement utilities for MultiValueEric Long
2022-06-27Add `Table::to_pointer()` and `String::to_pointer()` functionsAlex Orlenko
2022-05-28Make Variadic::new and MultiValue::new constAlex Orlenko
2022-05-18Add `Value::to_pointer()` function.Alex Orlenko
Closes #165 and #166.
2022-03-25Update docsAlex Orlenko
2022-03-22Add Luau vector datatype supportAlex Orlenko
2022-03-20Refactor ffi moduleAlex Orlenko
Initial Luau support work
2021-11-25More performance optimizationsAlex Orlenko
2021-11-14Update commentsAlex Orlenko
2021-11-12Performance optimization: cache and reuse `MultiValue` containersAlex Orlenko
2021-11-12Optimize MultiValue allocations (recycle old container)Alex Orlenko
2021-10-12Update documentation referencesAlex Orlenko
Using rustdoc links (see RFC https://github.com/rust-lang/rfcs/pull/1946)
2021-09-28Add inline attributes to few hot funcsAlex Orlenko
2021-05-02Stack assertions reviewAlex Orlenko
Other minor code and documentation updates
2021-04-27cargo fmt and other minor fixesAlex Orlenko
2021-04-27Don't trigger longjmp in rust.Alex Orlenko
Motivation behind this change is upcoming breaking change in Rust compiler v1.52.0 to prevent unwinding across FFI boundaries. https://github.com/rust-lang/rust/pull/76570 The new functionality requires nightly compiler to declare FFI functions as "C-unwind". The fundamental solution is to use C shim to wrap "e" and "m" Lua functions in pcall. Additionally define Rust calling convention to trigger lua_error on Rust behalf.
2021-02-27Fix/whitelist some clippy warningsAlex Orlenko
2021-01-20Fix numeric types conversion for 32bit lua. Fix #27Alex Orlenko
2020-12-14Serde support (serialize feature flag)Alex Orlenko
2020-05-15Add clippy check and fix clippy warningsAlex Orlenko
2020-04-15Cherry-pick changes from rlua:Alex Orlenko
- Make Value::type_name() public - Update CallbackError and ExternalError Display impl
2020-01-07Implement PartialEq trait for Value (and subtypes)Alex Orlenko
Add equals() method to compare values optionally invoking __eq.
2019-09-29Backport changes from rlua 0.16 (master branch)Alex Orlenko
2018-08-05format with up-to-date rustfmtkyren
2018-03-28New approach for ref types, use an auxillary thread stackkyren
Vastly simpler and less magical than using a fixed size magical section of the active stack, and seems to be no slower. The only real downside is that it *seems* extremely extremely hacky (and to be fair, it is).
2018-03-12Documentation updates for new handle behavior, and some minor cleanupkyren
2018-03-12Documentation improvements, split scope into its own module, improved testskyren
Also makes `Lua` and associated types !UnwindSafe and !RefUnwindSafe, which they should be because they are intensely internally mutable. Lua IS still panic safe, but that doesn't mean it should be marked as UnwindSafe (as I understand it).
2018-03-11A lot of performance changes.kyren
Okay, so this is kind of a mega-commit of a lot of performance related changes to rlua, some of which are pretty complicated. There are some small improvements here and there, but most of the benefits of this change are from a few big changes. The simplest big change is that there is now `protect_lua` as well as `protect_lua_call`, which allows skipping a lightuserdata parameter and some stack manipulation in some cases. Second simplest is the change to use Vec instead of VecDeque for MultiValue, and to have MultiValue be used as a sort of "backwards-only" Vec so that ToLuaMulti / FromLuaMulti still work correctly. The most complex change, though, is a change to the way LuaRef works, so that LuaRef can optionally point into the Lua stack instead of only registry values. At state creation a set number of stack slots is reserved for the first N LuaRef types (currently 16), and space for these are also allocated separately allocated at callback time. There is a huge breaking change here, which is that now any LuaRef types MUST only be used with the Lua on which they were created, and CANNOT be used with any other Lua callback instance. This mostly will affect people using LuaRef types from inside a scope callback, but hopefully in those cases `Function::bind` will be a suitable replacement. On the plus side, the rules for LuaRef types are easier to state now. There is probably more easy-ish perf on the table here, but here's the preliminary results, based on my very limited benchmarks: create table time: [314.13 ns 315.71 ns 317.44 ns] change: [-36.154% -35.670% -35.205%] (p = 0.00 < 0.05) create array 10 time: [2.9731 us 2.9816 us 2.9901 us] change: [-16.996% -16.600% -16.196%] (p = 0.00 < 0.05) Performance has improved. create string table 10 time: [5.6904 us 5.7164 us 5.7411 us] change: [-53.536% -53.309% -53.079%] (p = 0.00 < 0.05) Performance has improved. call add function 3 10 time: [5.1134 us 5.1222 us 5.1320 us] change: [-4.1095% -3.6910% -3.1781%] (p = 0.00 < 0.05) Performance has improved. call callback add 2 10 time: [5.4408 us 5.4480 us 5.4560 us] change: [-6.4203% -5.7780% -5.0013%] (p = 0.00 < 0.05) Performance has improved. call callback append 10 time: [9.8243 us 9.8410 us 9.8586 us] change: [-26.937% -26.702% -26.469%] (p = 0.00 < 0.05) Performance has improved. create registry 10 time: [3.7005 us 3.7089 us 3.7174 us] change: [-8.4965% -8.1042% -7.6926%] (p = 0.00 < 0.05) Performance has improved. I think that a lot of these benchmarks are too "easy", and most API usage is going to be more like the 'create string table 10' benchmark, where there are a lot of handles and tables and strings, so I think that 25%-50% improvement is a good guess for most use cases.
2017-12-04more reorganization in an attempt to shrink the size of lua.rskyren