implementing-jsc-classes-cpp

Implement JavaScript classes in C++ using JavaScriptCore bindings.

Updated Dec 27, 2025
One-click install
npx skills add https://github.com/brendadeeznuts1111/mybundocs11 --skill implementing-jsc-classes-cpp-brendadeeznuts1111
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: implementing-jsc-classes-cpp
Source: https://github.com/brendadeeznuts1111/mybundocs11/tree/main/bun-docs-repo/.claude/skills/implementing-jsc-classes-cpp
Command: npx skills add https://github.com/brendadeeznuts1111/mybundocs11 --skill implementing-jsc-classes-cpp-brendadeeznuts1111

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a comprehensive guide to implementing JavaScript classes in C++ using JavaScriptCore, enabling seamless native bindings, prototypes, and constructors for embedding native objects in a JS runtime.

Core Features & Use Cases

  • Define C++ classes that map to JavaScript objects using JSC::DestructibleObject when needed and create prototype and constructor bindings.
  • Provide sample patterns for Foo, FooPrototype, and FooConstructor, including iso subspaces when C++ fields exist.
  • Use cases include exposing high-performance native APIs to JS code, enabling seamless interop between C++ and the JS runtime in Bun-like environments.

Quick Start

Steps to implement:

  • Create C++ classes following the Foo pattern (Foo, FooPrototype, FooConstructor).
  • Implement prototype/constructor bindings and any necessary iso subspaces.
  • Wire the classes into the JS engine (VM, Structure, and global bindings) and build.

Frequently Asked Questions about implementing-jsc-classes-cpp

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement JavaScript classes in C++ using JavaScriptCore?

To implement JavaScript classes in C++ using JavaScriptCore, you define C++ classes mapping to JS objects using JSC::DestructibleObject, create Foo, FooPrototype, and FooConstructor bindings, and wire them into the VM and global object.

When do I need iso subspaces for JSC prototype and constructor bindings?

Iso subspaces are needed for JSC bindings when your C++ class contains C++ fields. Wiring them ensures proper memory management and garbage collection for native objects exposed to the JavaScriptCore runtime.

Does this JSC C++ binding approach work in Bun-like environments?

Yes, this JavaScriptCore C++ binding approach applies to Bun-like environments, enabling seamless interop between native C++ objects and the JS runtime through prototype, constructor, and subspace wiring.

What C++ version and tools are required to bridge native objects with JavaScriptCore?

Bridging native objects with JavaScriptCore requires a C++14+ toolchain, access to JavaScriptCore and JSC APIs, and familiarity with prototype, constructor bindings, and optional subspace wiring.

What is the best way to expose high-performance native APIs to JavaScriptCore?

The best way to expose high-performance native APIs to JavaScriptCore is implementing C++ classes with JSC::DestructibleObject, defining prototype and constructor bindings, and wiring iso subspaces for native fields.