nodejs / nodejs/node-addon-api

Enforce callback signatures with C++ Concepts

未关闭
#1,746 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

blocked SemVer-major
主要语言
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::PostFinalizer
  • Object::AddFinalizer
  • External::New
  • Buffer::New / Buffer::NewOrCopy
  • ThreadSafeFunction::New
  • TypedThreadSafeFunction::New

Callback candidates:

  • Function::New — the JS callback (Callable)
  • PropertyDescriptor::AccessorGetter / Setter
  • PropertyDescriptor::FunctionCallable
  • ThreadSafeFunction::BlockingCall / NonBlockingCallCallback
  • TypedThreadSafeFunction::BlockingCall / NonBlockingCallCallback
  • TypedThreadSafeFunction — the CallJs callback

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 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

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。