-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix wrap/unwrap of objects inheriting from non-ObjectWrap PR-URL: #732 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Nicola Del Gobbo <[email protected]>
- Loading branch information
1 parent
31504c8
commit ba7ad37
Showing
6 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
|
||
const buildType = process.config.target_defaults.default_configuration; | ||
const assert = require('assert'); | ||
|
||
const test = bindingName => { | ||
const binding = require(bindingName); | ||
const TestMI = binding.objectwrap_multiple_inheritance.TestMI; | ||
const testmi = new TestMI(); | ||
|
||
assert.strictEqual(testmi.test, 0); | ||
} | ||
|
||
test(`./build/${buildType}/binding.node`); | ||
test(`./build/${buildType}/binding_noexcept.node`); |