quickjspp
quickjspp copied to clipboard
quickjspp v2
This changes the way pointers are stored in JS objects.
| v1 (branch master) | v2 (branch sharedptr) | |
|---|---|---|
| js object holds opaque pointer to | std::shared_ptr<T> |
T |
std::shared_ptr<T> conversion |
yes | no |
qjs::shared_ptr<T> conversion |
no | yes |
T* conversion |
yes | only if T has qjs::enable_shared_from_this<T> as base class |
| extra allocations when converting from C++ pointer to JS object | yes(slower) | no(faster) |
| weak_ptr and deleter support | std | not yet |
| inheritance support | yes | limited |
| creating c++ objects | new,std::make_shared |
qjs::make_shared |
| <!-- | class can evaluate js code | no |
current v2 limitations:
qjs::make_sharedneeds JSContext- all
qjs::shared_ptrinstances need to be destroyed before js context is destroyed
Also fixes bugs where JS properties are not saved
looks great, will give it a try when ready :)
small bit of feedback, i tried implementing this branch over last weekend to see how itd go with the changes. requiring classes to be inherited from enable_shared_from_this is a bit of a pain in an existing codebase, was much better in V1 where things can be auto exposed. even if i want to have a class that will only be created natively in JS i still need to inherit from that which doesnt seem nessecary
@SamHellawell I'm agree with you !
enable_shared_from_this is a bad idea.