diff options
author | Paul Gardiner <paul@glidos.net> | 2012-07-09 11:08:54 +0100 |
---|---|---|
committer | Paul Gardiner <paul@glidos.net> | 2012-07-09 11:08:54 +0100 |
commit | b3a52c4786ab4d9b119dec48ebcc66751e573f5e (patch) | |
tree | 28fcb3a9e4d55b521e4c29b95ec7d75b195c4dfe /pdf | |
parent | ef952db0446b755acf81ee3a0349cecd3246f241 (diff) | |
download | mupdf-b3a52c4786ab4d9b119dec48ebcc66751e573f5e.tar.xz |
Javascript: add some comments on v8 implementation
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/pdf_jsimp_v8.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/pdf/pdf_jsimp_v8.cpp b/pdf/pdf_jsimp_v8.cpp index 27eb0a12..70234d0f 100644 --- a/pdf/pdf_jsimp_v8.cpp +++ b/pdf/pdf_jsimp_v8.cpp @@ -334,12 +334,19 @@ extern "C" char *pdf_jsimp_new_obj_cpp(pdf_jsimp *imp, pdf_jsimp_type *type, voi Local<Object> obj = vType->templ->NewInstance(); obj->SetInternalField(0, External::New(natobj)); - /* Arrange for destructor to be called on the client sire object + /* Arrange for destructor to be called on the client-side object * when the v8 object is garbage collected */ if (vType->dtr) { + /* Wrap obj in a PDFJSImpGCObj, which takes a persistent handle to + * obj, and stores its type with it. The persistent handle tells v8 + * it cannot just destroy obj leaving the client-side object hanging */ PDFJSImpGCObj *gco = new PDFJSImpGCObj(obj, vType); + /* Keep the wrapped object in a list, so that we can take back control + * of destroying client-side objects when shutting down this context */ vType->imp->gclist.insert(gco); + /* Tell v8 that it can destroy the persistent handle to obj when it has + * no further need for it, but it must inform us via gcCallback */ gco->pobj.MakeWeak(gco, gcCallback); } |