mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 02:25:34 +00:00
Branch landing: Multithreading libmocha in mozilla.
- Add JS_BeginRequest and JS_EndRequest calls - Add context parameters to some functions
This commit is contained in:
parent
22be0fa5fb
commit
e5bf3349f6
@ -367,19 +367,30 @@ PREF_Init(char *filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_SetVersion(m_mochaContext, JSVERSION_1_2);
|
||||
JS_BeginRequest(m_mochaContext);
|
||||
|
||||
m_GlobalConfigObject = JS_NewObject(m_mochaContext, &global_class, NULL, NULL);
|
||||
if (!m_GlobalConfigObject)
|
||||
if (!m_GlobalConfigObject) {
|
||||
JS_EndRequest(m_mochaContext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!JS_InitStandardClasses(m_mochaContext, m_GlobalConfigObject))
|
||||
/* MLM - need a global object for set version call now. */
|
||||
JS_SetGlobalObject(m_mochaContext, m_GlobalConfigObject);
|
||||
|
||||
JS_SetVersion(m_mochaContext, JSVERSION_1_2);
|
||||
|
||||
if (!JS_InitStandardClasses(m_mochaContext,
|
||||
m_GlobalConfigObject)) {
|
||||
JS_EndRequest(m_mochaContext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_SetBranchCallback(m_mochaContext, pref_BranchCallback);
|
||||
JS_SetErrorReporter(m_mochaContext, NULL);
|
||||
|
||||
m_mochaPrefObject = JS_DefineObject(m_mochaContext, m_GlobalConfigObject,
|
||||
m_mochaPrefObject = JS_DefineObject(m_mochaContext,
|
||||
m_GlobalConfigObject,
|
||||
"PrefConfig",
|
||||
&autoconf_class,
|
||||
NULL,
|
||||
@ -389,12 +400,14 @@ PREF_Init(char *filename)
|
||||
if (!JS_DefineProperties(m_mochaContext,
|
||||
m_mochaPrefObject,
|
||||
autoconf_props)) {
|
||||
JS_EndRequest(m_mochaContext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!JS_DefineFunctions(m_mochaContext,
|
||||
m_mochaPrefObject,
|
||||
autoconf_methods)) {
|
||||
JS_EndRequest(m_mochaContext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -403,6 +416,8 @@ PREF_Init(char *filename)
|
||||
#if !defined(XP_WIN) && !defined(XP_OS2)
|
||||
ok = pref_InitInitialObjects();
|
||||
#endif
|
||||
} else {
|
||||
JS_BeginRequest(m_mochaContext);
|
||||
}
|
||||
|
||||
if (ok && filename) {
|
||||
@ -411,6 +426,7 @@ PREF_Init(char *filename)
|
||||
else if (!ok) {
|
||||
m_ErrorOpeningUserPrefs = TRUE;
|
||||
}
|
||||
JS_EndRequest(m_mochaContext);
|
||||
return ok;
|
||||
}
|
||||
|
||||
@ -420,8 +436,10 @@ PREF_GetConfigContext(JSContext **js_context)
|
||||
if (!js_context) return FALSE;
|
||||
|
||||
*js_context = NULL;
|
||||
if (m_mochaContext)
|
||||
if (m_mochaContext) {
|
||||
*js_context = m_mochaContext;
|
||||
JS_SetContextThread(m_mochaContext);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -504,6 +522,7 @@ PREF_EvaluateConfigScript(const char * js_buffer, size_t length,
|
||||
if (!m_mochaContext || !scope)
|
||||
return JS_FALSE;
|
||||
|
||||
JS_BeginRequest(m_mochaContext);
|
||||
errReporter = JS_SetErrorReporter(m_mochaContext, pref_ErrorReporter);
|
||||
m_CallbacksEnabled = bCallbacks;
|
||||
|
||||
@ -513,6 +532,7 @@ PREF_EvaluateConfigScript(const char * js_buffer, size_t length,
|
||||
m_CallbacksEnabled = TRUE; /* ?? want to enable after reading user/lock file */
|
||||
JS_SetErrorReporter(m_mochaContext, errReporter);
|
||||
|
||||
JS_EndRequest(m_mochaContext);
|
||||
return ok;
|
||||
}
|
||||
|
||||
@ -536,9 +556,11 @@ PREF_QuietEvaluateJSBuffer(const char * js_buffer, size_t length)
|
||||
if (!m_mochaContext || !m_mochaPrefObject)
|
||||
return PREF_NOT_INITIALIZED;
|
||||
|
||||
JS_BeginRequest(m_mochaContext);
|
||||
ok = JS_EvaluateScript(m_mochaContext, m_mochaPrefObject,
|
||||
js_buffer, length, NULL, 0, &result);
|
||||
|
||||
JS_EndRequest(m_mochaContext);
|
||||
/* Hey, this really returns a JSBool */
|
||||
return ok;
|
||||
}
|
||||
@ -552,8 +574,10 @@ PREF_QuietEvaluateJSBufferWithGlobalScope(const char * js_buffer, size_t length)
|
||||
if (!m_mochaContext || !m_GlobalConfigObject)
|
||||
return PREF_NOT_INITIALIZED;
|
||||
|
||||
JS_BeginRequest(m_mochaContext);
|
||||
ok = JS_EvaluateScript(m_mochaContext, m_GlobalConfigObject,
|
||||
js_buffer, length, NULL, 0, &result);
|
||||
JS_EndRequest(m_mochaContext);
|
||||
|
||||
/* Hey, this really returns a JSBool */
|
||||
return ok;
|
||||
|
@ -367,19 +367,30 @@ PREF_Init(char *filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_SetVersion(m_mochaContext, JSVERSION_1_2);
|
||||
JS_BeginRequest(m_mochaContext);
|
||||
|
||||
m_GlobalConfigObject = JS_NewObject(m_mochaContext, &global_class, NULL, NULL);
|
||||
if (!m_GlobalConfigObject)
|
||||
if (!m_GlobalConfigObject) {
|
||||
JS_EndRequest(m_mochaContext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!JS_InitStandardClasses(m_mochaContext, m_GlobalConfigObject))
|
||||
/* MLM - need a global object for set version call now. */
|
||||
JS_SetGlobalObject(m_mochaContext, m_GlobalConfigObject);
|
||||
|
||||
JS_SetVersion(m_mochaContext, JSVERSION_1_2);
|
||||
|
||||
if (!JS_InitStandardClasses(m_mochaContext,
|
||||
m_GlobalConfigObject)) {
|
||||
JS_EndRequest(m_mochaContext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_SetBranchCallback(m_mochaContext, pref_BranchCallback);
|
||||
JS_SetErrorReporter(m_mochaContext, NULL);
|
||||
|
||||
m_mochaPrefObject = JS_DefineObject(m_mochaContext, m_GlobalConfigObject,
|
||||
m_mochaPrefObject = JS_DefineObject(m_mochaContext,
|
||||
m_GlobalConfigObject,
|
||||
"PrefConfig",
|
||||
&autoconf_class,
|
||||
NULL,
|
||||
@ -389,12 +400,14 @@ PREF_Init(char *filename)
|
||||
if (!JS_DefineProperties(m_mochaContext,
|
||||
m_mochaPrefObject,
|
||||
autoconf_props)) {
|
||||
JS_EndRequest(m_mochaContext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!JS_DefineFunctions(m_mochaContext,
|
||||
m_mochaPrefObject,
|
||||
autoconf_methods)) {
|
||||
JS_EndRequest(m_mochaContext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -403,6 +416,8 @@ PREF_Init(char *filename)
|
||||
#if !defined(XP_WIN) && !defined(XP_OS2)
|
||||
ok = pref_InitInitialObjects();
|
||||
#endif
|
||||
} else {
|
||||
JS_BeginRequest(m_mochaContext);
|
||||
}
|
||||
|
||||
if (ok && filename) {
|
||||
@ -411,6 +426,7 @@ PREF_Init(char *filename)
|
||||
else if (!ok) {
|
||||
m_ErrorOpeningUserPrefs = TRUE;
|
||||
}
|
||||
JS_EndRequest(m_mochaContext);
|
||||
return ok;
|
||||
}
|
||||
|
||||
@ -420,8 +436,10 @@ PREF_GetConfigContext(JSContext **js_context)
|
||||
if (!js_context) return FALSE;
|
||||
|
||||
*js_context = NULL;
|
||||
if (m_mochaContext)
|
||||
if (m_mochaContext) {
|
||||
*js_context = m_mochaContext;
|
||||
JS_SetContextThread(m_mochaContext);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -504,6 +522,7 @@ PREF_EvaluateConfigScript(const char * js_buffer, size_t length,
|
||||
if (!m_mochaContext || !scope)
|
||||
return JS_FALSE;
|
||||
|
||||
JS_BeginRequest(m_mochaContext);
|
||||
errReporter = JS_SetErrorReporter(m_mochaContext, pref_ErrorReporter);
|
||||
m_CallbacksEnabled = bCallbacks;
|
||||
|
||||
@ -513,6 +532,7 @@ PREF_EvaluateConfigScript(const char * js_buffer, size_t length,
|
||||
m_CallbacksEnabled = TRUE; /* ?? want to enable after reading user/lock file */
|
||||
JS_SetErrorReporter(m_mochaContext, errReporter);
|
||||
|
||||
JS_EndRequest(m_mochaContext);
|
||||
return ok;
|
||||
}
|
||||
|
||||
@ -536,9 +556,11 @@ PREF_QuietEvaluateJSBuffer(const char * js_buffer, size_t length)
|
||||
if (!m_mochaContext || !m_mochaPrefObject)
|
||||
return PREF_NOT_INITIALIZED;
|
||||
|
||||
JS_BeginRequest(m_mochaContext);
|
||||
ok = JS_EvaluateScript(m_mochaContext, m_mochaPrefObject,
|
||||
js_buffer, length, NULL, 0, &result);
|
||||
|
||||
JS_EndRequest(m_mochaContext);
|
||||
/* Hey, this really returns a JSBool */
|
||||
return ok;
|
||||
}
|
||||
@ -552,8 +574,10 @@ PREF_QuietEvaluateJSBufferWithGlobalScope(const char * js_buffer, size_t length)
|
||||
if (!m_mochaContext || !m_GlobalConfigObject)
|
||||
return PREF_NOT_INITIALIZED;
|
||||
|
||||
JS_BeginRequest(m_mochaContext);
|
||||
ok = JS_EvaluateScript(m_mochaContext, m_GlobalConfigObject,
|
||||
js_buffer, length, NULL, 0, &result);
|
||||
JS_EndRequest(m_mochaContext);
|
||||
|
||||
/* Hey, this really returns a JSBool */
|
||||
return ok;
|
||||
|
Loading…
Reference in New Issue
Block a user