File: objectwrap_multiple_inheritance.cc

package info (click to toggle)
node-addon-api 8.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,248 kB
  • sloc: cpp: 15,431; javascript: 5,631; ansic: 157; makefile: 7
file content (30 lines) | stat: -rw-r--r-- 758 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <napi.h>

class TestMIBase {
 public:
  TestMIBase() : test(0) {}
  virtual void dummy() {}
  uint32_t test;
};

class TestMI : public TestMIBase, public Napi::ObjectWrap<TestMI> {
 public:
  TestMI(const Napi::CallbackInfo& info) : Napi::ObjectWrap<TestMI>(info) {}

  Napi::Value GetTest(const Napi::CallbackInfo& info) {
    return Napi::Number::New(info.Env(), test);
  }

  static void Initialize(Napi::Env env, Napi::Object exports) {
    exports.Set(
        "TestMI",
        DefineClass(
            env, "TestMI", {InstanceAccessor<&TestMI::GetTest>("test")}));
  }
};

Napi::Object InitObjectWrapMultipleInheritance(Napi::Env env) {
  Napi::Object exports = Napi::Object::New(env);
  TestMI::Initialize(env, exports);
  return exports;
}