Skip to content

drtychai/jsc-sys

Repository files navigation

jsc-sys

A *-sys crate of raw bindings to the JavaScriptCore low-level C API.

crates.io-badge docs.rs-badge musl-badge darwin-badge license

Building

#
#  Clone crate and WebKit source (included as a submodule)
#
➜ git clone --recursive https://github.com/drtychai/jsc-sys

                 [ ... ]

#
#  No special caveats to builds
#
➜ cargo build [-vv] [--target <TRIPLE>]

                 [ ... ]

➜ cargo package [-vv] [--target <TRIPLE>]

Usage

Add the following to your Cargo.toml:

[dependencies]
jscjs-sys = "0.0.2"

All necessary definitions are provided to easily interoperate with the JSC API on all x86_64 *nix architectures supported by Rust. This crate explicity exports:

JavaScriptCore.h jscjs_sys
JSContextGroupRef jscjs_sys::VM
JSGlobalContectRef jscjs_sys::Context
JSString jscjs_sys::Sting
JSValueRef jscjs_sys::Value
JSObjectref jscjs_sys::Object

These bindings are designed to be a fairly straightforward translation to the low-level C API, while taking advantage of Rust's memory safety. For more about the JavaScriptCore API, see the API source and the documentation.

Provided below are some practical examples of what functionalities this crate allows:

  • Create a global scripting context, used to create and execute JavaScript objects and code
  • Work natively with objects, parameters
  • Build JavaScript functions out of strings
  • Associate C callbacks to user-definted "classes" of objects
  • Attach C callbacks to "classes", handles responses to an action (e.g., getters/setters, promises, fn cals)
  • Load JavaScript files based on designated names and starting line-numbers

About

Raw FFI bindings to (statically-compiled) JavaScriptCore definitions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages