ChaiScript/emscripten/chaiscript_em.cpp
leftibot 340e7d4b16
Fix #472: Emscripten Frontend (#662)
* Fix #472: Add Emscripten/WebAssembly build for browser-based ChaiScript

Port Rob Loach's ChaiScript.js work (https://github.com/RobLoach/ChaiScript.js)
into the main repository as an Emscripten build target. Adds a GitHub Actions
workflow that builds ChaiScript to WebAssembly and publishes artifacts (JS, WASM,
HTML) for embedding in the official ChaiScript.com website. Includes an HTML
interactive playground frontend and a native test validating the eval API surface.

Co-Authored-By: Rob Loach <robloach@gmail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Address review: publish WASM assets as release under wasm-latest tag

Add a publish job to the emscripten workflow that creates a prerelease
tagged wasm-latest with chaiscript.js, chaiscript.wasm, and
chaiscript.html as downloadable assets. Runs only on pushes to the
develop branch. The website repo can fetch these via the public
GitHub Releases API on a daily cron without any cross-repo auth.

Requested by @lefticus in PR #662 review.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: leftibot <leftibot@users.noreply.github.com>
Co-authored-by: Rob Loach <robloach@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 15:58:28 -06:00

24 lines
854 B
C++

// This file is distributed under the BSD License.
// See "license.txt" for details.
// Copyright 2019, Rob Loach (https://github.com/RobLoach/ChaiScript.js)
// Copyright 2009-2018, Jason Turner (jason@emptycrate.com)
// http://www.chaiscript.com
//
// Emscripten/WebAssembly wrapper for ChaiScript.
// Based on work by Rob Loach: https://github.com/RobLoach/ChaiScript.js
#include "chaiscript_eval.hpp"
#ifdef __EMSCRIPTEN__
#include <emscripten/bind.h>
EMSCRIPTEN_BINDINGS(chaiscript) {
emscripten::function("eval", &chaiscript_eval);
emscripten::function("evalString", &chaiscript_eval_string);
emscripten::function("evalBool", &chaiscript_eval_bool);
emscripten::function("evalInt", &chaiscript_eval_int);
emscripten::function("evalFloat", &chaiscript_eval_float);
emscripten::function("evalDouble", &chaiscript_eval_double);
}
#endif