Alex Orlenko
9f6c78532f
Move IntoLua/FromLua and IntoLuaMulti/FromLuaMulti to traits module
2024-10-07 10:32:50 +01:00
Alex Orlenko
f95161c6e0
Add missing documentation for Function::wrap_raw* functions
2024-10-05 23:26:03 +01:00
Alex Orlenko
4ac87c7208
Derive PartialEq instead of implementing manually
2024-10-02 12:21:04 +01:00
Alex Orlenko
91fe02da45
Add LuaNativeFn/LuaNativeFnMut/LuaNativeAsyncFn traits for using in Function::wrap
2024-09-24 14:35:03 +01:00
Alex Orlenko
ca69be07ff
Support setting metatable for Lua builtin types.
...
Closes #445
2024-09-23 10:45:57 +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
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
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
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
4aa178fcc0
Take &Value in Lua::push_value()
2024-07-31 13:42:35 +01:00
Alex Orlenko
9734146313
Add Function::deep_clone() (Luau only)
2024-03-21 22:14:00 +00:00
Alex Orlenko
908f37656a
Add to_pointer function to Function/Table/Thread
2024-02-02 09:23:16 +00:00
Alex Orlenko
c36808b251
Faster Function::call() for lua51/jit/luau
2023-12-01 12:03:46 +00:00
Alex Orlenko
94a79656ad
Faster Function::call()
2023-08-03 01:16:52 +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
28bcc73f2c
Move impl IntoLua for WrappedFunction to the function.rs file
2023-07-27 15:19:34 +01:00
Alex Orlenko
9f5325ef2f
Use c-unwind ABI (Rust 1.71+)
2023-07-22 23:54:30 +01:00
Alex Orlenko
6b8b79266f
Drop futures-timer dev-dependency
2023-07-10 01:16:27 +01:00
Alex Orlenko
c38a1f060b
Various cosmetic changes
2023-07-10 00:04:40 +01:00
Alex Orlenko
b3b8d79446
Make Debug interface more user friendly
...
- use String instead of Vec<u8>
- update docs
- unify fields between lua5.x/luau
- line numbers are `usize`
2023-07-06 00:38:33 +01:00
Alex Orlenko
c1168d3ec1
Refactor call_async() functions to use static dispatch outside of traits
2023-06-21 12:44:24 +01:00
Alex Orlenko
cf0524aa23
Use lua_iscfunction instead of lua_getinfo in Function::environment()
2023-06-08 09:33:48 +01:00
Alex Orlenko
9596f2e9ee
Fix warning when compiling for lua51
2023-06-03 14:24:34 +01:00
Alex Orlenko
1dc32452e6
Support getting and setting environment for Lua functions.
...
Closes #218
2023-06-03 12:56:49 +01:00
Alex Orlenko
baf25e263f
Change _mlua to __mlua prefix for internal chunk names
2023-05-30 00:36:09 +01:00
Alex Orlenko
3abf73dee5
Update FunctionInfo doc and interface
2023-05-30 00:33:57 +01:00
Alex Orlenko
e0224ab159
Use futures-core and futures-tasks via futures-util.
...
Just to reduce number of dependencies.
2023-05-29 00:30:29 +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
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
65e72f39ae
Remove unstable feature flag from Function::wrap/wrap_mut/wrap_async
2023-04-14 00:21:18 +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
d9aac08b81
Support setting memory limit for Lua 5.1/JIT/Luau
...
Other versions already support this feature.
Closes #119
2023-03-26 00:06:52 +00:00
Alex Orlenko
22c973af02
Async: Don't clone function when executing it from recycled thread
2023-03-03 18:22:39 +00:00
Alex Orlenko
5394faca16
Rename Owned*::to_ref() to as_ref()
2023-03-02 15:36:11 +00:00
Alex Orlenko
1d4a135e8e
Add Function::wrap/Function::wrap_mut/Function::wrap_async to wrap functions into a type that implements IntoLua trait.
...
This is useful to avoid calling `lua.create_function*` every time when `Function` handle is needed.
2022-12-22 16:24:35 +00:00
Alex Orlenko
a13c188de3
Rename ToLua/ToLuaMulti -> IntoLua/IntoLuaMulti
2022-12-19 23:00:47 +00:00
Alex Orlenko
c60f633a62
Add "unstable" feature flag.
...
Hide owned types under the new feature flag.
Drop OwnedString/OwnedThread types (unlikely they are useful).
2022-12-19 22:26:44 +00:00
Alex Orlenko
56abc4a700
Refactor AsChunk trait
2022-12-19 21:12:36 +00:00
Alex Orlenko
9b4e3a1598
Refactor LuaInner state
...
Add static_assertions to check for auto traits impl on compilation stage
Bump MSRV to 1.63 (required for `Ref::filter_map`)
2022-12-19 16:09:05 +00:00
Alex Orlenko
bf79d9e75d
Initial implementation of owned Lua types
2022-12-18 00:35:41 +00:00
Alex Orlenko
29c6c9cb58
Fix clippy warnings
2022-10-09 14:08:33 +01:00