本文整理汇总了C++中JS_DestroyRuntime函数的典型用法代码示例。如果您正苦于以下问题:C++ JS_DestroyRuntime函数的具体用法?C++ JS_DestroyRuntime怎么用?C++ JS_DestroyRuntime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JS_DestroyRuntime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sm_stop
void sm_stop(spidermonkey_vm *vm) {
begin_request(vm);
spidermonkey_state *state = (spidermonkey_state *) JS_GetContextPrivate(vm->context);
state->terminate = 1;
JS_SetContextPrivate(vm->context, state);
//Wait for any executing function to stop
//before beginning to free up any memory.
while (JS_IsRunning(vm->context)) {
sleep(1);
}
end_request(vm);
//Now we should be free to proceed with
//freeing up memory without worrying about
//crashing the VM.
if (state != NULL) {
if (state->error != NULL) {
free_error(state);
}
driver_free(state);
}
JS_SetContextPrivate(vm->context, NULL);
JS_DestroyContext(vm->context);
JS_DestroyRuntime(vm->runtime);
driver_free(vm);
}
示例2: JS_DestroyRuntime
JsParser::~JsParser() {
/** The world is over */
// JS_DestroyContext(js_context);
JS_DestroyRuntime(js_runtime);
JS_ShutDown();
func("JsParser::close()");
}
示例3: lwqq_js_close
void lwqq_js_close(lwqq_js_t* js)
{
JS_DestroyContext(js->context);
JS_DestroyRuntime(js->runtime);
JS_ShutDown();
s_free(js);
}
示例4: gjs_runtime_destroy
/**
* gjs_runtime_destroy:
* @runtime: a #JSRuntime
*
* Calls JS_DestroyRuntime() on runtime and frees data allocated by
* gjs_runtime_init(); these are unified into a single call because we
* need to order things so that the allocated data is cleaned up
* after JS_DestroyRuntime(). We might have finalizers run by
* JS_DestroyRuntime() that rely on the information stored in the data,
* such as the dynamic class structs.
*
* This should only be called by GJS, not by applications.
*/
void
gjs_runtime_destroy(JSRuntime *runtime)
{
RuntimeData *rd;
void *key;
void *value;
rd = JS_GetRuntimePrivate(runtime);
if (rd->context_stack != NULL || rd->current_frame.depth != 0)
gjs_fatal("gjs_runtime_destroy() called during gjs_push_context()");
gjs_debug(GJS_DEBUG_CONTEXT,
"Destroying JS runtime");
JS_DestroyRuntime(runtime);
gjs_debug(GJS_DEBUG_CONTEXT,
"Destroying any remaining dataset items on runtime");
while (gjs_g_hash_table_remove_one(rd->dynamic_classes, &key, &value)) {
JSClass *clasp = value;
gjs_debug(GJS_DEBUG_GREPO,
"Finalizing dynamic class '%s'",
clasp->name);
g_free( (char*) clasp->name); /* we know we malloc'd the char* even though it's const */
g_slice_free(DynamicJSClass, (DynamicJSClass*) clasp);
}
g_hash_table_destroy(rd->dynamic_classes);
g_slice_free(RuntimeData, rd);
}
示例5: main
int main(int argc, const char *argv[]) {
/* Initialize the JS engine -- new/required as of SpiderMonkey 31. */
/*if (!JS_Init())
return 1;*/
/* Create a JS runtime. */
JSRuntime *rt = JS_NewRuntime(8L * 1024L * 1024L, JS_NO_HELPER_THREADS);
if (!rt)
return 1;
/* Create a context. */
JSContext *cx = JS_NewContext(rt, 8192);
if (!cx)
return 1;
JS_SetOptions(cx, JSOPTION_VAROBJFIX);
JS_SetErrorReporter(cx, reportError);
int status = run(cx);
JS_DestroyContext(cx);
JS_DestroyRuntime(rt);
/* Shut down the JS engine. */
JS_ShutDown();
return status;
}
示例6: _egueb_script_js_sm_scripter_free
static void _egueb_script_js_sm_scripter_free(void *prv)
{
Egueb_Script_Js_Sm_Scripter *thiz = prv;
JS_DestroyContext(thiz->cx);
JS_DestroyRuntime(thiz->rt);
free(thiz);
}
示例7: ClearReceivers
void
JetpackChild::CleanUp()
{
ClearReceivers();
JS_DestroyContext(mCx);
JS_DestroyRuntime(mRuntime);
JS_ShutDown();
}
示例8: qq_js_close
void qq_js_close(qq_js_t* js)
{
JS_DestroyContext(js->context);
JS_DestroyRuntime(js->runtime);
JS_ShutDown();
/*something wrong here*/
//s_free(js);
}
示例9: Runtime_dealloc
void
Runtime_dealloc(Runtime* self)
{
if(self->rt != NULL)
{
JS_DestroyRuntime(self->rt);
}
}
示例10: cleanup_smjs
void
cleanup_smjs(struct module *module)
{
if (!smjs_ctx) return;
JS_DestroyContext(smjs_ctx);
JS_DestroyRuntime(smjs_rt);
}
示例11: SpidermonkeyDestroy
void SpidermonkeyDestroy()
{// begin SpidermonkeyDestroy
#ifdef ADM_JS_THREADSAFE
JS_SetContextThread(g_pCx);
#endif
JS_DestroyContext(g_pCx);
JS_DestroyRuntime(g_pRt);
}// end SpidermonkeyDestroy
示例12: TerminateSpiderMonkey
void TerminateSpiderMonkey(JSContext * context) {
if (terminated) return;
JS_DestroyContext(context);
JS_DestroyRuntime(runtime);
JS_ShutDown();
terminated = true;
}
示例13: main
int main(int argc, const char *argv[]) {
/* JS variables. */
JSRuntime *rt;
JSContext *cx;
JSObject *global;
/* Create a JS runtime. */
rt = JS_NewRuntime(8L * 1024L * 1024L,JS_NO_HELPER_THREADS);
if (rt == NULL)
return 1;
/* Create a context. */
cx = JS_NewContext(rt, 8192);
if (cx == NULL)
return 1;
JS_SetOptions(cx, JSOPTION_VAROBJFIX | JSOPTION_METHODJIT);
JS_SetVersion(cx, JSVERSION_LATEST);
JS_SetErrorReporter(cx, reportError);
/* Create the global object in a new compartment. */
global = JS_NewGlobalObject(cx, &global_class, NULL);
if (global == NULL)
return 1;
/* Populate the global object with the standard globals, like Object and Array. */
if (!JS_InitStandardClasses(cx, global))
return 1;
/* Your application code here. This may include JSAPI calls
* to create your own custom JavaScript objects and to run scripts.
*
* The following example code creates a literal JavaScript script,
* evaluates it, and prints the result to stdout.
*
* Errors are conventionally saved in a JSBool variable named ok.
*/
JS_DefineFunction(cx,global,"print",&js_print,0,0);
// execJsFile(cx,"t.js");
// testObj(cx);
beforeTest(cx);
execJsFile(cx,"t4.js");
test(cx);
/* End of your application code */
/* Clean things up and shut down SpiderMonkey. */
JS_DestroyContext(cx);
JS_DestroyRuntime(rt);
JS_ShutDown();
return 0;
}
示例14: ctxs_free
static void ctxs_free(ctxStore *self)
{
if (!self) return;
if (self->ctx) JS_DestroyContext(self->ctx);
if (self->run) JS_DestroyRuntime(self->run);
if (self->cls) px_free(self->cls);
px_free(self->pac);
px_free(self);
}
示例15: exitProgram
short exitProgram(JSContext *cx){ //To be called at the very end - Shutdown the whole application
if(cx)
JS_DestroyContext(cx);
JS_DestroyRuntime(runtime);
TTF_Quit();
SDL_DestroyRenderer(renderer);
SDL_Quit();
JS_ShutDown();
return 0;
}