Commit Graph

35 Commits

Author SHA1 Message Date
Alex Orlenko 646827a6bb Update Table::set_metatable
- Return Err (instead of panic) when trying to change readonly table (Luau)
- Slightly optimize performance
2025-07-06 11:37:02 +01:00
Alex Orlenko 13395e9c3d Sync mlua_derive with AsChunk trait 2025-05-27 00:54:24 +01:00
Alex Orlenko 58965c6255 Move lifetime from AsChunk<'a> to AsChunk::source 2025-01-28 18:17:29 +00:00
Evie 031854fa2a Switch proc-macro-error to proc-macro-error2 (#493) 2024-11-30 22:37:40 +00: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 c6ef393ce9 Turn Lua::entrypoint() to constructor (don't require initializing Lua first) 2024-09-02 23:43:52 +01:00
Alex Orlenko b4892c228c Add rustfmt.toml 2024-07-31 13:42:37 +01:00
Alex Orlenko 7221051683 Refactor:
- Remove the rest of `'lua` lifetimes
- Remove Owned types
2024-07-31 13:42:35 +01:00
Joris Willems ffc4bd599c Fix module imports for export (#394) 2024-04-18 10:22:41 +01:00
Yiyu Lin b62f2ee0f7 chore: make clippy happy (#388)
Co-authored-by: hzlinyiyu <hzlinyiyu@corp.netease.com>
2024-03-25 13:26:06 +00:00
Alex Orlenko 145c5b316b Fix FromLua derive proc macro to cover more cases 2024-01-25 10:26:43 +00:00
Alex Orlenko b5896173fd Include skip_memory_check code only when the corresponding attribute set for module 2024-01-10 10:08:33 +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 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 9f5325ef2f Use c-unwind ABI (Rust 1.71+) 2023-07-22 23:54:30 +01:00
Alex Orlenko 0e030d21b0 Add #[derive(FromLua)] macro to opt-in into FromLua<T> where T: 'static + Clone (userdata type).
Future macro implementations will allow making T from Lua tables/other values.
Relates to #291.
2023-07-16 01:57:28 +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 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 d0cbd32ad2 (clippy) mlua_derive: don't clone function name 2023-04-22 11:07:33 +01:00
Alex Orlenko 0848ddcdf7 Clippy 2023-03-28 20:53:22 +01:00
Alex Orlenko e182d474e0 More user-friendly error message about missing value for name attribute in module macro
Update the `[lua_module]` doc
2023-03-28 16:27:16 +01:00
Alex Orlenko 0f937b0a03 Switch to syn 2.0 2023-03-28 13:56:59 +01:00
Alex Orlenko b790b525c1 Fix clippy warnings 2023-02-07 22:43:48 +00:00
Alex Orlenko 56abc4a700 Refactor AsChunk trait 2022-12-19 21:12:36 +00:00
Alex Orlenko 0aa30226df Check for invalid args when parsing #[lua_module(...)] proc macro 2022-12-18 00:35:41 +00:00
rise0chen b532f86674 feat: Support custom name of lua_module 2022-12-18 00:35:41 +00:00
Alex Orlenko d3975bdf30 Refactor AsChunk trait.
Remove blanket implementation for T: AsRef<[u8]>
Implement for `std::path::Path`
2022-04-14 20:48:00 +01:00
Alex Orlenko cfb5d3fd45 Fix clippy warnings 2021-12-28 12:23:06 +00:00
Alex Orlenko f24fdfdb80 Update AsChunk::env function prototype 2021-06-21 23:19:33 +01:00
Alex Orlenko 08ffeb0ca9 Improve module mode:
- Don't hide module function inside `luaopen_%` function.
- Raise Lua exception instead of panic if module function returns error.
2021-06-13 22:38:51 +01:00
Alex Orlenko 20cba5de5b Fix clippy warnings 2021-05-06 00:36:47 +01:00
Alex Orlenko 3e03f4201c Add chunk! macro support 2021-05-05 22:13:51 +01:00
Alex Orlenko 5952a1f709 New module feature
Don't link module with Lua core (see: http://lua-users.org/wiki/BuildingModules)
Example and tests for modules
2020-06-07 20:38:11 +01:00
Alex Orlenko 224ed8ff52 Add mlua_derive proc macro module 2019-10-02 22:12:27 +01:00