Alex Orlenko
7bc72be7d3
Use serde feature flag instead of serialize.
...
The old one is still supported.
2025-06-12 13:35:22 +01:00
Alex Orlenko
2fefaafaa6
Update "AnyUserData::take" to work on ref thread without need to push into stack.
2025-05-28 12:13:34 +01:00
Alex Orlenko
df38878278
Update __mlua_index/__mlua_newindex chunk names
2025-05-15 11:03:30 +01:00
Alex Orlenko
97ca3e2c08
Check that type passed to scoped userdata self argument is userdata.
...
If passed type is non-userdata we try to get a pointer (which will be null) that triggers an assertion.
Having a check also allow us to generate right error message.
Fixes #569
2025-05-01 13:09:23 +01:00
Alex Orlenko
49958f4827
Split Luau thread event callback to creation and collection callbacks.
...
We need this because they have different requirements:
- Thread creation callback can return Error or panic
- Thread collection callback runs during Luau GC cycle and cannot make any Lua calls or trigger panics.
2025-04-06 13:57:15 +01:00
Alex Orlenko
12e61e01f6
Restrict access to Luau VM from UserData destructors.
...
It's unsafe to make almost any Lua calls when userdata destructor is running.
This can cause recursive GC run and crash.
See https://github.com/luau-lang/luau/pull/510 for some details.
2025-04-05 10:31:39 +01:00
Alex Orlenko
53ff494ab9
Prepare for custom (Luau) userdata destructors.
...
We need to add logic later to prevent calling any Lua functions when UserData destructor is running.
2025-04-04 16:36:06 +01:00
Alex Orlenko
0a1a1fe0b6
Move some userdata helpers from crate::util to crate::userdata::util
2025-03-21 15:13:53 +00:00
Alex Orlenko
4fe7d151a1
Refactor userdata-wrappers feature.
...
Support borrowing underlying data in `UserDataRef` and `UserDataRefMut`.
2025-03-21 14:19:38 +00:00
Alex Orlenko
ae7cdcb934
Remove (internal) borrow counter and use instead "locked" flag and strong reference counter
2025-02-14 14:41:37 +00:00
Alex Orlenko
4ef0d583fc
impl Send for UserDataTypeId (in send mode)
2024-11-16 01:56:18 +00:00
Alex Orlenko
3bfaee4ecc
Delay "any" userdata metatable creation until first instance
2024-11-16 01:47:04 +00:00
Alex Orlenko
89b68e2a24
Remove generic from RawLua::push_userdata_metatable.
...
This should help to reduce amount of generated code.
2024-11-16 01:44:17 +00:00
Alex Orlenko
cbf805f492
Avoid ptr->usize->ptr conversion to comply strict provenance
2024-11-15 21:47:19 +00:00
Alex Orlenko
a7d0691e10
Add AnyUserData::destroy method
2024-11-07 16:12:20 +00:00
Alex Orlenko
1f32754f05
Relax UserDataBorrowRef restrictions to allow recursive calls
2024-11-03 12:18:00 +00:00
Alex Orlenko
c2eab173c5
Add userdata-wrappers feature
...
This feature allow to opt into `impl UserData` for `Rc<T>`/`Arc<T>`/`Rc<RefCell<T>>`/`Arc<Mutex<T>>` where `T: UserData`
Close #470
2024-11-03 11:48:47 +00:00
Alex Orlenko
bb311349ec
Switch between shared and exclusive lock for UserDataRef depending if T: Sync or not.
2024-11-02 10:38:25 +00:00
Alex Orlenko
6066089cc1
Skip setting Send/Sync in non-send mode for UserDataCell
2024-10-30 23:32:13 +00:00
Alex Orlenko
93a1a55aaa
Update docs
2024-10-19 23:10:43 +01:00
Alex Orlenko
08545224f4
clippy
2024-10-19 11:49:40 +01:00
Alex Orlenko
98339c57e6
Update userdata tests
2024-10-18 21:38:02 +01:00
Alex Orlenko
9f6c78532f
Move IntoLua/FromLua and IntoLuaMulti/FromLuaMulti to traits module
2024-10-07 10:32:50 +01:00
Alex Orlenko
04d8106676
Remove SubtypeId from AnyUserData and instead add Value::Other variant that will cover any unknown types (eg. LuaJIT CData)
2024-10-02 12:16:48 +01:00
Alex Orlenko
fb0c0d9ee9
Add Either<L, R> enum to combine two types into a single one.
...
It implements `FromLua` and `IntoLua` traits for easy type conversions..
2024-09-26 18:58:28 +01:00
Alex Orlenko
8274b5fa88
More user-friendly error message on userdata mismatch
2024-09-23 15:56:29 +01:00
Alex Orlenko
fce85381c6
Fix clippy warnings
2024-09-22 19:02:16 +01:00
Alex Orlenko
640d27697d
Fix compile error in non-send mode
2024-09-20 21:20:52 +01:00
Alex Orlenko
da4404baa5
Add Lua::scope back
2024-09-20 13:01:55 +01:00
Alex Orlenko
d6b27de34e
Optimize ObjectLike::to_string for tables and userdata
2024-08-30 22:55:53 +01:00
Alex Orlenko
4018a17e26
Combine TableExt and AnyUserDataExt traits into ObjectLike
2024-08-30 22:50:03 +01:00
Alex Orlenko
9891e86d16
Remove Clone requirement from UserDataFields::add_field()
2024-08-26 11:10:34 +01:00
Alex Orlenko
23d4e2519b
Switch to Mutex from RwLock for userdata access in send mode.
...
Unfortunately RwLock allow access to the userdata from multiple threads
without enforcing `Sync` marker.
2024-08-24 09:44:39 +01:00
Alex Orlenko
fdc50bffc9
Fix memory leak when polling async futures
2024-08-23 01:03:54 +01:00
Alex Orlenko
9931709ecd
Remove explicit lifetime from UserDataMethods and UserDataFields traits.
...
Pass `'static` arguments to async functions and require `'static` Future.
(in future we can use async closures to make it more elegant).
2024-08-23 00:10:29 +01:00
Alex Orlenko
c58f67b140
Add MaybeSend requirement to Lua futures
2024-08-10 17:55:39 +01:00
Alex Orlenko
8e14b6e40b
Fix tests
2024-08-04 22:22:02 +01:00
Alex Orlenko
4082b354fe
clippy
2024-08-01 00:55:10 +01:00
Alex Orlenko
3641c98959
Prepare for Rust 2024 edition (see rust-lang/rust#123748 )
...
Replace `IntoLua(Multi)` generic with positional arg (impl trait) where possible
This allow to shorten syntax from `a.get::<_, T>` to `a.get::<T>`
2024-07-31 23:42:43 +01:00
Alex Orlenko
b4892c228c
Add rustfmt.toml
2024-07-31 13:42:37 +01:00
Alex Orlenko
c1395ab543
clippy
2024-07-31 13:42:37 +01:00
Alex Orlenko
cd6d86a5ce
Split single lua module to multiple submodules under state
2024-07-31 13:42:37 +01:00
Alex Orlenko
d17dc54645
Rewrite call_async in traits to use impl Future instead of LocalBoxFuture.
...
More use `std::future` types instead of `future-utils`.
2024-07-31 13:42:36 +01:00
Alex Orlenko
baa8895cfb
Optimize creation of userdata callbacks (registry)
2024-07-31 13:42:36 +01:00
Alex Orlenko
550d6b2991
Remove wrapped UserData impl (Rc/Arc/etc)
2024-07-31 13:42:36 +01:00
Alex Orlenko
b3649a44e0
Move userdata-related top-level modules into the userdata module
2024-07-31 13:42:36 +01:00