anchor_finalize(JSContext *cx, JSObject *obj) { JSAnchor *named_anchor; MochaDecoder *decoder; MWContext *context; lo_NameList *name_rec; named_anchor = JS_GetPrivate(cx, obj); if (!named_anchor) return; decoder = named_anchor->decoder; context = decoder->window_context; if (context) { LO_LockLayout(); name_rec = LO_GetNamedAnchorByIndex(context, named_anchor->layer_id, named_anchor->index); if (name_rec && name_rec->mocha_object == obj) name_rec->mocha_object = NULL; LO_UnlockLayout(); } DROP_BACK_COUNT(decoder); JS_UnlockGCThing(cx, named_anchor->text); JS_UnlockGCThing(cx, named_anchor->name); JS_free(cx, named_anchor); }
component_finalize(JSContext *cx, JSObject *obj) { JSComponent* component; component = JS_GetPrivate(cx, obj); if (!component) return; JS_UnlockGCThing(cx, component->name); DROP_BACK_COUNT(component->decoder); JS_free(cx, component); }
void CJSRuntime::ReleaseObject(IUEEntries iType, void *index) { JSOBJECTMAP_ITERATOR toSearch = objectList[iType].find(index); if (toSearch != objectList[iType].end()) { JSObject *toRelease = (*toSearch).second; JS_UnlockGCThing(jsContext, toRelease); //JS_RemoveRoot(jsContext, &toRelease); JS_SetPrivate(jsContext, toRelease, NULL); objectList[iType].erase(toSearch); } }
CJSRuntime::~CJSRuntime(void) { Cleanup(); JS_UnlockGCThing(jsContext, spellsObj); //JS_RemoveRoot(jsContext, &spellsObj); JS_UnlockGCThing(jsContext, accountsObj); //JS_RemoveRoot(jsContext, &accountsObj); JS_UnlockGCThing(jsContext, consoleObj); //JS_RemoveRoot(jsContext, &consoleObj); for (size_t i = JSP_ITEM; i < JSP_COUNT; ++i) { JS_UnlockGCThing(jsContext, protoList[i]); //JS_RemoveRoot(jsContext, &protoList[i]); } JS_UnlockGCThing(jsContext, jsGlobal); //JS_RemoveRoot(jsContext, &jsGlobal); JS_DestroyContext(jsContext); JS_DestroyRuntime(jsRuntime); }
void CJSRuntime::Cleanup(void) { std::vector< JSOBJECTMAP >::iterator oIter; for (oIter = objectList.begin(); oIter != objectList.end(); ++oIter) { JSOBJECTMAP& ourList = (*oIter); for (JSOBJECTMAP_ITERATOR lIter = ourList.begin(); lIter != ourList.end(); ++lIter) { JS_UnlockGCThing(jsContext, (*lIter).second); //JS_RemoveRoot(jsContext, &(*lIter).second); JS_SetPrivate(jsContext, (*lIter).second, NULL); } ourList.clear(); } objectList.resize(0); }