#programming-language #bindings #janet

sys janet-rs-sys

Raw Rust bindings to the Janet Programming Language

1 unstable release

0.1.0 Sep 25, 2023

#2404 in Development tools

MIT license

1.5MB
39K SLoC

C 29K SLoC // 0.1% comments Janet 9K SLoC // 0.1% comments Batch 152 SLoC Rust 55 SLoC // 0.1% comments Shell 54 SLoC // 0.0% comments

janet-rs-sys

Raw Rust bindings to the Janet Programming Language

use janet_rs_sys::*;
use std::ffi::*;

fn main()
{
    let result = unsafe { janet_init() };
    assert_eq!(result, 0);

    let env = unsafe { janet_core_env(std::ptr::null_mut()) };

    let code =
        CString::new(r#"(print "Hello World!")"#).unwrap().as_c_str().as_ptr();

    let file = CString::new("hello-world.janet").unwrap().as_c_str().as_ptr();

    let result =
        unsafe { janet_dostring(env, code, file, std::ptr::null_mut()) };
    assert_eq!(result, 0);
}

Note

Currently, these bindings only work on Windows because of some strange errors arising from bindgen using u128 on the FFI layer and subsequent warnings from the compiler because of this. It's likely that there isn't much left to do to get a Linux & MacOS version of this working but as of right now it proved too difficult to work out what was wrong on Nix platforms.

Dependencies

These are required when using janet-rs-sys in a project:

  • Meson: Builds Janet
  • Ninja: Used by Meson
  • Clang: Bindgen uses libclang

Dev Dependencies

Initialize submodules

$ git submodule update --init --recursive

Windows

Visual Studio Developer Command Prompt is required to build on Windows during development of janet-rs-sys.

No runtime deps

~0–2.6MB
~44K SLoC