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
c1a018a60d
Add AnyUserData::type_id method
2025-03-31 22:41:42 +01:00
Alex Orlenko
87fa663ac1
Remove deprecated functions
2025-03-28 13:24:15 +00:00
Alex Orlenko
95c623e94d
Use c string literal where appropriate
2025-03-21 15:57:15 +00: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
d8307d0e4c
Reduce visibility of Wrapped* structs
2024-11-22 13:08:57 +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
a7d0691e10
Add AnyUserData::destroy method
2024-11-07 16:12:20 +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
93a1a55aaa
Update docs
2024-10-19 23:10:43 +01:00
Alex Orlenko
a020b2b5b2
Remove functions deprecated in v0.9
2024-10-19 15:14:09 +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
179c54f297
Remove generic from Table::equals and Value::equals
2024-10-16 16:11:48 +01:00
Alex Orlenko
9f6c78532f
Move IntoLua/FromLua and IntoLuaMulti/FromLuaMulti to traits module
2024-10-07 10:32:50 +01:00
Alex Orlenko
ac315fd80b
Add AnyUserData::wrap_ser function
2024-10-06 11:12:44 +01:00
Alex Orlenko
4ac87c7208
Derive PartialEq instead of implementing manually
2024-10-02 12:21:04 +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
529361fcbc
Add new Buffer type for Luau.
...
Previously it was represented as `AnyUserData` which is not always convenient.
2024-10-01 15:21:19 +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
9891e86d16
Remove Clone requirement from UserDataFields::add_field()
2024-08-26 11:10:34 +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
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
c715aec1f7
Do not consume self in Table::pairs and Table::sequence_values methods.
2024-07-31 13:42:38 +01:00
Alex Orlenko
b4892c228c
Add rustfmt.toml
2024-07-31 13:42:37 +01:00
Alex Orlenko
658f2a13ea
Support multi threads under send feature flag
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
b3649a44e0
Move userdata-related top-level modules into the userdata module
2024-07-31 13:42:36 +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
1eb2ecb3b0
Drop lifetime from IntoLua
2024-07-31 13:42:35 +01:00
Alex Orlenko
24b0672d99
Rename LuaRef to ValueRef
2024-07-31 13:42:35 +01:00
Alex Orlenko
08c7429531
Optimize various parts of the code to remove unnecessary clone calls.
...
This is became possible after implementing `IntoLua` for references.
2024-07-31 13:42:35 +01:00
Alex Orlenko
fa217d3706
Better Luau buffer type support.
...
- Add `Lua::create_buffer()` function
- Support serializing buffer type as a byte slice
- Support accessing copy of underlying bytes using `BString`
2024-03-28 13:05:01 +00: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
3d43103431
Make __idiv metamethod available for luau
...
Closes #383
2024-03-20 19:20:05 +00:00
Alex Orlenko
908f37656a
Add to_pointer function to Function/Table/Thread
2024-02-02 09:23:16 +00:00
Alex Orlenko
dfd82edc42
Add Lua::push() helper
2024-01-26 13:52:19 +00:00
Alex Orlenko
60e859f643
Fix (nightly) warning in doc
2024-01-06 12:55:18 +00:00
Alex Orlenko
34476ebf53
Support LuaJIT cdata type (produced by ffi module)
2023-11-16 13:33:23 +00:00
Alex Orlenko
5043447f23
Support Luau buffer type and and library.
...
Buffer is an object that represents a fixed-size mutable block of memory and added to Luau 0.601.
See https://luau-lang.org/library#buffer-library for more details.
2023-11-16 12:55:58 +00:00
Alex Orlenko
09eb7f251b
Support options for Value::serialize() implementation
...
To match `lua.from_value_with()` functionality.
2023-08-12 17:24:57 +01:00
Alex Orlenko
cd0c8a4584
Optimize async functionality:
...
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-03 00:56:17 +01:00
Alex Orlenko
196c09a0d6
New (unsafe and private) methods for IntoLua/FromLua traits: 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-31 22:13:23 +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
2277ee4860
Rename UserDataRegistrar to LuaUserDataRegistry
2023-07-11 22:15:15 +01:00