Silence warnings about member function pointers

The base ClassDefinition defines its constructor member as null, but some subclass have a static constructor function. This allows both cases to be handled without a warning.
This commit is contained in:
Scott Kyle 2016-06-01 09:42:17 -07:00
parent 43f7329047
commit 6d524107e0
2 changed files with 4 additions and 4 deletions

View File

@ -169,7 +169,7 @@ inline JSClassRef ObjectWrap<ClassType>::create_constructor_class() {
// This must be set for `typeof constructor` to be 'function'.
definition.callAsFunction = call;
if (s_class.constructor) {
if (reinterpret_cast<void*>(s_class.constructor)) {
definition.callAsConstructor = construct;
}
if (!s_class.static_methods.empty()) {
@ -226,7 +226,7 @@ inline JSValueRef ObjectWrap<ClassType>::call(JSContextRef ctx, JSObjectRef func
}
// Classes without a constructor should still be subclassable.
if (s_class.constructor) {
if (reinterpret_cast<void*>(s_class.constructor)) {
try {
s_class.constructor(ctx, this_object, argc, arguments);
}
@ -241,7 +241,7 @@ inline JSValueRef ObjectWrap<ClassType>::call(JSContextRef ctx, JSObjectRef func
template<typename ClassType>
inline JSObjectRef ObjectWrap<ClassType>::construct(JSContextRef ctx, JSObjectRef constructor, size_t argc, const JSValueRef arguments[], JSValueRef* exception) {
if (!s_class.constructor) {
if (!reinterpret_cast<void*>(s_class.constructor)) {
*exception = jsc::Exception::value(ctx, s_class.name + " is not a constructor");
return nullptr;
}

View File

@ -226,7 +226,7 @@ inline void ObjectWrap<ClassType>::construct(Nan::NAN_METHOD_ARGS_TYPE info) {
if (!info.IsConstructCall()) {
Nan::ThrowError("Constructor must be called with new");
}
if (s_class.constructor) {
if (reinterpret_cast<void*>(s_class.constructor)) {
auto isolate = info.GetIsolate();
auto arguments = get_arguments(info);
v8::Local<v8::Object> this_object = info.This();