Michael Pfaff
061f84f702
Turn more comments into doc comments, improve debuggability
2023-07-16 14:39:35 -04:00
Michael Pfaff
2bbb203050
Revert "Make Debug interface more user friendly"
...
This reverts commit b3b8d79446
.
2023-07-06 13:32:11 -04: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
85f17a269d
Add `Table:is_empty()` function
2023-06-26 10:50:18 +01:00
Alex Orlenko
b169031d4e
Don't use any metamethods in `Table::sequence_values()` iterator.
...
This is matches with `Table::pair()` iterator.
Remove `Table::raw_sequence_values()` iterator.
2023-06-26 10:46:59 +01:00
Alex Orlenko
b05698d55b
impl UserData for Rc<T> and Arc<T> where T: UserData
2023-06-21 01:30:09 +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
c2bfc9ec52
Implement `PartialEq<[T]>` for tables
2023-06-19 23:28:08 +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
16bec29274
Fix setting Luau version number in `_VERSION` env var
2023-06-07 12:35:45 +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
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
1dc32452e6
Support getting and setting environment for Lua functions.
...
Closes #218
2023-06-03 12:56:49 +01:00
Alex Orlenko
3abf73dee5
Update `FunctionInfo` doc and interface
2023-05-30 00:33:57 +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
b674d7906d
Include (known) userdata type to Value debug pretty-print
2023-05-28 01:12:42 +01:00
Alex Orlenko
4306e6e978
Add `Value::to_string()` method similar to `luaL_tolstring`.
...
It uses `__tostring` metamethod if set.
Closes #279
2023-05-27 01:29:08 +01:00
Alex Orlenko
68e65a8ffe
Set `__name` field in userdata metatable if not provided
2023-05-25 10:59:46 +01:00
Alex Orlenko
1c66a02878
Update to Lua 5.4.6
2023-05-21 00:55:06 +01:00
Alex Orlenko
1ac98e7d16
- Allow downcasting error wrapped into `Error::WithContext`
...
- Overwrite error context when called multiple times
2023-05-08 23:39:53 +01:00
Alex Orlenko
d951cb503f
Add `Value::NULL` constant
2023-05-06 22:53:40 +01:00
Alex Orlenko
bbd2488f79
Add `OwnedAnyUserData::take()`
2023-05-03 23:29:33 +01:00
Alex Orlenko
fdda0d3724
Update compile tests
2023-04-27 23:06:38 +01:00
Alex Orlenko
a1d385c7b7
Add OwnedString
2023-04-26 23:17:27 +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
2d6a0fdf9c
Check for reference leak detection only in mlua integratin tests.
...
This is not necessary an error and should not be enforced by default.
Fixes #268 .
2023-04-23 10:56:26 +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
cdbf04f50c
Add pretty-print to the Debug formatting to Value to Table.
...
This would allow dumping any Lua variable in human readable form.
2023-04-11 20:36:41 +01:00
Alex Orlenko
ba324b4f54
Allow deserializing Lua null into unit(`()`) or unit struct. See #264
2023-04-10 01:49:51 +01:00
Alex Orlenko
3e83753466
Add `Thread::set_hook()` function
2023-04-08 23:53:48 +01:00
Alex Orlenko
288934c82c
Refactor `HookTriggers` (make it const)
2023-04-05 01:02:27 +01:00
Alex Orlenko
1be927bc5d
Don't call error handler for memory errors in coroutines
2023-03-30 17:29:57 +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
742307a267
Add &Lua to luau interrupt callback ( fixes #197 )
2023-03-25 16:30:31 +00:00
Alex Orlenko
6a647f58be
Add `Error::downcast_ref()` method
2023-03-19 00:22:51 +00:00
Alex Orlenko
4bc6501d2e
Tests for the `ErrorContext` trait
2023-03-17 01:31:07 +00:00
Alex Orlenko
03787668fd
Improve error reporting when calling Rust functions from Lua.
...
In particular new error type `Error::BadArgument` added to help identify bad argument position or name (eg `self` for userdata).
2023-03-14 23:23:46 +00:00
Alex Orlenko
22fbcfd9fb
Update edition everywhere
2023-03-12 01:03:31 +00:00
Alex Orlenko
87d027e8ac
Rename rust_module in tests to test_module
...
This causes warning during compilation
2023-03-03 18:58:13 +00:00
Alex Orlenko
68b60e2a0a
Add `UserDataRef` and `UserDataRefMut` types that implement `FromLua`
...
and can be used as accessors to underlying `AnyUserData` type.
2023-02-26 21:52:28 +00:00
Alex Orlenko
94f01e597c
Add `AnyUserDataExt` trait with auxiliary functions for `AnyUserData`
2023-02-18 23:40:28 +00:00
Alex Orlenko
b66bff9155
Drop `Lua::async_scope` as it's unsound
2023-02-12 22:25:10 +00:00
Alex Orlenko
f52abf919e
Add create_userdata_ref/create_userdata_ref_mut for scope ( #206 )
...
New methods would allow creating userdata objects from (mutable) reference
to a UserData of registered type.
2023-02-12 16:37:02 +00:00
Alex Orlenko
47c8300ccf
Allow registering and creating custom userdata types that don't necessary implement the `UserData` trait.
...
This is useful to register 3rd party types that cannot implement `UserData` due to Rust orphan rules.
See #206
2023-02-03 23:46:04 +00:00
Alex Orlenko
8339621f9c
Rename `to_lua_err` -> `into_lua_err`
2023-01-06 21:35:15 +00:00
Alex Orlenko
88da28a68d
Allow deserializing values from serializable UserData using `Lua::from_value()` method.
...
Closes #240
2023-01-06 10:41:17 +00:00
Alex Orlenko
cb3d58b1c7
Better Debug for String
2023-01-04 15:56:57 +00:00
Alex Orlenko
fa46720f5a
Add `Table::clear()` method
2023-01-02 15:50:21 +00:00
Alex Orlenko
72b9209ae9
Rename wrapped_failure/thread cache to pool
2022-12-30 21:48:12 +00:00
Alex Orlenko
d67332a3ac
Refactor `userdata::MetaMethod`.
...
Take `impl AsRef<str>` as name of metamethod (instead of `Into<MetaMethod>`) in UserDataMethods/UserDataFields.
Change position of generic args in userdata.
2022-12-24 19:16:58 +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
9d28b790e7
Fix module tests
2022-12-21 21:05:23 +00:00
Alex Orlenko
61c285746c
Remove FromLua impl for UserData+Clone
2022-12-20 23:30:18 +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
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
7526773a90
Do not clear usevalues when taking value out of userdata.
...
It has big performance penalty.
Lua GC can collect uservalues when userdata is not referenced anymore.
2022-12-18 00:35:41 +00:00
Alex Orlenko
05eb20f9c6
Fix subtraction overflow when calculating index for `MultiValue::get()`.
...
Return `None` instead of panic in debug mode.
Fixes #232
2022-12-15 21:10:31 +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
Alex Orlenko
a6ca65aa74
Better checks and tests when trying to modify a Luau readonly table
2022-10-30 11:41:09 +00:00
Alex Orlenko
e98998d6ac
Add push/pop methods to Table
2022-10-23 23:27:17 +01:00
Alex Orlenko
1040c0a347
Fix typo
2022-10-22 23:44:21 +01:00
Alex Orlenko
967cbb53b0
Update compile tests
2022-08-23 23:12:37 +01:00
Alex Orlenko
44a8d86d8a
Fix error message in tests (luau)
2022-08-23 23:08:00 +01:00
Alex Orlenko
33278d4a64
Check if chunk is empty in luaL_loadbufferx for Luau ( fixes #200 )
2022-08-23 11:35:08 +01:00
Alex Orlenko
0cd724f63b
Fix Lua assertion when inspecting another thread stack.
...
The thread can be dead and it's not safe to call __tostring metamethod (if present) on error object.
Fixes #195
2022-08-01 22:07:39 +01:00
Alex Orlenko
ab029b087d
Close to-be-closed variables for Lua 5.4 when using call_async functions
...
Fixes #192
2022-07-31 15:33:02 +01:00
Alex Orlenko
40fe937878
Fix a bug in `Function::bind` when args and binds are empty
...
This leads to a Lua assertion due to using wrong stack index
2022-07-22 00:24:53 +01:00
Alex Orlenko
70e16b51ae
Set source name to full file path in Luau require
2022-06-29 11:25:16 +01:00
Alex Orlenko
e7f494530f
Add Lua::create_proxy for easy access to UserData static fields and functions
...
Closes #178
2022-06-28 23:03:29 +01:00
Alex Orlenko
a05a58b258
Update integer/number coercion logic
2022-05-30 19:26:12 +01:00
Alex Orlenko
62db3adde1
Add "send" test
2022-05-26 22:22:23 +01:00
Alex Orlenko
30ba616a8a
Correctly deserialize newtype struct ( #168 )
2022-05-24 23:26:17 +01:00
Alex Orlenko
0076aa735a
Add `Function::coverage` for Luau to obtain coverage report
2022-05-24 02:01:46 +01:00
Alex Orlenko
bcf2cbea37
Add `Value::to_pointer()` function.
...
Closes #165 and #166 .
2022-05-18 13:15:08 +01:00
Alex Orlenko
2a8c5c7f82
Refactor `Function::bind` implementation.
...
Make it possible to bind async function arguments.
Fixes #161
2022-05-15 01:15:31 +01:00
Alex Orlenko
1807fa789c
Don't require Lua sources for modules in build system
2022-05-07 22:16:54 +01:00
Alex Orlenko
5133a9837a
Add `Function::info()` to get information about functions.
...
Closes #149 and #7 .
2022-04-18 18:28:11 +01:00
Alex Orlenko
790df77965
Fix "unused" warning in tests
2022-04-17 22:39:21 +01:00
Sondre Aasemoen
a5ce0c1409
Add parking_lot dependency and feature
2022-04-16 19:45:21 +02: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
21affdadfd
Remove Luau compiler options from Chunk in favour of setting Compiler instance.
...
Add ability to set global Luau compiler used for load all chunks including via require function.
2022-04-14 00:54:29 +01:00
Alex Orlenko
1ba7a409d5
Update compile tests
2022-04-13 14:30:52 +01:00
Alex Orlenko
ef81f40afa
Add tests for static Lua instance
2022-04-13 14:30:45 +01:00
Alex Orlenko
28a063c1e5
Implement Hash for Lua String
2022-04-08 20:02:18 +01:00
Alex Orlenko
55fac90a74
Fix Luau documentation in docs.rs
...
Enable `Lua::gc_inc` for Luau
Mark `debug` module as safe for Luau
2022-04-08 20:02:12 +01:00
Alex Orlenko
70d287cf9f
Don't pass Lua handler to interrupt callback (Luau) as it's not safe.
...
Optimize callback_error_ext to check stack only before allocating a new WrappedFailure.
2022-04-08 10:45:28 +01:00
Alex Orlenko
595dc3e95f
Move some Luau functionality to a new module
...
Immplement native "vector" function to construct vectors
2022-03-31 19:31:37 +01:00
Alex Orlenko
4492a20bbc
Make LuaHook as Fn instead of FnMut to remove Mutex and improve performance
2022-03-30 23:55:34 +01:00
Alex Orlenko
595bc3a2b3
Support Luau interrupts ( closes #138 )
2022-03-30 22:01:06 +01:00
Alex Orlenko
87c10ca93d
Sandboxing support
2022-03-28 23:42:35 +01:00
Alex Orlenko
714dd6249f
Enable Thread::reset for Luau
2022-03-23 21:13:48 +00:00
Alex Orlenko
0a3b65af88
Support `readonly` table attribute (luau)
2022-03-22 21:33:29 +00:00
Alex Orlenko
3a9c8c2da2
Add Luau vector datatype support
2022-03-22 21:14:06 +00:00
Alex Orlenko
4e0ba6559e
Add `require` function to Luau
2022-03-21 01:08:48 +00:00
Alex Orlenko
1e61d1dadc
Return binary chunks support in safe mode.
...
Lua has many ways to load binary bytecode and this restriction was easy to bypass.
2022-03-21 01:08:47 +00:00
Alex Orlenko
32124b31a0
Move chunks structs to a new module.
...
Add Luau Compiler interface to compile sources.
2022-03-21 01:08:47 +00:00
Alex Orlenko
3e5f8e7bb8
Enable `Lua::inspect_stack` for Luau
2022-03-21 01:08:47 +00:00