Commit Graph

363 Commits

Author SHA1 Message Date
Alex Orlenko c2eab173c5 Add userdata-wrappers feature
This feature allow to opt into `impl UserData` for `Rc<T>`/`Arc<T>`/`Rc<RefCell<T>>`/`Arc<Mutex<T>>` where `T: UserData`
Close #470
2024-11-03 11:48:47 +00:00
Alex Orlenko bb311349ec Switch between shared and exclusive lock for UserDataRef depending if T: Sync or not. 2024-11-02 10:38:25 +00:00
Alex Orlenko 5b8681dcf2 Add Scope::add_destructor to attach custom destructors 2024-10-31 14:35:21 +00:00
Alex Orlenko 4e9a17707b Fix tests 2024-10-31 09:23:03 +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 5ec4e0338a Add From<Vec> and Into<Vec> support to MultiValue and Variadic types 2024-10-30 13:03:08 +00:00
Alex Orlenko 446d63a77e More tests 2024-10-23 15:50:58 +01:00
Alex Orlenko c702077028 More Lua values conversion tests 2024-10-19 15:08:51 +01:00
Alex Orlenko e122f90837 More Either tests 2024-10-19 11:20:25 +01:00
Alex Orlenko c638d90b02 Fix test_inspect_stack 2024-10-19 00:11:05 +01:00
Alex Orlenko 2a8db87132 Update Value tests 2024-10-18 22:50:48 +01:00
Alex Orlenko cbae4fe59c More async tests 2024-10-18 22:50:15 +01:00
Alex Orlenko c68e3c4f41 Some DebugStack improvements 2024-10-18 22:48:41 +01:00
Alex Orlenko 98339c57e6 Update userdata tests 2024-10-18 21:38:02 +01:00
Alex Orlenko c07bdce250 More scope tests 2024-10-17 17:03:31 +01:00
Alex Orlenko 084a85c3d8 Update error tests 2024-10-16 23:57:48 +01:00
Alex Orlenko 735aa22be9 Fix typo in chunk tests 2024-10-16 23:57:07 +01:00
Alex Orlenko 5479546b27 Update chunk tests 2024-10-16 21:54:22 +01:00
Alex Orlenko 179c54f297 Remove generic from Table::equals and Value::equals 2024-10-16 16:11:48 +01:00
Alex Orlenko f9ae4bf05f Update table tests 2024-10-16 16:00:01 +01:00
Alex Orlenko 9e16e18132 Update string tests 2024-10-16 15:59:23 +01:00
Alex Orlenko 7535a23fa2 Update function tests 2024-10-16 15:59:13 +01:00
Alex Orlenko 8aecc83f53 clippy 2024-10-06 22:48:58 +01:00
psentee 6d5e735bed Add IntoLua/FromLua for OsString/OsStr and PathBuf/Path (#459) 2024-10-06 13:43:20 +01:00
Alex Orlenko ac315fd80b Add AnyUserData::wrap_ser function 2024-10-06 11:12:44 +01:00
Alex Orlenko 4bc846a119 Add optional anyhow dependency (under the same feature flag) to implement IntoLua for anyhow::Error 2024-10-05 23:16:36 +01:00
Alex Orlenko ae4897ab2e Add Value::is_error and Value::as_error helpers 2024-10-02 12:59:04 +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 ad9bc36764 impl Eq/Ord for Lua String 2024-10-01 23:20:19 +01:00
Alex Orlenko 4b8c26e682 Invoke __tostring metamethod when calling Value::to_string() for Buffer type 2024-10-01 22:59:19 +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 4dddf3c18d Use fmt::Debug implementation for Lua string from bstr 2024-09-26 22:46:02 +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 235c32006c Rename Lua::with_raw_state to Lua::exec_raw 2024-09-24 23:11:16 +01:00
Alex Orlenko b65901e444 Add Error::chain method to return iterator over nested errors 2024-09-24 22:48:19 +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 8274b5fa88 More user-friendly error message on userdata mismatch 2024-09-23 15:56:29 +01:00
Alex Orlenko e582e7c57f Rename get_metatable to metatable for Table/AnyUserData types 2024-09-23 11:13:16 +01:00
Alex Orlenko ca69be07ff Support setting metatable for Lua builtin types.
Closes #445
2024-09-23 10:45:57 +01:00
Alex Orlenko fc1570d2d7 Support yielding from hooks for Lua 5.3+ 2024-09-22 19:04:32 +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 da4404baa5 Add Lua::scope back 2024-09-20 13:01:55 +01:00
Alex Orlenko e1c0aa8491 Fix test test_integer_from_lua 2024-09-07 17:01:04 +01:00
Alex Orlenko 7957c6868d Fastpath for LuaString/integer/float conversion from Lua 2024-09-07 12:25:35 +01:00
Alex Orlenko 104e242ddd Some cosmetic changes 2024-09-01 22:48:56 +01:00
Alex Orlenko 825bdbfa04 Use dynamic Lua state ownership instead of compile-time module cfg flag to allow
creating new VMs in module mode (and destructing them properly).
2024-08-31 22:52:55 +01:00
Alex Orlenko 4018a17e26 Combine TableExt and AnyUserDataExt traits into ObjectLike 2024-08-30 22:50:03 +01:00
Alex Orlenko 3774296835 Run gargabe collection on main Lua instance drop
This should help preventing leaking memory when capturing Lua in async block
and dropping future without finishing polling.
2024-08-29 11:59:52 +01:00
Alex Orlenko ece66c46bf Remove unstable feature flag 2024-08-26 23:51:58 +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