add ctor extensions and fast property support#5
Merged
MangelSpec merged 36 commits intomasterfrom Feb 13, 2026
Merged
Conversation
- convert.hpp: ToString() → ToLocal + throw (proxy/throwing toString) - convert.hpp: GetPropertyNames() → ToLocal + throw (Proxy traps) - function.hpp: Function::New() → ToLocal + return empty - json.ipp: Stringify/GetPropertyNames → ToLocal with fallbacks - json.ipp: Set().FromJust() → FromMaybe(false) - class.hpp: extract isolate/context temps in static_()
Add try_from_v8 static method to every convert<T> specialization, combining validation and extraction in a single pass without exceptions. For simple converters (bool, int, float), from_v8 now delegates to try_from_v8 to eliminate code duplication. String converter extracts a shared extract_string helper. Sequence and mapping converters move their full extraction logic into try_from_v8 with from_v8 delegating to it. Free function v8pp::try_from_v8<T>() uses a requires-expression to detect native try_from_v8 support, falling back to is_valid + from_v8 for user-defined converters via a [[deprecated]] helper that emits a compile-time warning encouraging users to add try_from_v8. Add comprehensive tests covering primitives, strings, enums, sequences, maps, tuples, optionals, and wrapped classes via raw and shared pointers.
Use #cmakedefine01 in config.hpp.in to convert CMake BOOL values (ON/OFF) to C preprocessor integers (1/0). Include config.hpp in type_info.hpp so the macro is defined when included standalone. Remove redundant PRIVATE compile definition from v8pp target.
circular reference handling, class method/property on non-wrapped objects. Fix non-member functions not accessible on class constructor, update tuple bool->string test expectation, fix class re-registration conflict in try_from_v8 tests, suppress V8 stderr noise in unhandled exception tests.
…r validation, context use-after-free protection - Rewrite unwrap_object with fast path (direct field check) and depth-limited slow path (constexpr kMaxPrototypeDepth = 16) to prevent infinite loops from circular/deep prototype chains - Add magic number sentinel (0xC1A5517F) to class_info, validated in weak callbacks and unwrap_object before static_cast of registry pointer - Protect require()/run() from use-after-free via static alive-context set in context.cpp, checked before dereferencing context pointer in callbacks - Add tests: deep prototype chain, fast path unwrap, inheritance unwrap, require() after context destruction
… concepts Extract traverse_subobjects() helper from get_option/set_option/set_option_data to eliminate three identical 12-line loops. Replace void_t detection patterns (is_mapping, is_sequence, has_reserve) and the is_callable_impl SFINAE hack with C++20 concepts. Replace 9 enable_if partial specializations in convert.hpp with requires clauses, using standard concepts (std::integral, std::floating_point) where available. All existing trait aliases preserved for backward compatibility.
…omUtf8Literal Add SideEffectType annotations to function/var/property bindings in class_ and module. Const member functions auto-detect as kHasNoSideEffect, with explicit override overload. Var and property getters marked kHasNoSideEffect, setters kHasSideEffectToReceiver. Add to_v8_name() helper using kInternalized for property/method name strings. Replace to_v8 char array overload with NewFromUtf8Literal for compile-time constant strings. Add is_const_member_function_v trait with requires-constrained partial specialization.
…hrono New type conversions: - int64_t/uint64_t use BigInt (lossless full-range, accepts Number fallback) - std::span<T> → TypedArray (copy-based, to_v8 only) - std::vector<uint8_t> ↔ ArrayBuffer (bidirectional) - std::set/unordered_set ↔ Array - std::pair<K,V> ↔ [first, second] Array - std::filesystem::path ↔ string - std::chrono::duration ↔ Number (milliseconds) - std::chrono::time_point ↔ Number (epoch milliseconds) Variant converter updated with BigInt dispatch using lossless parameter for correct signed/unsigned 64-bit differentiation.
…st API callbacks - add v8pp::defaults<> for trailing default parameter values on bound functions - add call_from_v8 overload with arg_or_default compile-time dispatch - add forward_function_with_defaults V8 callback and wrap_function_template overload - add defaults support to class_::function(), class_::ctor(), module::function(), context::function() - add v8pp::overload<Sig>() compile-time overload selector - add overload_entry, overload_set, with_defaults() for bundling overloads - add runtime arity+type dispatch in forward_overloaded_function - add variadic .function(name, f1, f2, ...) on class_, module, context - add v8pp::fast_fn<&func> for V8 Fast API JIT fast-path callbacks via NTTP - add is_fast_api_compatible trait, fast_callback wrapper generating CFunction signatures - add fast_function overloads on class_, module, context, wrap_function_template - use ConstructorBehavior::kThrow for fast-path FunctionTemplates (V8 requirement) - replace static_assert with requires clauses on function() to enable SFINAE with fast_function - add test_overload and test_fast_api test suites
- to_string_tag() for custom Object.prototype.toString output - to_primitive() for type coercion (member functions and lambdas) - iterable() for Symbol.iterator with member or lambda begin/end - promise<T> and promise<void> with convert specialization
- add v8pp::context_store class backed by a dedicated V8 context - store uses isolated v8::Object (not context global) to avoid built-in property pollution - support dot-separated names with auto-creating intermediate objects (ensure_subobjects) - add typed set<T>/get<T> convenience methods via convert<T> - add JSON deep-copy methods (set_json/get_json) for cross-context value cloning - add bulk save_from/restore_to for migrating named values between contexts - add 12-case test suite covering lifecycle, move semantics, and cross-context survival - register context_store in CMake build system (header-only and compiled modes)
- add IsConstructCall() guard in class.ipp constructor callback to throw a JS exception instead of crashing when a bound class is called without new - add test_gc_stress.cpp: bulk 10k object lifecycle, mixed C++/JS lifespans, rapid create-destroy cycles, inheritance cleanup (raw_ptr and shared_ptr) - add test_adversarial.cpp: adversarial JS tests (Proxy, defineProperty, Object.freeze, null prototype, constructor-without-new, prototype swap, wrong-receiver calls, deep prototype chains) and exception safety tests (throwing ctor/method/property, use-after-destroy) - add test_thread_safety.cpp: concurrent isolates, cross-isolate shared_ptr (sequential + concurrent), isolate independence with same-named classes - fix test_type_info.cpp for PRETTIFY_TYPENAMES=OFF with conditional checks and unconditional ID uniqueness/stability/alias/nonzero assertions - update test/CMakeLists.txt and test/main.cpp to register new tests
- update actions/checkout from v2 to v4 (Node 12 EOL) - update gha-setup-ninja from v3 to v5 (Node 20) - add permissions: contents: read for least-privilege security - add concurrency group to cancel stale in-flight runs - set fail-fast: false to surface all platform failures - add timeout-minutes: 30 to prevent stuck jobs - cache NuGet V8 packages on Windows - upload CTest logs as artifacts on failure
- update CI badge URL to MangelSpec/v8pp fork - remove upstream-specific badges (NPM, Gitter, DeepWiki) - add fork introduction with link back to upstream pmed/v8pp - update requirements to C++20 and V8 9.0+ - add "What this fork adds" section covering performance, crash safety, new binding features, expanded type conversions, V8 API compatibility, and C++20 modernization - add usage examples for function overloading, default parameters, symbol protocols, iterators, and promise support - add full type conversion table (25 types including BigInt, span, ArrayBuffer, set, pair, path, chrono) - add class binding example showing const_property - update build instructions to Ninja-based workflow - present V8 installation and CMake options as tables - add V8PP_PRETTIFY_TYPENAMES and V8_ENABLE_SANDBOX to CMake options table - consolidate external object section (reference_external + import_external) - remove verbose file_reader/file_writer plugin example, keep console example - add License and Upstream sections - add test log upload step on CI failure
- fix typo "sandoxing" → "sandboxing" in V8_ENABLE_SANDBOX option description - remove commented-out CMAKE_CXX_RTTI and source_group dead code in v8pp/CMakeLists.txt - remove obsolete /experimental:external MSVC flag (unnecessary on MSVC 2022+) - add explicit PRIVATE visibility to target_link_libraries() in test and plugin targets - use modern add_test(NAME ... COMMAND ...) syntax with target names instead of hardcoded paths - use idiomatic option() for boolean cache variables instead of set(... CACHE BOOL) - add find_dependency(V8) to Config.cmake.in so find_package(v8pp) consumers auto-resolve V8
…veDataProperty - replace options.fallback with options.isolate->ThrowError() in fast_api.hpp (fallback member removed in V8 12.9+) - remove v8::DEFAULT (AccessControl) from SetNativeDataProperty calls in class.hpp V8 12.9+ paths - add V8 12.9+ version guards to SetNativeDataProperty calls in module.hpp
…mpatibility - change convert<T> for 64-bit integers to produce v8::Number instead of v8::BigInt - keep from_v8 accepting both Number and BigInt for interop - add safe-integer check (±2^53) in variant try_as for 64-bit integrals from Number - reorder variant IsNumber() dispatch to try is_large_integral before is_floating_point - add is_large_integral fallback to IsInt32()/IsUint32() variant branch - update tests to expect Number output and use double-safe range values - remove int64_t+uint64_t from mixed variant order test, test them individually - update CLAUDE.md type conversion table
- guard v8-fast-api-calls.h include with __has_include for distros that ship V8 10+ without the header (Ubuntu libv8-dev), define V8PP_HAS_FAST_API_HEADER macro used in fast_api.hpp and function.hpp - replace exact JSON.stringify(Y) string comparison in test_class with order-independent property validation for V8 13.0+ compatibility - add missing template keyword on .inherit<GCBase>() in test_gc_stress.cpp for strict AppleClang 17 - suppress unused parameter warnings for receiver/options in free-function fast_callback - remove unused GetClass and property_type aliases in class_::const_property
- fix time_point round-trip off-by-1ms by converting through integer milliseconds instead of double-precision nanosecond scaling - use integer milliseconds in time_point to_v8 for consistency - make JSON.stringify(Y) test order-independent for V8 13.0+ property enumeration changes - guard v8-fast-api-calls.h with __has_include for distros that ship V8 10+ without the header, define V8PP_HAS_FAST_API_HEADER macro - add missing template keyword on .inherit<GCBase>() for AppleClang 17 - skip unnecessary context/isolate creation in test main when no scripts are provided - suppress unused receiver/options parameter warnings in free-function fast_callback - remove unused GetClass and property_type aliases in const_property
Add BUILD_BENCHMARKS cmake option (OFF by default) to build the bench/ benchmark suite.
Support linking against a custom V8 library via CUSTOM_V8_LIB_PATH and CUSTOM_V8_INCLUDE_PATH cmake variables. Handles single-file libs (.a/.so/.lib/.dylib) or a directory of static libs. Links winmm and dbghelp on Windows, sets static CRT (/MT) to match V8 monolith builds. Also accepts a pre-existing V8::V8 target via add_subdirectory. Enables CMP0091 policy for CMAKE_MSVC_RUNTIME_LIBRARY support.
On Windows, std::filesystem::path(std::string) interprets the string using the ANSI codepage, not UTF-8. V8 strings are UTF-8, so non-ASCII paths were silently mangled in both directions (JS->C++ and C++->JS). Convert through wstring via MultiByteToWideChar/WideCharToMultiByte for correct UTF-8 round-tripping on Windows.
… build stringapiset.h transitively includes winnt.h which expects _AMD64_ to be defined, but that macro is normally set up by windef.h (via windows.h). Since we include stringapiset.h directly, we need to bridge this ourselves.
stringapiset.h transitively includes winnt.h which expects _AMD64_, and minwindef.h which defines min/max macros that break std::numeric_limits.
- add call_ctor_entry helpers to overload.hpp for constructor multi-dispatch - add ctor(factory, defaults) overload to class_ for factory functions with default parameters - add ctor(f1, f2, ...) overload to class_ for multi-dispatch constructors with first-match-wins dispatch - add fast_function property overloads to class_ using SetAccessorProperty (read-only and read-write) - add fast_function property overloads to module using SetAccessorProperty (read-only and read-write) - add requires constraint on existing property() in class_ and module to disambiguate from fast_function overloads - add ctor factory+defaults, multi-dispatch, and multi-dispatch+with_defaults tests to test_class.cpp - add fast class property and fast module property tests to test_fast_api.cpp
Add clang-format lint job Add ccache for Linux/macOS builds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
call_ctor_entryhelpers tooverload.hppfor constructor multi-dispatchctor(factory, defaults)overload toclass_for factory functions with default parametersctor(f1, f2, ...)overload toclass_for multi-dispatch constructors with first-match-wins dispatchclass_usingSetAccessorProperty(read-only and read-write)moduleusingSetAccessorProperty(read-only and read-write)requiresconstraint on existingproperty()inclass_andmoduleto disambiguate from fast_function overloadstest_class.cpptest_fast_api.cpp