Composition and Inheritance of Wrapped Objects Examples

Aberta
#72 2 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
45/100
Tipo de issue
Documentação
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
cpp, nodejs
Domínio
documentation

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
C++
Estrelas
2.6k
Forks
602
Métricas de merge de PRs
Nenhum PR com merge em 30d

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de nodejs/node-addon-examples

Todas as issues de nodejs/node-addon-examples

Issues semelhantes

Mais issues de C++

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.