πŸ“¦ justjavac / moonbit-ffi

MoonBit Foreign Function Interface.

β˜… 7 stars β‘‚ 0 forks πŸ‘ 7 watching
πŸ“₯ Clone https://github.com/justjavac/moonbit-ffi.git
HTTPS git clone https://github.com/justjavac/moonbit-ffi.git
SSH git clone git@github.com:justjavac/moonbit-ffi.git
CLI gh repo clone justjavac/moonbit-ffi
θΏ·ζΈ‘ θΏ·ζΈ‘ feat: bump version to 0.1.12 in moon.mod.json 89b661b 8 days ago πŸ“ History
πŸ“‚ main View all commits β†’
πŸ“ .github
πŸ“ src
πŸ“„ .gitignore
πŸ“„ moon.mod.json
πŸ“„ README.md
πŸ“„ README.md

MoonBit FFI

A lightweight utility library for converting between C‐style null-terminated byte strings (Bytes) and MoonBit String values.

[Build Status]()

Features

  • from_cstr: Convert a null-terminated Bytes to a MoonBit String (drops
the \x00 terminator).
  • to_cstr: Convert a MoonBit String to null-terminated Bytes.

Installation

Add justjavac/ffi to your dependencies:

moon update
moon add justjavac/ffi

Usage

// Convert Bytes β†’ String
let data = b"Hello, world!\x00"
let s = @ffi.from_cstr(data)
assert_eq!(s, "Hello, world!")

// Convert String β†’ Bytes
let cstr = @ffi.to_cstr("Hello, world!")
assert_eq!(cstr, data)

Supported Backends

  • Wasm & WasmGC
  • JavaScript
  • Native
  • LLVM

Development

Build the library and run tests (including docs):

moon build
moon test --doc

License

This project is licensed under the MIT License.\ Β© justjavac