feat: add public member access for Qore objects in V8#213
feat: add public member access for Qore objects in V8#213
Conversation
- Check saveQoreReference() failure in wrapExistingObject() to prevent premature GC of wrapped objects - Add missing newline at end of QoreV8Program.cpp - Support multiple inheritance by recursively adding methods, static methods, and constants from additional parent class hierarchies - Add cache lookup in namespace query() to avoid redundant lookups Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Set up GitLab CI with Ubuntu and Alpine test jobs that build the v8 module from source and run all Qore tests. Add GitHub webhook mirroring infrastructure and Copilot auto-review workflow for PRs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cmake needs NODE_LIB_DIR=/opt/nodejs/lib to find libnode in the qore-test-base image. Also run tests with --enable-debug for full test coverage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use transient references (tRef/tDeref) instead of real references (realRef/realDeref) for Qore objects held by V8, matching the pattern used in module-jni and module-python. This avoids strong reference cycles while keeping C++ memory alive for V8's weak callback cleanup. Also adds NODE_INCLUDE_DIR for Alpine CI where Node headers are at a non-standard path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The NamedPropertyHandlerConfiguration callbacks changed from returning void to v8::Intercepted in V8 12+ (Node.js 22+). Use preprocessor conditionals on V8_MAJOR_VERSION to support both old and new APIs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add V8 named property interceptors to InstanceTemplate of wrapped Qore classes, enabling transparent read/write access to public data members from JavaScript. Member metadata is cached per class template in QoreV8MemberHandlerData for O(1) lookups. kNonMasking flag ensures prototype methods are not shadowed by the interceptor. Also fix a latent V8 12+ bug in QoreV8NamespaceWrapper where returning kYes without setting a return value would crash. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This pull request adds comprehensive support for accessing Qore APIs (namespaces, classes, functions, constants, enums, and public data members) from JavaScript through a global qore object. The implementation uses V8 named property interceptors for transparent, lazy resolution and provides proper memory management with weak references and deterministic cleanup.
Changes:
- Added V8 namespace and class wrapper infrastructure with property interceptors for transparent access to Qore APIs from JavaScript
- Implemented member access interceptors with O(1) cached lookups for public data member read/write/enumeration
- Added comprehensive test suite (999 lines) with 10 sub-tests covering member access, inheritance, callbacks, and edge cases
- Updated documentation with examples and architecture details
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
test/v8-qore-import.qtest |
Comprehensive test suite with 22 test cases covering namespace access, class instantiation, methods, member access, and edge cases |
test/docker_test/test-ubuntu.sh |
Docker test script for Ubuntu CI builds |
test/docker_test/test-alpine.sh |
Docker test script for Alpine CI builds |
src/QoreV8Program.h |
Added class template cache, tracking sets for wrapper data, and new public methods for class wrapping |
src/QoreV8Program.cpp |
Injected qore global object, implemented cleanup logic, and added support for wrapping non-JavaScript Qore objects |
src/QoreV8NamespaceWrapper.h |
Header for namespace wrapper with data structures and interceptor declarations |
src/QoreV8NamespaceWrapper.cpp |
Implementation of namespace wrapper with named property interceptors for lazy resolution and caching |
src/QoreV8ClassWrapper.h |
Header for class wrapper with data structures for constructor, methods, and member access |
src/QoreV8ClassWrapper.cpp |
Implementation of class wrapper with FunctionTemplate, inheritance, and member access interceptors |
docs/mainpage.dox.tmpl |
Added comprehensive documentation with examples for namespace traversal, class usage, and member access |
design/qore-v8-integration.md |
Detailed design document explaining architecture, memory management, and implementation details |
CMakeLists.txt |
Added new source files to the build |
.gitlab-ci.yml |
Added GitLab CI configuration for Ubuntu and Alpine test runners |
.github/workflows/copilot-review.yml |
Added GitHub Actions workflow for automated Copilot review requests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- realRef/realDeref → tRef/tDeref in design doc (3 occurrences) - JAVASCRIPT-ERROR → JAVASCRIPT-MEMBER-ACCESS-ERROR in Doxygen docs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add assert() checks for v8::External data in all 4 member interceptors, matching the existing pattern used in other interceptors - Fix JAVASCRIPT-ERROR → JAVASCRIPT-MEMBER-ACCESS-ERROR in design doc getter flow description Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Analyze Jest JSON output to distinguish transient network/timeout failures from real test failures. Only transient issues (timeouts, connection errors, rate limits, DNS failures) are tolerated with a warning; real assertion failures still fail the pipeline. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The test account may not have any flow executions, causing the checkAllowedValues assertion to fail. Skip if no flow SID is available and allow empty results, matching the pattern used by the transcription test. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
InstanceTemplateof wrapped Qore classes, enabling transparent read/write access to public data members from JavaScriptQoreV8MemberHandlerDatawithstd::unordered_mapfor O(1) lookups instead of iteratingQoreClassMemberIteratoron every accesskNonMaskingflag so prototype methods take precedence over member interceptorsQoreV8NamespaceWrapperwhere returningkYeswithout setting a return value would crash withCheck failed: !IsTheHoleObject.keys(),inoperator, round-trip, nullable members, and JS-only propertiesTest plan
🤖 Generated with Claude Code