Alex Orlenko
90ef25a6ee
Prepare for custom (Luau) userdata destructors.
...
We need to add logic later to prevent calling any Lua functions when UserData destructor is running.
2025-05-05 00:49:17 +01:00
Alex Orlenko
4444ac4ea3
Add AnyUserData::type_id method
2025-05-05 00:47:09 +01:00
Alex Orlenko
0393406b9f
Refactor userdata-wrappers feature.
...
Support borrowing underlying data in `UserDataRef` and `UserDataRefMut`.
2025-05-04 18:45:42 +01:00
Alex Orlenko
69d3ddec29
Remove (internal) borrow counter and use instead "locked" flag and strong reference counter
2025-05-04 12:46:35 +01:00
Alex Orlenko
a7d0691e10
Add AnyUserData::destroy method
2024-11-07 16:12:20 +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
2a8db87132
Update Value tests
2024-10-18 22:50:48 +01:00
Alex Orlenko
98339c57e6
Update userdata tests
2024-10-18 21:38:02 +01:00
Alex Orlenko
179c54f297
Remove generic from Table::equals and Value::equals
2024-10-16 16:11:48 +01:00
Alex Orlenko
8274b5fa88
More user-friendly error message on userdata mismatch
2024-09-23 15:56:29 +01:00
Alex Orlenko
e582e7c57f
Rename get_metatable to metatable for Table/AnyUserData types
2024-09-23 11:13:16 +01:00
Alex Orlenko
da4404baa5
Add Lua::scope back
2024-09-20 13:01:55 +01:00
Alex Orlenko
4018a17e26
Combine TableExt and AnyUserDataExt traits into ObjectLike
2024-08-30 22:50:03 +01:00
Alex Orlenko
6317b8e0c8
Test GC for nested userdata (userdata in userdata)
2024-08-25 21:02:12 +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
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
550d6b2991
Remove wrapped UserData impl (Rc/Arc/etc)
2024-07-31 13:42:36 +01:00
Alex Orlenko
313117095c
Remove parking_lot feature flag
2024-07-31 13:42:35 +01:00
Alex Orlenko
7221051683
Refactor:
...
- Remove the rest of `'lua` lifetimes
- Remove Owned types
2024-07-31 13:42:35 +01:00
Alex Orlenko
a79840afc9
Suppress Rust 1.77 dead_code false warnings.
2024-03-23 11:42:46 +00:00
Alex Orlenko
58be624222
Remove redundant "match" when checking userdata type via AnyUserData::is.
...
Fixes #386
2024-03-20 19:29:47 +00:00
Alex Orlenko
908f37656a
Add to_pointer function to Function/Table/Thread
2024-02-02 09:23:16 +00:00
Alex Orlenko
145c5b316b
Fix FromLua derive proc macro to cover more cases
2024-01-25 10:26:43 +00:00
Alex Orlenko
8200bee467
Implement IntoLua for ref to String/Table/Function/AnyUserData
...
This would prevent cloning plus has better performance when pushing values to Lua stack (`IntoLua::push_into_stack` method)
2024-01-23 22:14:50 +00:00
Alex Orlenko
53b7b5b70b
Fix setting userdata (static) fields when it has __index metamethod/function.
...
Closes #312
2023-08-27 23:01:37 +01:00
Alex Orlenko
a802276c56
Fix an edge case when using invalidated (relative) userdata index after processing varargs.
...
This causes Lua API correctness check assertion in debug mode.
Fixes #311 .
2023-08-24 00:54:50 +01:00
Alex Orlenko
3bda1351c3
Fix lua51/52 case in userdata tests
2023-07-26 23:18:30 +01:00
Alex Orlenko
4daa631178
Set __type metatable field for Luau instead of __name.
...
Other Lua versions continue to use `__name` field.
Also make `MetaMethod` enum non-exhaustive (and add `Type` variant)
Closes #295
2023-07-26 21:43:26 +01:00
Alex Orlenko
0e030d21b0
Add #[derive(FromLua)] macro to opt-in into FromLua<T> where T: 'static + Clone (userdata type).
...
Future macro implementations will allow making T from Lua tables/other values.
Relates to #291 .
2023-07-16 01:57:28 +01:00
Alex Orlenko
44b8c8b7a6
Add AnyUserData::wrap() to more easy way of creating _any_ userdata in Lua.
...
This is similar to `Function::wrap()`.
2023-07-10 16:36:38 +01:00
Alex Orlenko
01c1952c9f
Rename AnyUserData::get_*_user_value to AnyUserData::*_user_value.
...
To be more consistent with function like `Lua::named_registry_value`, `Lua::add_data_ref` and os on.
2023-07-09 23:50:44 +01:00
Alex Orlenko
b05698d55b
impl UserData for Rc<T> and Arc<T> where T: UserData
2023-06-21 01:30:09 +01:00
Alex Orlenko
5a135a331a
Add UserDataFields::add_field() method to add static fields to UserData.
...
Plus `UserDataFields::add_meta_field()` for static meta fields.
Fix propagating fields to wrapped UserData types.
2023-06-07 12:18:24 +01:00
Alex Orlenko
68e65a8ffe
Set __name field in userdata metatable if not provided
2023-05-25 10:59:46 +01:00
Alex Orlenko
bbd2488f79
Add OwnedAnyUserData::take()
2023-05-03 23:29:33 +01:00
Alex Orlenko
4daa7de997
Various improvements for owned types, including:
...
- tests
- shortcuts for `OwnedFunction` and `OwnedAnyUserData`
2023-04-26 15:40:48 +01:00
Alex Orlenko
03787668fd
Improve error reporting when calling Rust functions from Lua.
...
In particular new error type `Error::BadArgument` added to help identify bad argument position or name (eg `self` for userdata).
2023-03-14 23:23:46 +00:00
Alex Orlenko
68b60e2a0a
Add UserDataRef and UserDataRefMut types that implement FromLua
...
and can be used as accessors to underlying `AnyUserData` type.
2023-02-26 21:52:28 +00:00
Alex Orlenko
94f01e597c
Add AnyUserDataExt trait with auxiliary functions for AnyUserData
2023-02-18 23:40:28 +00:00
Alex Orlenko
47c8300ccf
Allow registering and creating custom userdata types that don't necessary implement the UserData trait.
...
This is useful to register 3rd party types that cannot implement `UserData` due to Rust orphan rules.
See #206
2023-02-03 23:46:04 +00:00
Alex Orlenko
8339621f9c
Rename to_lua_err -> into_lua_err
2023-01-06 21:35:15 +00:00
Alex Orlenko
d67332a3ac
Refactor userdata::MetaMethod.
...
Take `impl AsRef<str>` as name of metamethod (instead of `Into<MetaMethod>`) in UserDataMethods/UserDataFields.
Change position of generic args in userdata.
2022-12-24 19:16:58 +00:00
Alex Orlenko
61c285746c
Remove FromLua impl for UserData+Clone
2022-12-20 23:30:18 +00:00
Alex Orlenko
de38e299fc
Use impl AsRef<str> for userdata methods/fields instead of generic param.
...
Use `impl AsRef<str>` for module names and named registry values.
2022-12-18 00:35:41 +00:00
Alex Orlenko
7526773a90
Do not clear usevalues when taking value out of userdata.
...
It has big performance penalty.
Lua GC can collect uservalues when userdata is not referenced anymore.
2022-12-18 00:35:41 +00:00
Alex Orlenko
e7f494530f
Add Lua::create_proxy for easy access to UserData static fields and functions
...
Closes #178
2022-06-28 23:03:29 +01:00
Sondre Aasemoen
a5ce0c1409
Add parking_lot dependency and feature
2022-04-16 19:45:21 +02:00
Alex Orlenko
c322e028e2
Initial Luau support
2022-03-20 20:30:20 +00:00
Alex Orlenko
e2ebe65306
Add get_named_user_value and set_named_user_value to AnyUserData
2021-11-21 23:42:47 +00:00