nodejs / nodejs/node-addon-api
Enforce callback signatures with C++ Concepts
还没有人认领这个 Issue。
- 主要语言
- C++
- 星标
- 2.4k
- 派生
- 499
- 平均合并
- 2 天 11 小时
- 30 天内合并 PR
- 2
描述
#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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
检查 #1738 中的内联签名注解以及列出的模板入口点,包括 BasicEnv::PostFinalizer、Object::AddFinalizer、External::New、Buffer::New 和 ThreadSafeFunction APIs。确定每个 Finalizer、Callable、Getter、Setter 和 Callback 候选项所需的约束。完成标准是由 C++20 Concepts 强制执行文档中规定的签名,并在调用点生成诊断信息。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- cpp
- 领域
- api
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 52/100