Skip to content

Enforce callback signatures with C++ Concepts #1746

Description

@legendecas

#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::新建
  • Buffer::新建 / Buffer::新建OrCopy
  • ThreadSafeFunction::新建
  • TypedThreadSafeFunction::新建

Callback candidates:

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    项目

    Status
    Need Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions