summaryrefslogtreecommitdiff
path: root/src/scope.rs
AgeCommit message (Collapse)Author
2022-03-21Enable `Lua::inspect_stack` for LuauAlex Orlenko
2022-03-20Initial Luau supportAlex Orlenko
2021-11-08Add `set_nth_user_value` and `get_nth_user_value` to `AnyUserData`Alex Orlenko
with `n` up to 65535 for all Lua versions.
2021-11-04Add async meta methods for all Lua except 51Alex Orlenko
2021-10-12Update documentation referencesAlex Orlenko
Using rustdoc links (see RFC https://github.com/rust-lang/rfcs/pull/1946)
2021-10-05Add (hidden) method `UserData::take()` to take out value from userdataAlex Orlenko
2021-09-28Update check_stack requirementsAlex Orlenko
2021-09-28Refactor UserData metatables handlingAlex Orlenko
2021-09-28Make `protect_lua` as a smart macro to choose from C/closureAlex Orlenko
2021-07-08Revert "Make `protect_lua` as a smart macro to choose from C/closure"Alex Orlenko
This reverts commit 84fe5f7f761e5a9669ae00df3f6e48ef2814272c.
2021-07-07Make `protect_lua` as a smart macro to choose from C/closureAlex Orlenko
2021-06-30Optimize callback creationAlex Orlenko
Attach only one upvalue to callbacks rather than two. This leads to less lookup to Lua registry.
2021-06-21Fix clippy warningAlex Orlenko
2021-06-18Fix userdata memleak in edge case.Alex Orlenko
This can happen if we unable to push metatable with `__gc` metamethod after pushing userdata. In this case Lua will never execute drop. Instead, we will push metatable first and then userdata.
2021-06-16Revert commit ced808d5abAlex Orlenko
I think this experiment is unsuccessful and does not work well in a module mode with dynamic symbols resolution and mixing between different mlua instances. Overall the Rust bug has been fixed and we can wait for the "C-unwind" feature become stable.
2021-06-03Remove `T: Clone` requirement from `add_async_function`Alex Orlenko
2021-06-03Implement `UserData` for Rc<RefCell>/Arc<Mutex>/Arc<RwLock> wrappersAlex Orlenko
2021-05-02Stack assertions reviewAlex Orlenko
Other minor code and documentation updates
2021-04-27Refactor UserDataCellAlex Orlenko
2021-04-27Store nonstatic UserData pointer in self userdata (instead of metatable)Alex Orlenko
2021-04-27Fix lua51 scope compilationAlex Orlenko
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-04-27Fix some clippy warnings & minor changesAlex Orlenko
2021-04-27Improve/fix scoped UserData dropAlex Orlenko
2021-04-27Add `UserDataFields` API.Alex Orlenko
Provide safe access to UserData metatable and allow to define custom metamethods..
2021-04-16Serialize only known (registered) userdata.Alex Orlenko
This reverts commit 7332c6a. Non-static userdata is a special case and can cause segfault if try to serialize it. Now it should be safe, plus I added non-static userdata destructor to generate better error messages in case of accessing destructed userdata.
2021-02-21Fix scoped async destruction of partially polled futuresAlex Orlenko
2020-12-31Update documentationAlex Orlenko
2020-12-14Serde support (serialize feature flag)Alex Orlenko
2020-05-15Update documentationAlex Orlenko
2020-05-15Add clippy check and fix clippy warningsAlex Orlenko
2020-05-11Add Lua 5.4 (rc2) supportAlex Orlenko
2020-05-11Scope support (including async)Alex Orlenko
2020-04-17v0.3.0-alpha.1 with async supportAlex Orlenko
Squashed commit of the async branch.
2019-11-30Add Lua 5.2 supportAlex Orlenko
2019-11-04Move lua 5.1 support under new "lua51" featureAlex Orlenko
2019-10-17Lua 5.1 supportAlex Orlenko
2019-09-29cargo fmtAlex Orlenko
2019-09-29Backport changes from rlua 0.16 (master branch)Alex Orlenko
2018-09-16Rename Scope::create_userdata to Scope::create_nonstatic_userdatakyren
avoids clashing with the previous method name to avoid confusion
2018-09-04code re-org have slightly less pub(crate) itemskyren
2018-09-04Comment updates that I really hope are correctkyren
Tried to explain the rationale for safety around callbacks in Lua and Scope a bit better, because every time I don't look at this for a while I forget my reasoning. I'm not always so great at using the right terminology, so to whoever reads this, if I got this wrong please tell me.
2018-09-04Initial design for non-'static scoped userdatakyren
Uses the same UserData trait, and should at least in theory support everything that 'static UserData does, except that any functions added that rely on AnyUserData are pretty much useless. Probably pretty slow and I'm not sure how to make it dramatically faster, which is a shame because generally when you need non'-static userdata you might be creating it kind of a lot (if it was long-lived, it would probably be 'static). Haven't added tests yet, will do that next.
2018-08-05Solve (maybe) *another* soundness issue with `Lua::scope`kyren
Callbacks should not be able to capture their arguments and hold onto them, because the `&Lua` used in previous calls will not remain valid across calls. One could imagine an API where the specific `&Lua` is simply stored inside the `Scope` itself, but this is harder to do, and would (badly) encourage storing references inside Lua userdata. Ideally, the only way it should be possible to store Lua handles inside Lua itself is through usafety or the `rental` crate or other self-borrowing techniques to make references into 'static types. If at all possible this roadblock should stay, because reference types inside userdata are almost always going to lead to a a memory leak, and if you accept the risks you should just use `RegistryKey` with its manual removal.
2018-08-05Remove out of date documentation, simpler scope lifetimeskyren
The documentation describing it being a logic bug to access "outer" callback handles when inside an "inner" callback is inaccurate, that was only true when using an older design for handle values. Also, there is no reason to have a separate 'callback lifetime, because 'scope is already invariant and just using 'scope seems equivalent.
2018-08-05Fix for a soundness bug around scope, don't allow callback parameters to escapekyren
Also includes other fixes for compiletest_rs failures, and a small reorg of tests
2018-08-05format with up-to-date rustfmtkyren
2018-03-19Small renames and comments to better communicate the intention of stack ↵kyren
checking functions
2018-03-12Fix some bad potential unsafety on inner callback calls.kyren
Since we now optionally use stack spaces for handle values, we have to be mindful of whether our stack handle points to the stack in an outer level of Lua "stack protection". We now keep track of the "recursion level" of Lua instances, and do not allow ref manipulation on "outer" Lua instances until the inner callback has returned. Also, update the documentation to reflect the additional panic behavior.