[quickjs-devel] Get Global Property not working when eval with JS_EVAL_TYPE_MODULE

  • From: Coldzer0 <coldzer0x0@xxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Fri, 20 Mar 2020 22:32:25 +0200

Hello Bellard,

I've a small project running js code with (written in freepascal)

JS_EVAL_TYPE_GLOBAL or JS_EVAL_TYPE_MODULE

and this code where i get an update function defined in the js code

// Execute our JS File.
if not eval_file(QJSCtx, Script, JS_EVAL_TYPE_GLOBAL or
JS_EVAL_TYPE_MODULE) then
Halt;

js_std_loop(QJSCtx);

OnUpdate := JS_GetPropertyStr(QJSCtx, JSGlobal, 'update');
Writeln(OnUpdate.tag);
if not JS_IsFunction(QJSCtx, OnUpdate) then
begin
WritelnLog('update function is not defined !!!');
Halt();
end;

if i removed the JS_EVAL_TYPE_MODULE the code can get the obj for update
function
but with it return JS_TAG_UNDEFINED

Regards.

-- 

Coldzer0

F204 44EF CC37 DC2E C1C3 26F6 694B 1BB4 981D FF9C

Other related posts:

  • » [quickjs-devel] Get Global Property not working when eval with JS_EVAL_TYPE_MODULE - Coldzer0