Add a constructee parameter to ConstructorType

This commit is contained in:
Yavor Georgiev 2017-06-16 14:07:22 +02:00
parent 8dd9fb8554
commit d0104cacfb
No known key found for this signature in database
GPG Key ID: 83FC145DA0CCA9C3
4 changed files with 7 additions and 7 deletions

View File

@ -28,7 +28,7 @@ namespace realm {
namespace js { namespace js {
template<typename T> template<typename T>
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<typename T> template<typename T>
using MethodType = void(typename T::Context, typename T::Function, typename T::Object, size_t, const typename T::Value[], ReturnValue<T> &); using MethodType = void(typename T::Context, typename T::Function, typename T::Object, size_t, const typename T::Value[], ReturnValue<T> &);

View File

@ -187,7 +187,7 @@ public:
#endif #endif
// static methods // 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 SharedRealm create_shared_realm(ContextType, realm::Realm::Config, bool, ObjectDefaultsMap &&, ConstructorMap &&);
static void schema_version(ContextType, FunctionType, ObjectType, size_t, const ValueType[], ReturnValue &); 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<typename T> template<typename T>
void RealmClass<T>::constructor(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[]) { void RealmClass<T>::constructor(ContextType ctx, FunctionType constructor_function, ObjectType this_object, size_t argc, const ValueType arguments[]) {
realm::Realm::Config config; realm::Realm::Config config;
ObjectDefaultsMap defaults; ObjectDefaultsMap defaults;
ConstructorMap constructors; ConstructorMap constructors;
@ -353,7 +353,7 @@ void RealmClass<T>::constructor(ContextType ctx, ObjectType this_object, size_t
} }
#if REALM_ENABLE_SYNC #if REALM_ENABLE_SYNC
SyncClass<T>::populate_sync_config(ctx, Value::validated_to_object(ctx, Object::get_property(ctx, this_object, "Sync")), object, config); SyncClass<T>::populate_sync_config(ctx, Value::validated_to_object(ctx, Object::get_property(ctx, constructor_function, "Sync")), object, config);
#endif #endif
static const String path_string = "path"; static const String path_string = "path";

View File

@ -228,7 +228,7 @@ inline JSValueRef ObjectWrap<ClassType>::call(JSContextRef ctx, JSObjectRef func
// Classes without a constructor should still be subclassable. // Classes without a constructor should still be subclassable.
if (reinterpret_cast<void*>(s_class.constructor)) { if (reinterpret_cast<void*>(s_class.constructor)) {
try { try {
s_class.constructor(ctx, this_object, argc, arguments); s_class.constructor(ctx, function, this_object, argc, arguments);
} }
catch (std::exception &e) { catch (std::exception &e) {
*exception = jsc::Exception::value(ctx, e); *exception = jsc::Exception::value(ctx, e);
@ -248,7 +248,7 @@ inline JSObjectRef ObjectWrap<ClassType>::construct(JSContextRef ctx, JSObjectRe
JSObjectRef this_object = create_instance(ctx); JSObjectRef this_object = create_instance(ctx);
try { try {
s_class.constructor(ctx, this_object, argc, arguments); s_class.constructor(ctx, constructor, this_object, argc, arguments);
} }
catch (std::exception &e) { catch (std::exception &e) {
*exception = jsc::Exception::value(ctx, e); *exception = jsc::Exception::value(ctx, e);

View File

@ -237,7 +237,7 @@ inline void ObjectWrap<ClassType>::construct(const v8::FunctionCallbackInfo<v8::
wrap->Wrap(this_object); wrap->Wrap(this_object);
try { 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) { catch (std::exception &e) {
Nan::ThrowError(node::Exception::value(isolate, e)); Nan::ThrowError(node::Exception::value(isolate, e));