You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I load test_a.js along with native C++ function print (imported as module System) into context context, and test_b.js into context context2. Both belong to the same runtime.
My goal is to call func_a from test_a.js in context with the object test_object from test_b.js from context2 as an argument.
However, trying this (ignoring my contexts and methods which are actually from my own wrapper class):
qjs::Value test_obj_b = context2.get()->eval("test_object");
auto func_a = context.get()->eval("func_a").as<std::function<void(const qjs::Value&)>>();
func_a(test_obj_b);
results in the following: Assertion failed: ctx == v.ctx, file ../include/quickjspp/quickjspp.hpp, line 1807
Apparently when wrapping a JSValue into a Value, a check is performed to make sure the value is from the same context as the context it's being used in. However, I was under the impression from quickjs's documentation that sharing objects between contexts was possible ("There can be several JSContexts per JSRuntime and they can share objects[...]"), so I'm not sure if I'm doing something wrong with quickjspp, if this is intended behavior, or if I'm just missing some crucial piece of information in my basic idea.
EDIT: if I remove the assertion from quickjspp.hpp, things behave the way I expect, and "test_b.js" is output to the console. I imagine this might have consequences, though?
The text was updated successfully, but these errors were encountered:
Hi,
I have two files, test_a.js and test_b.js. Here they are:
test_a.js
test_b.js
I load test_a.js along with native C++ function
print
(imported as moduleSystem
) into contextcontext
, and test_b.js into contextcontext2
. Both belong to the same runtime.My goal is to call
func_a
from test_a.js incontext
with the objecttest_object
from test_b.js fromcontext2
as an argument.However, trying this (ignoring my contexts and methods which are actually from my own wrapper class):
results in the following:
Assertion failed: ctx == v.ctx, file ../include/quickjspp/quickjspp.hpp, line 1807
Apparently when wrapping a JSValue into a Value, a check is performed to make sure the value is from the same context as the context it's being used in. However, I was under the impression from quickjs's documentation that sharing objects between contexts was possible ("There can be several JSContexts per JSRuntime and they can share objects[...]"), so I'm not sure if I'm doing something wrong with quickjspp, if this is intended behavior, or if I'm just missing some crucial piece of information in my basic idea.
EDIT: if I remove the assertion from quickjspp.hpp, things behave the way I expect, and "test_b.js" is output to the console. I imagine this might have consequences, though?
The text was updated successfully, but these errors were encountered: