diff --git a/src/js_class.hpp b/src/js_class.hpp index 70b28e2e..4b5f8d7d 100644 --- a/src/js_class.hpp +++ b/src/js_class.hpp @@ -28,7 +28,7 @@ namespace realm { namespace js { template -using ConstructorType = void(typename T::Context, typename T::Object, size_t, const typename T::Value[]); +using ConstructorType = void(typename T::Context, typename T::Function, typename T::Object, size_t, const typename T::Value[]); template using MethodType = void(typename T::Context, typename T::Function, typename T::Object, size_t, const typename T::Value[], ReturnValue &); diff --git a/src/js_realm.hpp b/src/js_realm.hpp index 5627446a..1cb12208 100644 --- a/src/js_realm.hpp +++ b/src/js_realm.hpp @@ -187,7 +187,7 @@ public: #endif // static methods - static void constructor(ContextType, ObjectType, size_t, const ValueType[]); + static void constructor(ContextType, FunctionType, ObjectType, size_t, const ValueType[]); static SharedRealm create_shared_realm(ContextType, realm::Realm::Config, bool, ObjectDefaultsMap &&, ConstructorMap &&); static void schema_version(ContextType, FunctionType, ObjectType, size_t, const ValueType[], ReturnValue &); @@ -327,7 +327,7 @@ static inline void convert_outdated_datetime_columns(const SharedRealm &realm) { } template -void RealmClass::constructor(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[]) { +void RealmClass::constructor(ContextType ctx, FunctionType constructor_function, ObjectType this_object, size_t argc, const ValueType arguments[]) { realm::Realm::Config config; ObjectDefaultsMap defaults; ConstructorMap constructors; @@ -353,7 +353,7 @@ void RealmClass::constructor(ContextType ctx, ObjectType this_object, size_t } #if REALM_ENABLE_SYNC - SyncClass::populate_sync_config(ctx, Value::validated_to_object(ctx, Object::get_property(ctx, this_object, "Sync")), object, config); + SyncClass::populate_sync_config(ctx, Value::validated_to_object(ctx, Object::get_property(ctx, constructor_function, "Sync")), object, config); #endif static const String path_string = "path"; diff --git a/src/jsc/jsc_class.hpp b/src/jsc/jsc_class.hpp index 6e6f7618..e04daf29 100644 --- a/src/jsc/jsc_class.hpp +++ b/src/jsc/jsc_class.hpp @@ -228,7 +228,7 @@ inline JSValueRef ObjectWrap::call(JSContextRef ctx, JSObjectRef func // Classes without a constructor should still be subclassable. if (reinterpret_cast(s_class.constructor)) { try { - s_class.constructor(ctx, this_object, argc, arguments); + s_class.constructor(ctx, function, this_object, argc, arguments); } catch (std::exception &e) { *exception = jsc::Exception::value(ctx, e); @@ -248,7 +248,7 @@ inline JSObjectRef ObjectWrap::construct(JSContextRef ctx, JSObjectRe JSObjectRef this_object = create_instance(ctx); try { - s_class.constructor(ctx, this_object, argc, arguments); + s_class.constructor(ctx, constructor, this_object, argc, arguments); } catch (std::exception &e) { *exception = jsc::Exception::value(ctx, e); diff --git a/src/node/node_class.hpp b/src/node/node_class.hpp index 21cddad6..ea473c20 100644 --- a/src/node/node_class.hpp +++ b/src/node/node_class.hpp @@ -237,7 +237,7 @@ inline void ObjectWrap::construct(const v8::FunctionCallbackInfoWrap(this_object); try { - s_class.constructor(isolate, this_object, arguments.size(), arguments.data()); + s_class.constructor(isolate, info.Callee(), this_object, arguments.size(), arguments.data()); } catch (std::exception &e) { Nan::ThrowError(node::Exception::value(isolate, e));