static int js_init(void) { JSContext *cx; jsval val; JS_SetCStringsAreUTF8(); runtime = JS_NewRuntime(0x1000000); cx = js_newctx(err_reporter); JS_BeginRequest(cx); showtimeobj = JS_NewObject(cx, &showtime_class, NULL, NULL); JS_DefineFunctions(cx, showtimeobj, showtime_functions); val = INT_TO_JSVAL(showtime_get_version_int()); JS_SetProperty(cx, showtimeobj, "currentVersionInt", &val); val = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, htsversion)); JS_SetProperty(cx, showtimeobj, "currentVersionString", &val); JSFunction *fn = JS_DefineFunction(cx, showtimeobj, "RichText", js_RichText, 1, 0); RichText = JS_GetFunctionObject(fn); JS_AddNamedRoot(cx, &showtimeobj, "showtime"); JS_EndRequest(cx); JS_DestroyContext(cx); return 0; }
static int js_init(void) { JSContext *cx; JS_SetCStringsAreUTF8(); runtime = JS_NewRuntime(0x1000000); cx = js_newctx(err_reporter); JS_BeginRequest(cx); showtimeobj = JS_NewObject(cx, &showtime_class, NULL, NULL); JS_DefineFunctions(cx, showtimeobj, showtime_functions); JSFunction *fn = JS_DefineFunction(cx, showtimeobj, "RichText", js_RichText, 1, 0); RichText = JS_GetFunctionObject(fn); JS_AddNamedRoot(cx, &showtimeobj, "showtime"); JS_EndRequest(cx); JS_DestroyContext(cx); return 0; }
bool round_js_sm_engine_init(RoundJavaScriptEngine* engine) { if (!engine) return NULL; JS_SetCStringsAreUTF8(); engine->cx = NULL; engine->rt = NULL; engine->obj = NULL; engine->rt = JS_NewRuntime(8L * 1024L * 1024L); if (!engine->rt) return false; engine->cx = JS_NewContext(engine->rt, 8192); if (!engine->cx) return false; JS_SetErrorReporter(engine->cx, RoundJSReportError); // Obsolete since JSAPI 16 engine->obj = JS_NewCompartmentAndGlobalObject(engine->cx, &RoundJSGlobalClass, NULL); if (!engine->obj) return false; JS_InitStandardClasses(engine->cx, engine->obj); JS_DefineFunctions(engine->cx, engine->obj, JS_SM_FUNCTIONS); return true; }
ScriptingCore::ScriptingCore() : rt(NULL) , cx(NULL) , global(NULL) { // set utf8 strings internally (we don't need utf16) JS_SetCStringsAreUTF8(); this->addRegisterCallback(registerDefaultClasses); }
static char * command__js_utf8(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { JS_SetCStringsAreUTF8(); if (JS_CStringsAreUTF8()) { return NGX_CONF_OK; } else { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "couldn't set JS_CStringsAreUTF8()", &cmd->name); return NGX_CONF_ERROR; } }
void Init_spidermonkey() { JS_SetCStringsAreUTF8(); VALUE johnson = rb_const_get(rb_mKernel, rb_intern("Johnson")); VALUE spidermonkey = rb_define_module_under(johnson, "SpiderMonkey"); init_Johnson_SpiderMonkey_Context(spidermonkey); init_Johnson_SpiderMonkey_Proxy(spidermonkey); init_Johnson_SpiderMonkey_Debugger(spidermonkey); init_Johnson_SpiderMonkey_Immutable_Node(spidermonkey); init_Johnson_SpiderMonkey_Runtime(spidermonkey); rb_define_const(spidermonkey, "VERSION", rb_obj_freeze(rb_str_new2(JS_GetImplementationVersion()))); }
int main(int argc, char *argv[]) { int total = 0; int failures = 0; const char *filter = (argc == 2) ? argv[1] : NULL; JS_SetCStringsAreUTF8(); for (JSAPITest *test = JSAPITest::list; test; test = test->next) { const char *name = test->name(); if (filter && strstr(name, filter) == NULL) continue; total += 1; printf("%s\n", name); if (!test->init()) { printf("TEST-UNEXPECTED-FAIL | %s | Failed to initialize.\n", name); failures++; continue; } JS::HandleObject global = JS::HandleObject::fromMarkedLocation(&test->global); if (test->run(global)) { printf("TEST-PASS | %s | ok\n", name); } else { JSAPITestString messages = test->messages(); printf("%s | %s | %.*s\n", (test->knownFail ? "TEST-KNOWN-FAIL" : "TEST-UNEXPECTED-FAIL"), name, (int) messages.length(), messages.begin()); if (!test->knownFail) failures++; } test->uninit(); } if (failures) { printf("\n%d unexpected failure%s.\n", failures, (failures == 1 ? "" : "s")); return 1; } printf("\nPassed: ran %d tests.\n", total); return 0; }
void SG_jscore__new_runtime( SG_context * pCtx, JSContextCallback cb, JSFunctionSpec *shell_functions, SG_bool bSkipModules, JSRuntime **ppRt ) { char * szSsjsMutable = NULL; if(gpJSCoreGlobalState != NULL) SG_ERR_THROW_RETURN(SG_ERR_ALREADY_INITIALIZED); SG_ERR_CHECK( SG_alloc1(pCtx, gpJSCoreGlobalState) ); // Store this for later. gpJSCoreGlobalState->cb = cb; gpJSCoreGlobalState->shell_functions = shell_functions; gpJSCoreGlobalState->bSkipModules = bSkipModules; if (! bSkipModules) SG_ERR_CHECK( _sg_jscore_getpaths(pCtx) ); SG_ERR_CHECK( SG_mutex__init(pCtx, &gpJSCoreGlobalState->mutexJsNamed) ); SG_ERR_CHECK( SG_RBTREE__ALLOC(pCtx, &gpJSCoreGlobalState->prbJSMutexes) ); // Start up SpiderMonkey. JS_SetCStringsAreUTF8(); gpJSCoreGlobalState->rt = JS_NewRuntime(64L * 1024L * 1024L); // TODO decide the right size here if(gpJSCoreGlobalState->rt==NULL) SG_ERR_THROW2(SG_ERR_JS, (pCtx, "Failed to allocate JS Runtime")); if (ppRt) *ppRt = gpJSCoreGlobalState->rt; return; fail: SG_NULLFREE(pCtx, szSsjsMutable); SG_PATHNAME_NULLFREE(pCtx, gpJSCoreGlobalState->pPathToDispatchDotJS); SG_PATHNAME_NULLFREE(pCtx, gpJSCoreGlobalState->pPathToModules); }
void sm_configure_locale() { JS_SetCStringsAreUTF8(); }
static int emonk_init() { if(!JS_CStringsAreUTF8()) JS_SetCStringsAreUTF8(); return 0; }