* Fix#693: Add Emscripten/embind bindings for get_state/set_state
The Emscripten wrapper exported only the eval family, leaving JS consumers
with no way to snapshot or restore the singleton ChaiScript engine. The
playground in chaiscript.github.io needs that to reset between runs without
reloading the WASM module. Added handle-based wrappers that hide
ChaiScript::State behind an int registry so JS callers don't have to manage
embind object lifetimes, exported them as saveState/restoreState/releaseState,
and added a native regression test that exercises capture, restore, and
release through the same wrapper functions the WASM binding uses.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Address review: snapshot top-level locals alongside engine state
ChaiScript::State captures globals, functions, and types but not the
top-level scripting locals created by `var x = ...`. The previous
restoreState therefore left such variables behind, breaking the
playground reset use case and tripping the new test's assertion in
Debug builds (where assert is enabled). Pair get_state with get_locals
in the snapshot so a restore brings back a clean baseline.
Requested by @lefticus in PR #699 review.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Address review: make ChaiScript engine an opaque handle, drop singleton
Replace the static ChaiScript singleton in the Emscripten wrapper with a
handle-based registry symmetric to the existing State registry. JS callers
now create an engine with chaiscript_create(), pass the resulting handle to
the eval/state helpers, and release it with chaiscript_destroy(). Multiple
independent engines are now possible, and a state snapshot can be restored
onto any engine. Updated the playground HTML and the three native regression
tests to exercise the new API.
Requested by @lefticus in PR #699 review.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: leftibot <leftibot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Fix#690: Apply clang-format consistently with CI
Applied clang-format-19 to all source files to enforce consistent
formatting according to the existing .clang-format configuration.
Added auto-clang-format GitHub Actions workflow (from
cpp-best-practices/cmake_template) that runs on pull requests to
automatically format and commit any style violations going forward.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ChaiScript relies heavily on C++ exceptions for error propagation, but
the Emscripten build was missing the -fwasm-exceptions flag. Without it,
any C++ exception in the WASM module causes an abort instead of being
catchable by JavaScript. Added -fwasm-exceptions as both a compile and
link option, and added a regression test verifying exception propagation
through the eval wrapper functions.
Co-authored-by: leftibot <leftibot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* 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>