Skip to content

v0.3.0

Latest

Choose a tag to compare

@engsr6982 engsr6982 released this 29 Nov 19:33
· 2 commits to main since this release

v0.3.0

Engine Lifecycle Safety, Promise/Proxy Support & Native Binding Hardening

Added

  • Promise support: jspp::Promise and PromiseResolver with microtask integration on both backends — QuickJS pumps pending jobs on EngineScope exit, V8 at the next engine checkpoint.
  • Proxy support: the Proxy type is exposed through the value layer; isArray(), isInstanceOf() and friends keep ECMA semantics through proxy traps.
  • QuickJS scriptc tool and BytecodeContainer: compile ES modules into bytecode, embed the containers into the executable and evaluate them with evalModule(), including pure-bytecode deployment.
  • Constructor factory: .ctor(factory) accepts a callable returning std::unique_ptr<T>/std::shared_ptr<T>, enabling non-default construction paths for bound classes.
  • Instance provider: instanceProvider() exposes a native singleton as a static class; bound member functions borrow the instance on every call.
  • Custom instance storage: traits::NativeInstanceFactory<T> customization point with jspp::binding::factory::newNativeInstanceFor()/newNativeInstanceFrom().
  • Module loading API: Engine::loadModule(), evalModule(), evalModuleNamespace() with file:// module names used as cache keys and import.meta.url.
  • CMake install/export rule: jspp::jspp target, headers and jsppConfig.cmake for find_package() consumption.
  • Number::newNumber() overload for uint32_t.

Changed

  • ReturnValuePolicy::kAutomatic deduction reworked: values are copied or moved, pointers and references are borrowed (kReference), smart pointers keep their ownership.
  • const semantics: kCopy/kMove drop the source's const qualifier, member property getters unwrap const correctly, borrowed member accesses auto-adjust to kReferenceInternal, and lambdas/free functions are accepted as instance methods.
  • Enum handling and type traits updated (flags, mixed enum values).
  • API naming cleanup: NativeInstance factory functions renamed to newNativeInstanceFor()/newNativeInstanceFrom(), Arguments::runtime() to engine(), clear() to reset() on handles and resolvers, export functions renamed.
  • Removed userDefinedConstructor; constructor resolution is centralized in the constructor callbacks.

Fixed

  • Engine destruction: fixed use-after-free with tracked handles and trampolines after the engine is gone — post-destruction virtual calls fall back to the base implementation or throw the pure-virtual exception. The ownership transfer now pins the script handle, keeping the script implementation alive while C++ holds the instance.
  • Native instance binding: fixed use-after-free with non-native receivers (e.g. Proxy) — receivers are validated through class tags and the class-id registry before unwrapping, and foreign receivers reject with a clean TypeError.
  • enable_shared_from_this: types deriving it are now constructed through std::make_shared so shared_from_this() works; combining it with unique_ptr construction is rejected at compile time, and unreachable/private bases report diagnostics.
  • TransientObjectScope: fixed the use-after-free in callback argument wrapping with provenance-based scope tracking.
  • Module-exported classes are lazily bound on native-to-JS conversion instead of requiring an explicit registration order.
  • Local<Value>::kind() resolves object-like kinds (e.g. Proxy) before reporting kObject.
  • std::function converter: argument conversion and lifetime handling corrected.
  • Value modifiers no longer break template matching for callable bindings.
  • pImpl-style classes with destructors defined in a single translation unit are exposed as reference-only types instead of failing to instantiate.
  • Numeric conversions check for overflow and truncation at the int64_t/double boundary.
  • QuickJS addon: missing EngineScope added around instance finalization.

Full Changelog: v0.2.1...v0.3.0


v0.3.0(简体中文)

引擎生命周期安全、Promise/Proxy 支持与原生绑定加固

新增

  • Promise 支持:jspp::Promise 与 PromiseResolver,双后端微任务集成 — QuickJS 在 EngineScope 退出时泵送,V8 在下一个引擎检查点执行。
  • Proxy 支持:Proxy 类型接入值层,isArray()、isInstanceOf() 等查询穿透 trap 保持 ECMA 语义。
  • QuickJS scriptc 工具与 BytecodeContainer:将 ES 模块编译为字节码,容器嵌入可执行文件并以 evalModule() 求值,支持纯字节码部署。
  • 构造器工厂:.ctor(factory) 接受返回 std::unique_ptr<T>/std::shared_ptr<T> 的可调用对象,为绑定类提供非默认构造路径。
  • 实例提供器:instanceProvider() 将原生单例暴露为静态类,绑定的成员函数每次调用借用实例。
  • 自定义实例存储:traits::NativeInstanceFactory<T> 定制点与 jspp::binding::factory::newNativeInstanceFor()/newNativeInstanceFrom()。
  • 模块加载 API:Engine::loadModule()、evalModule()、evalModuleNamespace(),file:// 模块名兼作缓存键与 import.meta.url。
  • CMake install/导出规则:jspp::jspp 目标、头文件与 jsppConfig.cmake 供 find_package() 消费。
  • Number::newNumber() 新增 uint32_t 重载。

变更

  • ReturnValuePolicy::kAutomatic 推导重做:值类型拷贝或移动,指针与引用借用(kReference),智能指针保持所有权。
  • const 语义:kCopy/kMove 去除源对象 const 限定,成员属性 getter 正确解包 const,借用型成员访问自动调整为 kReferenceInternal,lambda 与自由函数可用作实例方法。
  • 枚举处理与类型 traits 更新(flags、混合枚举值)。
  • API 命名清理:NativeInstance 工厂函数更名 newNativeInstanceFor()/newNativeInstanceFrom(),Arguments::runtime() 更名 engine(),句柄与解析器的 clear() 更名 reset(),导出函数统一命名。
  • 移除 userDefinedConstructor,构造解析集中到构造回调。

修复

  • 引擎销毁:修复引擎销毁后跟踪句柄与跳板的 use-after-free — 销毁后的虚调用回落到基类实现或抛出纯虚异常。所有权移交现以强引用固定脚本对象,C++ 持有期间脚本实现保持存活。
  • 原生实例绑定:修复非原生接收者(如 Proxy)的 use-after-free — 解包前经 class tag 与 class-id 注册表校验接收者,外部接收者以 TypeError 拒绝。
  • enable_shared_from_this:派生该基类的类型改经 std::make_shared 构造,shared_from_this() 正常工作;与 unique_ptr 构造的组合在编译期拒绝,不可达/private 基类给出诊断。
  • TransientObjectScope:以溯源式作用域跟踪修复回调参数包装中的 use-after-free。
  • 模块导出类在 native-to-JS 转换时延迟绑定,不再要求显式注册顺序。
  • Local<Value>::kind() 先解析对象型 kind(如 Proxy)再报告 kObject。
  • std::function 转换器:参数转换与生命周期处理修正。
  • 值修饰符不再破坏可调用绑定的模板匹配。
  • 析构函数定义在单一编译单元内的 pImpl 风格类改为仅引用方式暴露。
  • 数值转换在 int64_t/double 边界增加溢出与截断检查。
  • QuickJS addon:实例 finalizer 周围补充缺失的 EngineScope。

Full Changelog: v0.2.1...v0.3.0