nodejs / nodejs/node-addon-api
Enforce callback signatures with C++ Concepts
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.4k
- Forks
- 499
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 2
Description
#1738 documented the required signature of the templated finalizer callback parameters as inline comment hints.
These are human-only annotations. The compiler does not enforce them, so a mismatched callable fails deep inside the template instantiation with an unhelpful error.
Once C++20 is the minimum supported standard, we should replace these hints with C++ Concepts that constrain the Finalizer/FinalizerType template parameters. This gives compiler-enforced contracts and clear diagnostics at the call site.
Finalizer candidates:
BasicEnv::PostFinalizerObject::AddFinalizerExternal::NewBuffer::New/Buffer::NewOrCopyThreadSafeFunction::NewTypedThreadSafeFunction::New
Callback candidates:
Function::New— the JS callback (Callable)PropertyDescriptor::Accessor—Getter/SetterPropertyDescriptor::Function—CallableThreadSafeFunction::BlockingCall/NonBlockingCall—CallbackTypedThreadSafeFunction::BlockingCall/NonBlockingCall—CallbackTypedThreadSafeFunction— theCallJscallback
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the inline signature annotations from #1738 and the listed template entry points, including BasicEnv::PostFinalizer, Object::AddFinalizer, External::New, Buffer::New, and the ThreadSafeFunction APIs. Determine the constraints needed for each Finalizer, Callable, Getter, Setter, and Callback candidate. Done means C++20 Concepts enforce the documented signatures and produce diagnostics at the call site.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100