Alex Orlenko
ca22ea3be7
Deprecate Debug::curr_line() in favour of Debug::current_line() that returns Option
2025-07-08 10:09:26 +01:00
Alex Orlenko
c90cac5189
Add Lua::set_globals method to replace global environment.
...
Closes #611
2025-07-06 10:57:25 +01:00
Alex Orlenko
dfb4e9a668
Fix LuaJIT stack inspection tests
2025-07-01 21:40:06 +01:00
Alex Orlenko
a3697ab1db
Add Debug::function method to get function running at a given level.
...
Close #607
2025-06-30 23:25:36 +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
5dc6c3214b
Prepare for 2024 edition
2025-05-06 21:28:21 +01:00
Alex Orlenko
64b1d152b9
Deprecate Lua::load_from_finction and replace it with Lua::register_module and Lua::preload_module instead.
2025-04-26 13:42:07 +01:00
Alex Orlenko
b805939320
Make Lua::weak() method and WeakLua struct public.
...
This can be useful to prevent circular dependencies between Rust and Lua
or check that Lua instance is still alive.
2025-04-05 23:40:05 +01:00
Alex Orlenko
1f970824b4
Support user thread creation callback (Luau)
2025-03-28 11:51:35 +00:00
Alex Orlenko
806817212e
Rename Lua::init_from_ptr to Lua::get_or_init_from_ptr.
...
Return reference to `&Lua` with unbound lifetime (chosen by user).
2025-03-21 21:28:30 +00:00
Alex Orlenko
0ce599aff2
Update test case
2025-03-13 17:41:13 +00:00
Alex Orlenko
1ebb4b468a
Support 52-bit integers for Luau
...
Simply to float conversion (it actually never fails or goes out of range)
2025-03-13 16:18:44 +00:00
Alex Orlenko
c1f8abba9e
Do not allow recursive warnings (Lua 5.4)
2025-02-09 15:08:52 +00:00
Alex Orlenko
2b6172ef38
Fix tests
2025-02-05 19:01:07 +00:00
Joel Natividad
20f7ce097d
Fix typos ( #522 )
...
* fix various typos in the codebase
* fix typos in CHANGELOG.md
2025-02-05 16:16:20 +00:00
Alex Orlenko
5fd96c7908
Don't run GC finalizers on ref thread.
...
If this happen then we don't have full access to the ref thread stack.
Fixes #491
2024-11-30 01:00:31 +00:00
Alex Orlenko
a8d5f23818
Add Lua::try_app_data_ref and Lua::try_app_data_mut
2024-10-30 15:22:55 +00:00
Alex Orlenko
446d63a77e
More tests
2024-10-23 15:50:58 +01:00
Alex Orlenko
c638d90b02
Fix test_inspect_stack
2024-10-19 00:11:05 +01:00
Alex Orlenko
c68e3c4f41
Some DebugStack improvements
2024-10-18 22:48:41 +01:00
Alex Orlenko
7535a23fa2
Update function tests
2024-10-16 15:59:13 +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
235c32006c
Rename Lua::with_raw_state to Lua::exec_raw
2024-09-24 23:11:16 +01:00
Alex Orlenko
5162a0f46e
Add Lua::with_raw_state to provide easy low-level access to the Lua state.
2024-09-22 11:25:38 +01:00
Alex Orlenko
4977b91a98
Detect compilation error and return Result when using Compiler::compile() interface.
...
Closes #387
2024-08-25 23:07:13 +01:00
Alex Orlenko
4082b354fe
clippy
2024-08-01 00:55:10 +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
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
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
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
a79840afc9
Suppress Rust 1.77 dead_code false warnings.
2024-03-23 11:42:46 +00:00
Alex Orlenko
f4d783cb41
Impl push_into_stack for StdResult
2024-02-01 23:42:44 +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
727f99ee4d
Implement IntoLua for &RegistryKey
...
This would allow just passing registry keys to arguments with fasttrack to push directly into stack.
2024-01-20 22:04:28 +00:00
Alex Orlenko
9ed0d90746
Run tests for wasm32-unknown-emscripten
2024-01-06 12:12:56 +00:00
Alex Orlenko
34476ebf53
Support LuaJIT cdata type (produced by ffi module)
2023-11-16 13:33:23 +00:00
Alex Orlenko
e2b3464ec9
impl IntoLuaMulti for StdResult<(), E>
2023-08-20 14:17:18 +01:00
Alex Orlenko
6fb65a8fbe
Fix loading luau code starting with \t
2023-07-22 18:44:44 +01:00
Alex Orlenko
7dc6e4c132
Add Error::runtime() helper
2023-07-10 22:41:03 +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
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
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
Alex Orlenko
1c66a02878
Update to Lua 5.4.6
2023-05-21 00:55:06 +01:00
Alex Orlenko
8339621f9c
Rename to_lua_err -> into_lua_err
2023-01-06 21:35:15 +00:00
Alex Orlenko
56abc4a700
Refactor AsChunk trait
2022-12-19 21:12:36 +00:00
Alex Orlenko
de38e299fc
Use impl AsRef<str> for userdata methods/fields instead of generic param.
...
Use `impl AsRef<str>` for module names and named registry values.
2022-12-18 00:35:41 +00:00
Alex Orlenko
c88417a3b6
Redefine _VERSION for Luau to include version number.
...
https://github.com/khvzak/mlua/discussions/228
2022-12-03 21:21:28 +00:00
Alex Orlenko
f27c49f931
Fix bug when recycled Registry slot can be set to Nil.
...
This can result in allocating the same slot twice and rewriting old value.
Lua uses (registry) table length to find next free slot and having Nil in the middle of the table can impact length calculation.
With this fix we ensure that Nil values uses a special LUA_REFNIL slot.
2022-11-07 00:10:57 +00:00