Alex Orlenko
72ac247dca
Fix MaybeSend doc
2025-11-04 23:20:53 +00:00
Alex Orlenko
5d27cb91b2
Add optional __namecall optimization for Luau
...
Add `UserDataRegistry::enable_namecall()` hint to set `__namecall` metamethod to enable Luau-specific method resolution optimization.
2025-09-02 00:53:12 +01:00
Alex Orlenko
5f38445558
Fix warnings
2025-08-20 16:25:06 +01:00
Alex Orlenko
df0a44d405
Make Lua reference values cheap to clone
...
Instead of locking the VM and making a copy on auxiliary thread, track number of references using Rust ref counter.
This should also help reducing number of used references (they are limited to to 1M usually) on auxiliary thread.
2025-08-20 12:05:37 +01:00
Alex Orlenko
052740db15
Save lua_State at the moment of constructing Debug instead of resolving it dynamically
2025-06-30 22:38:46 +01:00
Alex Orlenko
faf547c154
Refactor Lua::inspect_stack and debug interface.
...
It was possible to cause a crash when getting a `Debug` instance and keeping it while deallocating the Lua stack frames.
2025-06-30 12:21:10 +01:00
Alex Orlenko
f16aca687d
Terminate underlying Rust future when AsyncThread is dropped.
...
Before this change, Lua GC was responsible to collect and destroy the future if
`AsyncThread` dropped in yielded state.
Now we will propagate "drop" event immediately so Lua GC need to only free the memory.
2025-05-09 12:48:40 +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
1f970824b4
Support user thread creation callback (Luau)
2025-03-28 11:51:35 +00:00
Alex Orlenko
c1f8abba9e
Do not allow recursive warnings (Lua 5.4)
2025-02-09 15:08:52 +00:00
Alex Orlenko
d1a587f49a
Wrap hooks in refcounter instead of box, same as previously.
...
This allows to obtain independent clone of closure.
Ensure that stack is always clean when running thread hook.
2025-02-08 22:11:11 +00:00
Alex Orlenko
74b4601b48
Rework Lua hooks:
...
- Support global hooks inherited by new threads
- Support thread hooks, where each thread can have its own hook
This should also allow to enable hooks for async calls.
Related to #489 #347
2025-02-07 22:42:17 +00:00
Alex Orlenko
3dc58cdfc9
Move Luau Vector type to top level
2024-10-22 22:41:26 +01:00
Alex Orlenko
d64d9719c6
Replace Either enum with implementation from either crate
2024-10-20 12:06:08 +01:00
Alex Orlenko
93a1a55aaa
Update docs
2024-10-19 23:10:43 +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
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
ca69be07ff
Support setting metatable for Lua builtin types.
...
Closes #445
2024-09-23 10:45:57 +01:00
Alex Orlenko
16951e3628
Move ValueRef to a new module
2024-09-22 23:58:53 +01:00
Alex Orlenko
fc1570d2d7
Support yielding from hooks for Lua 5.3+
2024-09-22 19:04:32 +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
21149106ee
Remove drop field from ValueRef
2024-08-26 11:18:17 +01:00
Alex Orlenko
74bebe6da3
Add optional Send requirement to internall callbacks
2024-08-26 11:13:06 +01:00
Alex Orlenko
e3c5cfdf19
Extract registry_key and vector modules from types
2024-08-26 00:27:41 +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
a86d6ab330
Mark LightUserData as Send+Sync (send feature flag)
2024-07-31 13:42:39 +01:00
Alex Orlenko
d9941ef409
Take &mut RegistryKey in Lua::replace_registry_value.
2024-07-31 13:42:38 +01:00
Alex Orlenko
b4892c228c
Add rustfmt.toml
2024-07-31 13:42:37 +01:00
Alex Orlenko
7a75c73052
Move AppData to types::app_data mod
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
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
07a5538e50
Don't run destructors if Lua is gone
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
24b0672d99
Rename LuaRef to ValueRef
2024-07-31 13:42:35 +01:00
Alex Orlenko
c23fa5aa6c
Optimize RegistryKey internals
...
- Store single `AtomicI32` field instead of pair i32,AtomicBool
- Make creation faster by skipping intermediate `Value` layer
Add new `RegistryKey::id()` method to return underlying identifier
2024-06-18 16:09:06 +01: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
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
389526bb80
Some doc improvements
2023-07-11 00:28:24 +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
3a71bfb8a0
Refactor Lua 5.4 warnings to use &str instead of CStr
2023-07-09 14:13:05 +01:00
Alex Orlenko
541139b944
Change Lua ref types Debug print from Ref{index} to Ref{pointer}
...
The index is always uniq per instance, but pointer can exactly tell when
several values reference to the same Lua internal value.
2023-07-08 12:52:14 +01:00
Alex Orlenko
1f0e81c9a1
Add a dedicated type for Luau vector.
...
Refactor existing implementation and add 4-dimensional vectors support.
2023-06-20 13:30:42 +01:00
Alex Orlenko
cea2d7fd15
Refactor application data container.
...
Now it's allowed at the same time mutably and immutably borrow different types.
Each value in the application data container is stored in it's own `RefCell` wrapper.
Also added new function `Lua::try_set_app_data()`.
2023-05-29 00:30:31 +01:00