mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-06-15 00:16:17 +08:00
* 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> |
||
|---|---|---|
| .. | ||
| chaiscript_em.cpp | ||
| chaiscript_eval.hpp | ||
| chaiscript.html | ||
| CMakeLists.txt | ||