mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-18 18:43:41 +00:00
Add a constructee parameter to ConstructorType
This commit is contained in:
parent
8dd9fb8554
commit
d0104cacfb
@ -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> &);
|
||||||
|
@ -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";
|
||||||
|
@ -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);
|
||||||
|
@ -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));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user