prevent static member names crossing

This commit is contained in:
raub 2018-03-21 17:50:18 +03:00
parent 1965aed592
commit 58df0274b9
4 changed files with 11 additions and 11 deletions

View File

@ -15,7 +15,7 @@ using namespace std;
if (example->_isDestroyed) return;
Nan::Persistent<v8::Function> Example::_constructor;
Nan::Persistent<v8::Function> Example::_ctorExample;
void Example::init(Handle<Object> target) {
@ -23,7 +23,7 @@ void Example::init(Handle<Object> target) {
Local<FunctionTemplate> proto = Nan::New<FunctionTemplate>(newCtor);
// class Example extends EventEmitter
Local<FunctionTemplate> parent = Nan::New(EventEmitter::_prototype);
Local<FunctionTemplate> parent = Nan::New(EventEmitter::_protoEventEmitter);
proto->Inherit(parent);
proto->InstanceTemplate()->SetInternalFieldCount(1);
@ -35,7 +35,7 @@ void Example::init(Handle<Object> target) {
// -------- static
Local<Function> ctor = Nan::GetFunction(proto).ToLocalChecked();
_constructor.Reset(ctor);
_ctorExample.Reset(ctor);
Nan::Set(target, JS_STR("Example"), ctor);

View File

@ -28,7 +28,7 @@ private:
private:
static Nan::Persistent<v8::Function> _constructor;
static Nan::Persistent<v8::Function> _ctorExample;
bool _isDestroyed;

View File

@ -20,11 +20,11 @@
template <typename T>
class StaticHolder {
protected:
static Nan::Persistent<v8::FunctionTemplate> _prototype;
static Nan::Persistent<v8::Function> _constructor;
static Nan::Persistent<v8::FunctionTemplate> _protoEventEmitter;
static Nan::Persistent<v8::Function> _ctorEventEmitter;
};
template <typename T> Nan::Persistent<v8::FunctionTemplate> StaticHolder<T>::_prototype;
template <typename T> Nan::Persistent<v8::Function> StaticHolder<T>::_constructor;
template <typename T> Nan::Persistent<v8::FunctionTemplate> StaticHolder<T>::_protoEventEmitter;
template <typename T> Nan::Persistent<v8::Function> StaticHolder<T>::_ctorEventEmitter;
class EventEmitter : public StaticHolder<int>, public Nan::ObjectWrap {
@ -79,8 +79,8 @@ public:
Nan::SetMethod(ctorObj, "listenerCount", jsStaticListenerCount);
_constructor.Reset(ctor);
_prototype.Reset(proto);
_ctorEventEmitter.Reset(ctor);
_protoEventEmitter.Reset(proto);
Nan::Set(target, JS_STR("EventEmitter"), ctor);

View File

@ -2,7 +2,7 @@
"name": "addon-tools-raub",
"author": "Luis Blanco <raubtierxxx@gmail.com>",
"description": "A set of extra tools for Node.js addons",
"version": "0.1.3",
"version": "0.1.4",
"main": "index.js",
"keywords": [
"node",