Alex Orlenko
3ca7b4942e
Implement IntoLua for &Value
2024-02-07 00:10:49 +00:00
Alex Orlenko
3014c4d7a1
Add REF_STACK_RESERVE constant
2024-02-02 23:26:33 +00:00
Alex Orlenko
dfd82edc42
Add Lua::push() helper
2024-01-26 13:52:19 +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
3c801e7b17
Expose internal POLL_PENDING constant (hidden)
2024-01-20 15:52:00 +00:00
Alex Orlenko
205989f569
Fix edge case when loading many-in-one module from thread without using its state.
...
If Lua previously been initialized in main thread and then new module was loaded from thread
we reuse old state which confuses Lua loader.
2024-01-10 00:37:02 +00:00
Alex Orlenko
e4d6e92287
(async) Move "pending" poll value from env to poll_future() results
2023-12-02 15:01:40 +00:00
Alex Orlenko
642201a7e0
Remove locals from __mlua_async_poll helper
2023-12-01 18:11:06 +00:00
Alex Orlenko
c36808b251
Faster Function::call() for lua51/jit/luau
2023-12-01 12:03:46 +00:00
Alex Orlenko
93b505cff9
Integrate Luau package into mlua api.
...
Eg. `Lua::load_from_std_lib` with `StdLib::PACKAGE` is now supported for Luau.
2023-11-20 12:08:08 +00:00
Alex Orlenko
2bee5ed33a
Support binary modules for Luau on cfg(unix)
2023-11-16 15:54:25 +00:00
Alex Orlenko
2d775695ef
Rewrite Luau require function to support module loaders.
...
Also add `package` library with `path`/`loaded`/`loaders`.
2023-11-16 14:39:17 +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
a1e39a8620
Remove MemoryState from ExtraData and retrieve using lua_getallocf (recently added to Luau)
2023-10-24 00:23:32 +01: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
89cf5bf362
impl Default for Lua
2023-08-20 12:16:11 +01:00
Alex Orlenko
0e4476c2e3
Add Lua::set_vector_metatable() method (unstable)
2023-08-12 22:46:21 +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
4fff14a144
impl Drop for MultiValue
...
This action would automatically return container to the pool on drop (instead of doing it manually)
2023-08-01 11:21:26 +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
114f072269
Update module entrypoint function.
...
Return c_int instead of Result (and avoid potential panic on Rust side).
2023-07-31 17:49:07 +01:00
Alex Orlenko
8b71f94141
Fix AsChunk trait to support capturing wrapped Lua types (AnyUserData::wrap() and Function::wrap()).
...
This is a breaking change, the `'lua` lifetime used to in environment moved to the trait declaration.
2023-07-27 13:56:48 +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
9f5325ef2f
Use c-unwind ABI (Rust 1.71+)
2023-07-22 23:54:30 +01:00
Alex Orlenko
fac39a2f46
Drop openresty specific luajit extensions
2023-07-20 01:02:23 +01:00
Alex Orlenko
2277ee4860
Rename UserDataRegistrar to LuaUserDataRegistry
2023-07-11 22:15:15 +01:00
Alex Orlenko
9f0fc27c52
Make Lua::push_value() and Lua::pop_value() public (but hidden from the docs).
...
Can be useful for low-level intergration with mlua values.
Also closes #215 .
2023-07-11 20:03:41 +01:00
Alex Orlenko
389526bb80
Some doc improvements
2023-07-11 00:28:24 +01:00
Alex Orlenko
7dc6e4c132
Add Error::runtime() helper
2023-07-10 22:41:03 +01:00
Alex Orlenko
6b8b79266f
Drop futures-timer dev-dependency
2023-07-10 01:16:27 +01:00
Alex Orlenko
44533d2c9d
Add new module attribule skip_memory_check to improve performance
...
in module mode (by skipping memory allocations check) with extra risks.
2023-07-10 00:43:19 +01:00
Alex Orlenko
c38a1f060b
Various cosmetic changes
2023-07-10 00:04:40 +01:00
Alex Orlenko
1c20494158
Use usize instead of c_int for table capacity (Lua::create_table_with_capacity)
2023-07-09 22:11:26 +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
24e14c4874
Always set hook on a current Lua context (state) and remove MainThreadNotAvailable as no longer needed
2023-07-09 12:33:21 +01:00
Alex Orlenko
5127903c38
Remove generic type parameter from init_userdata_metatable
2023-07-08 17:00:46 +01:00
Alex Orlenko
925a2816cc
clippy
2023-07-06 00:59:46 +01:00
Alex Orlenko
1367a033d7
Don't clone function when doing call_async()
2023-06-21 13:14:17 +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
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
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
e7b712e29f
Rely on LUA_MINSTACK in callbacks
2023-06-06 21:38:45 +01:00
Alex Orlenko
d5483988d2
Optimize polling async functions (40% performance win)
2023-06-04 20:53:12 +01:00
Alex Orlenko
8ab0ccf11c
Don't keep poll function in environment globals when polling async functions.
...
This is redundant after deprecating scoped async.
Closes #281
2023-06-04 02:31:29 +01:00
Alex Orlenko
9785722d61
Require environment to be a Table instead of Value in Chunks.
...
In addition to that, `AsChunk::env()` renamed to `AsChunk::environment()`.
2023-06-03 00:00:53 +01:00
Alex Orlenko
c905a34b1d
(Luau) Set thread globals to main thread globals when resetting the thread
2023-06-02 21:13:23 +01:00
Alex Orlenko
a1089dbf95
Optimize a bit calling Rust functions from Lua.
...
This is done by reusing upvalue as a captured variable.
Also in async functions upvalue is always set (async cannot be scoped) so extra checks removed.
2023-05-30 15:15:20 +01:00
Alex Orlenko
baf25e263f
Change _mlua to __mlua prefix for internal chunk names
2023-05-30 00:36:09 +01:00