o
odinpkg.dev
packages / binding / odin-mquickjs

odin-mquickjs

25bf58cbinding

Odin bindings for MicroQuickJS, focused on game scripting

MIT · updated 5 months ago

Installation

  • Clone with submodules: git clone --recursive https://github.com/xraxra/odin-mquickjs.git
  • Linux: build.sh
  • Windows: build.bat
    • (may need to edit path in bat, uses build tools for VS 2022 "Desktop development with C++" & "C++ Clang Compiler")
  • once built, it's useful to symlink to your odin/shared/ folder, e.g.
    • ln -s ~/dev/odin-mquickjs ~/dev/odin/shared/mquickjs so that it can be used via import "shared:mquickjs"

Usage

  • example usage: cd example && odin run .
  • you can also run the mquickjs test scripts, e.g odin run . -- ../mquickjs/tests/mandelbrot.js

mquickjs expects all callable functions to be defined in C and compiled into the library (see odin_stdlib.c)

  • For faster iteration, the bindings provide a dispatcher that routes JS calls to Odin procedures, e.g.
    • call("player_set_health", player_id, 100);
  • The code generator introspects your provided API struct and outputs an odin file with all dispatch handling for each procedure.
  • In theory, once your API has stabilized, any performance-critical functions could be moved into odin_stdlib.c to be called natively instead of using call()