Why do these two examples need a static FunctionReference?

オープン
#169 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
45/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
cpp, nodejs

調査の方向性

Read function-reference-demo/node-addon-api/src/native-addon.cc and inherits_from_event_emitter/node-addon-api/src/native-emitter.cc, focusing on the static FunctionReference declarations in Init. Compare them with the instance-data change in commit dc86a662c27c5732e069e1c19d3b7a8e74e86d29. Done means the examples no longer retain unnecessary constructor references while continuing to build and work.

索引モデルが issue の本文から書いたものです。

説明

https://github.com/nodejs/node-addon-examples/blob/c1bdff050f8c7dc250f7779283fbab664bfb5bcd/function-reference-demo/node-addon-api/src/native-addon.cc#L4
https://github.com/nodejs/node-addon-examples/blob/c1bdff050f8c7dc250f7779283fbab664bfb5bcd/inherits_from_event_emitter/node-addon-api/src/native-emitter.cc#L7

It's not referred anywhere other than the Init function and having an "immortal" Napi::FunctionReference seems unnecessary since the constructor isn't invoked from native code.

Curiously, these two examples were untouched by dc86a662c27c5732e069e1c19d3b7a8e74e86d29, which replaced the usage of a static FunctionReference with instance data in examples that do need to keep the constructor alive.

主要言語
C++
スター
2.6k
フォーク
602
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nodejs/node-addon-examples のほかの issue

nodejs/node-addon-examples の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。