sweet-moon

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

Downloads
7K
Stars
11
Committers
1
sweet-moon - Sweet Moon 1.0.0 Latest Release

Published by gbaptista 4 months ago

New version available on RubyGems:

gem 'sweet-moon', '~> 1.0'

New in this version:

  • Fixing C++ Shared Objects #7
  • Minimum Ruby version now is 3.1.0
sweet-moon - sweet-moon 0.0.7

Published by gbaptista over 2 years ago

Adding support for Fennel API options.

sweet-moon - sweet-moon 0.0.6

Published by gbaptista over 2 years ago

Global FFI

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.

sweet-moon - sweet-moon 0.0.5

Published by gbaptista over 2 years ago

Improved Error Handling Experience

sweet-moon - sweet-moon 0.0.4

Published by gbaptista over 2 years ago

We are bringing more consistency to how we internally handle global variables.

sweet-moon - sweet-moon 0.0.3

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.

sweet-moon - sweet-moon 0.0.2

Published by gbaptista over 2 years ago

Package paths priority rules improvement.