PetterS / quickjs

Thin Python wrapper of https://bellard.org/quickjs/
https://github.com/bellard/QuickJS
MIT License
177 stars 19 forks source link

Allow calling Python code from JS. #29

Closed PetterS closed 4 years ago

PetterS commented 4 years ago

Fixes #27.

Passing more complicated objects than simple types (int, bool, str) is not supported and will have to be JSON decoded manually.

SeaHOH commented 4 years ago

This API can only add callable to global scope now, whether need be more flexible?

SeaHOH commented 4 years ago

We are not sure whether the API was called success now. e.g.

context.eval("let f;")
context.add_callable("f", lambda x: x + 2)  # no throw
context.eval("f(1);")  # throw at here
PetterS commented 4 years ago

We are not sure whether the API was called success now. e.g.

Not sure how to fix this. JS_SetPropertyStr returns success.

PetterS commented 4 years ago

If arg is null, we should deallocate args and throw an OOM error. I guess PyTuple_SET_ITEM will crash otherwise?

Done, but I can not trigger this in unit tests since this conversion "always" succeeds.

PetterS commented 4 years ago

Time limits are now disallowed when calling into Python.

PetterS commented 4 years ago

use name here, maybe it makes for nicer stack traces

Yes, thanks, missed that.