mirror of
https://github.com/status-im/realm-js.git
synced 2025-02-03 02:05:21 +00:00
Fix event_loop_dispatcher
This commit is contained in:
parent
33bb01be11
commit
4751aca0dc
@ -50,7 +50,11 @@ private:
|
|||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
public:
|
public:
|
||||||
State(std::function<void(Args...)> func) : m_func(func), m_signal(nullptr) { }
|
State(std::function<void(Args...)> func) :
|
||||||
|
m_func(func),
|
||||||
|
m_signal(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
const std::function<void(Args...)> m_func;
|
const std::function<void(Args...)> m_func;
|
||||||
std::queue<Tuple> m_invocations;
|
std::queue<Tuple> m_invocations;
|
||||||
@ -71,7 +75,7 @@ private:
|
|||||||
::_apply_polyfill::apply(tuple, m_state->m_func);
|
::_apply_polyfill::apply(tuple, m_state->m_func);
|
||||||
m_state->m_invocations.pop();
|
m_state->m_invocations.pop();
|
||||||
}
|
}
|
||||||
m_state->m_signal = nullptr;
|
m_state->m_signal.reset();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const std::shared_ptr<EventLoopSignal<Callback>> m_signal;
|
const std::shared_ptr<EventLoopSignal<Callback>> m_signal;
|
||||||
|
@ -151,6 +151,7 @@ struct Function {
|
|||||||
using ObjectType = typename T::Object;
|
using ObjectType = typename T::Object;
|
||||||
using ValueType = typename T::Value;
|
using ValueType = typename T::Value;
|
||||||
|
|
||||||
|
static ValueType callback(ContextType, const FunctionType &, const ObjectType &, size_t, const ValueType[]);
|
||||||
static ValueType call(ContextType, const FunctionType &, const ObjectType &, size_t, const ValueType[]);
|
static ValueType call(ContextType, const FunctionType &, const ObjectType &, size_t, const ValueType[]);
|
||||||
template<size_t N> static ValueType call(ContextType ctx, const FunctionType &function,
|
template<size_t N> static ValueType call(ContextType ctx, const FunctionType &function,
|
||||||
const ObjectType &this_object, const ValueType (&arguments)[N])
|
const ObjectType &this_object, const ValueType (&arguments)[N])
|
||||||
|
@ -33,6 +33,11 @@ inline JSValueRef jsc::Function::call(JSContextRef ctx, const JSObjectRef &funct
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline JSValueRef jsc::Function::callback(JSContextRef ctx, const JSObjectRef &function, const JSObjectRef &this_object, size_t argc, const JSValueRef arguments[]) {
|
||||||
|
return jsc::Function::call(ctx, function, this_object, argc, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline JSObjectRef jsc::Function::construct(JSContextRef ctx, const JSObjectRef &function, size_t argc, const JSValueRef arguments[]) {
|
inline JSObjectRef jsc::Function::construct(JSContextRef ctx, const JSObjectRef &function, size_t argc, const JSValueRef arguments[]) {
|
||||||
JSValueRef exception = nullptr;
|
JSValueRef exception = nullptr;
|
||||||
|
@ -36,6 +36,19 @@ inline v8::Local<v8::Value> node::Function::call(v8::Isolate* isolate, const v8:
|
|||||||
return result.ToLocalChecked();
|
return result.ToLocalChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline v8::Local<v8::Value> node::Function::callback(v8::Isolate* isolate, const v8::Local<v8::Function> &function, const v8::Local<v8::Object> &this_object, size_t argc, const v8::Local<v8::Value> arguments[]) {
|
||||||
|
Nan::TryCatch trycatch;
|
||||||
|
|
||||||
|
auto recv = this_object.IsEmpty() ? isolate->GetCurrentContext()->Global() : this_object;
|
||||||
|
auto result = Nan::MakeCallback(recv, function, (int)argc, const_cast<v8::Local<v8::Value>*>(arguments));
|
||||||
|
|
||||||
|
if (trycatch.HasCaught()) {
|
||||||
|
throw node::Exception(isolate, trycatch.Exception());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline v8::Local<v8::Object> node::Function::construct(v8::Isolate* isolate, const v8::Local<v8::Function> &function, size_t argc, const v8::Local<v8::Value> arguments[]) {
|
inline v8::Local<v8::Object> node::Function::construct(v8::Isolate* isolate, const v8::Local<v8::Function> &function, size_t argc, const v8::Local<v8::Value> arguments[]) {
|
||||||
Nan::TryCatch trycatch;
|
Nan::TryCatch trycatch;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user