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
Alex Orlenko
7dc6e4c132
Add Error::runtime() helper
2023-07-10 22:41:03 +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
5dca743b0c
Improve performance AnyUserData::{is_serializable/inspect/serialize}
2023-07-10 00:01:26 +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
9fdba541e9
Update UserDataMethods::add_async_method() functions to take &T as second argument instead of cloning T.
...
New functions: `UserDataMethods::add_async_method_mut()`, `UserDataMethods::add_async_meta_method_mut()`.
2023-06-15 00:34:41 +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
b674d7906d
Include (known) userdata type to Value debug pretty-print
2023-05-28 01:12:42 +01:00
Alex Orlenko
3d7796de55
clippy
2023-05-27 22:08:42 +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
be64706cff
Missing doc for OwnedAnyUserData
2023-04-14 10:29:34 +01:00
Alex Orlenko
0fccdfed5c
Fix feature flags for owned types
2023-04-14 01:17:26 +01:00
Alex Orlenko
aaf0a5e44a
Remove usage of crate::ffi (clippy)
2023-04-14 00:36:31 +01:00
Alex Orlenko
f66932e8d2
Revert "Rename Owned*::to_ref() to as_ref()"
...
This reverts commit 5394faca16 .
2023-03-30 22:35:43 +01:00
Alex Orlenko
5394faca16
Rename Owned*::to_ref() to as_ref()
2023-03-02 15:36:11 +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
f52abf919e
Add create_userdata_ref/create_userdata_ref_mut for scope ( #206 )
...
New methods would allow creating userdata objects from (mutable) reference
to a UserData of registered type.
2023-02-12 16:37:02 +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