/** * Return an XPCLocaleCallbacks out of |cx|. Callers must know that * |cx| has an XPCLocaleCallbacks; i.e., the checks in MaybeThis() * would be pointless to run from the calling context. * * NB: If the returned XPCLocaleCallbacks hasn't yet been bound to a * thread, then a side effect of calling This() is to bind it to the * calling thread. */ static XPCLocaleCallbacks* This(JSContext* cx) { XPCLocaleCallbacks* ths = static_cast<XPCLocaleCallbacks*>(JS_GetLocaleCallbacks(cx)); ths->AssertThreadSafety(); return ths; }
/** * Return the XPCLocaleCallbacks that's hidden away in |rt|. (This impl uses * the locale callbacks struct to store away its per-runtime data.) */ static XPCLocaleCallbacks* This(JSRuntime *rt) { // Locale information for |rt| was associated using xpc_LocalizeRuntime; // assert and double-check this. JSLocaleCallbacks* lc = JS_GetLocaleCallbacks(rt); MOZ_ASSERT(lc); MOZ_ASSERT(lc->localeToUpperCase == LocaleToUpperCase); MOZ_ASSERT(lc->localeToLowerCase == LocaleToLowerCase); MOZ_ASSERT(lc->localeCompare == LocaleCompare); MOZ_ASSERT(lc->localeToUnicode == LocaleToUnicode); XPCLocaleCallbacks* ths = static_cast<XPCLocaleCallbacks*>(lc); ths->AssertThreadSafety(); return ths; }