-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Lua bindings #299
Merged
Add Lua bindings #299
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Redirect `which` output to `/dev/null` - Add double quotes - Use `"$@"` to pass all args to `build`/`install`
It's slow, though... Too slow. Slower than the fastest snail, but probably faster than the slowest snail. - `mlua` could have a lot of overhead - Lua wrapper tables could be bad too - Lua FFI is slow? - Or a combination I put this at the end because maybe you won't see it. I got 6.6MB/s. Compare that to Rust 260MB/s, C# 130MB/s, Python 50MB/s.
This is consistent with the manually written docs and seems like other Lua code (eg. the examples from https://github.com/sumneko/lua-language-server/wiki/EmmyLua-Annotations) also don't use spaces.
- Name should really be `luna` but it was taken - Lua 5.1 for now. Will add 5.2, 5.3, 5.4 later - A quick test shows that using the C API is much faster than `mlua` (and probably `rlua` since `mlua` is a fork of `rlua`)
- Get usize/isize args - `lua_module!()` and `lua_method!()` macros
This is much faster than the old code. Lua 5.1: ( old code -> new code) 1. 6.2x faster ( 9.87MB/s -> 61.00MB/s): for loop with fixed count + decode_out() 2. 6.8x faster ( 5.71MB/s -> 38.84MB/s): can_decode() + decode_out() 3. 7.1x faster (10.41MB/s -> 74.30MB/s): iter_out() 4. 15.2x faster ( 1.16MB/s -> 17.62MB/s): iter() (allocs a new Instruction every iter)
They're deprecated.
`get_user_data()` used to return `&mut` but many callers only need an immutable reference.
- Add a bunch of `Instruction` methods, examples not updated from Python code - Enable all iced-x86 features - Make sure the metatable is initialized even if the module hasn't been loaded yet. Eg. `Decoder` can create an `Instruction` even when the `Instruction` module hasn't been loaded yet. - Update method macros to create a `&Lua<'lua>` instead of `Lua<'lua>` so it's always the same type. - Add a more `Lua::push_{u32,f32,etc}()` methods - Rename `Instruction::new()` -> `Instruction::push_new()` since it pushes a value onto the Lua stack.
- Remove setter docs. Will be copied by the doc gen code - Fix wrong types in docs, eg. `str` -> `string` - Add missing `@param` - `@returns` should be `@return` - Use `an`
Similar to the Python pyi generator, this reads the Rust comments and spits out EmmyLua files that will be read by the Lua language server.
- 5.1.3: `lua_setlevel()` - 5.2.2: `lua_ident` - 5.4.3: `lua_closeslot()`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TODO
I tried mlua first but it had too much overhead. Switched to using the C API and I got much better speed. Lua 5.1 decoder iter: 75MB/s, Lua 5.4 90MB/s (Python with pyo3: 50MB/s)
Lua 5.1 (old mlua crate vs using the C API):