Lua / Fennel from Ruby and vice versa. Support to LuaJIT, Lua 5.0, and 5.1. Lua C API for Lua 5, 4, and 3. LuaRocks and fnx integration.
MIT License
New version available on RubyGems:
gem 'sweet-moon', '~> 1.0'
New in this version:
Published by gbaptista over 2 years ago
Adding support for Fennel API options.
Published by gbaptista over 2 years ago
Some Lua libraries (e.g., readline and luafilesystem) require the Lua C API functions available in the global C environment.
By default, Sweet Moon enables Global FFI to reduce friction when using popular libraries.
Using distinct Lua versions simultaneously with multiple Shared Objects may be dangerous in this setup: Two APIs with the same name functions could be an issue because something will be overwritten.
Also, libraries that need Lua C API functions are compiled for a specific Lua version. If you are, e.g., using LuaJIT and your library expects the Standard Lua, you may face issues.
You can disable Global FFI at any time with:
require 'sweet-moon'
SweetMoon.global.config(global_ffi: false)
SweetMoon::State.new(global_ffi: false)
SweetMoon::API.new(global_ffi: false)
To check if it's enabled or not:
require 'sweet-moon'
SweetMoon.global.api.meta.global_ffi # => true
SweetMoon.global.state.meta.global_ffi # => true
SweetMoon::API.new.meta.global_ffi # => true
SweetMoon::State.new.meta.global_ffi # => true
Caveats:
Binding a C API globally it's irreversible, so if you start something with global_ffi: true
and then change to global_ffi: false
, it won't make the global one go away. If you need local, ensure that you do it from the first line and never put anything as global throughout the entire program life cycle.
Also, the simple action of accessing meta.global_ff
will bind the API, so you need to set your desired configuration before checking.
Published by gbaptista over 2 years ago
Improved Error Handling Experience
Published by gbaptista over 2 years ago
We are bringing more consistency to how we internally handle global variables.
Published by gbaptista over 2 years ago
Garbage Collector Protection
Avoiding Ruby anonymous functions exchanged with Lua C Environment from being collected before the right time.
Published by gbaptista over 2 years ago
Package paths priority rules improvement.