New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delphi support? #1
Comments
Thanks, Yes i'm working on it. |
Great!
|
Yes i know about it, but first of all it's size is very big like 20 MB but QJS is like 1MB only I agree with "Microsoft has abandoned ChakraCore" i think they don't care too much as they moved to chromium. "QuickJS must be simpler than ChakraCore" it's the simplest implementation i've ever seen for a JS Engine As Bellard says in the docs
Plus QJS Main Features is amazing with very small code and small memory
"better support for integrating with the host (Delphi)" So i'm willing to support this project for long time, as i move from BESEN engine in my Cmulator project to QJS. Sorry for late reply i was very busy. |
@Coldzer0 No need to be sorry about the late reply, and I really appreciate you answering my questions! I'm looking forward to the Delphi version so that I can have a look at it ;) |
I finished the Delphi Support 😄 |
Great @Coldzer0 !
Will look further. |
Oh I see, the compiled program must be run with a parameter which is the js file you want to run. My results of running apihook.js:
And hello_module.js with error:
|
Thanks for testing, that's very helpful.
the result looks Ok 😄
this one happen on windows only, you need to write your own js_module_loader the c implementation JSModuleDef *js_module_loader(JSContext *ctx,
const char *module_name, void *opaque)
{
JSModuleDef *m;
if (has_suffix(module_name, ".so")) {
m = js_module_loader_so(ctx, module_name);
} else {
size_t buf_len;
uint8_t *buf;
JSValue func_val;
buf = js_load_file(ctx, &buf_len, module_name);
if (!buf) {
JS_ThrowReferenceError(ctx, "could not load module filename '%s'",
module_name);
return NULL;
}
/* compile the module */
func_val = JS_Eval(ctx, (char *)buf, buf_len, module_name,
JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_COMPILE_ONLY);
js_free(ctx, buf);
if (JS_IsException(func_val))
return NULL;
/* the module is already referenced, so we must free it */
m = JS_VALUE_GET_PTR(func_val);
JS_FreeValue(ctx, func_val);
}
return m;
} It's not hard to write your own one. JS_SetModuleLoaderFunc(rt, nil, @js_module_loader, nil); |
Thanks @Coldzer0 , it's useful. |
I already work on auto object binding for native classes I finished the Register Native Class with I'll push it after some testing 👍 |
That's a great choice man! Looking forward to the new update :) |
I already did ^_^, in this commit. |
I |
Thanks, I noticed it. And the next part also makes me exciting ^_^
|
I didn’t complete it yet because I stuck with some stuff like calling a published function from a class QJS don’t know about the “Self” Param so it’s a bit harder to implement it without make changes in the QJS core But it should work fine with any “class function” So we can declare all the native methods with class before it’s name And if we need to use the self object i did make a work around by setting it to an property in the js object related to the class But I’ll give it another try 👌 |
This is a great project! Do you have a plan to support Delphi? Thanks.
The text was updated successfully, but these errors were encountered: