Composition and Inheritance of Wrapped Objects Examples

Offen
#72 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
45/100
Issue-Typ
Dokumentation
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
cpp, nodejs
Bereich
documentation

Rechercherichtung

Read the existing 6_object_wrap/node-addon-api example and the inherits_from_event_emitter/node-addon-api example first, including their build files and JavaScript usage. Add focused examples covering composition and inheritance of ObjectWrap-based C++ classes, with each class independently instantiable from JavaScript, and verify the examples build and run.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Can examples of composition and inheritance of wrapped objects be added? I think one could potentially figure it out with the current examples, but I'm not able to figure it out.

class BasicClass { int IntValue; };
class BasicComposition
{
    int foo;
    BasicClass bc;
};
class BasicInheritance : BasicClass
{
    double yValue;
};
class InheritanceAndComposition : BasicInheritance
{
    std::string strValue;
    BasicComposition bcValue;
};

// Export all classes to JS

One should be able to instantiate and use each C++ class in JavaScript (e.g. create an instance of BasicClass independent of instances of BasicComposition).

It seems to me that only the case of BasicClass has an example in 6_object_wrap. The other cases with inheritance and composition of classes extending ObjectWrap<T> do not appear to exist. Inheritance might be covered in inherits_from_event_emitter, but it is not clear to me what is going on in that example.

I'm hoping someone with more experience with node-addon-api can provide these types of examples. It would greatly assist me in defining more complex relationships in Napi.

Vorherrschende Sprache
C++
Sterne
2.6k
Forks
602
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus nodejs/node-addon-examples

Alle Issues in nodejs/node-addon-examples

Ähnliche Issues

Weitere Issues zu C++

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.