diff options
Diffstat (limited to 'intl/locale/LocaleService.cpp')
-rw-r--r-- | intl/locale/LocaleService.cpp | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/intl/locale/LocaleService.cpp b/intl/locale/LocaleService.cpp index 2d3429d688..7a84ae2449 100644 --- a/intl/locale/LocaleService.cpp +++ b/intl/locale/LocaleService.cpp @@ -5,7 +5,6 @@ #include "LocaleService.h" -#include "jsapi.h" #include "mozilla/ClearOnShutdown.h" #include "mozilla/Services.h" #include "nsIObserverService.h" @@ -61,15 +60,6 @@ LocaleService::GetAppLocales(nsTArray<nsCString>& aRetVal) } void -LocaleService::GetAppLocale(nsACString& aRetVal) -{ - if (mAppLocales.IsEmpty()) { - ReadAppLocales(mAppLocales); - } - aRetVal = mAppLocales[0]; -} - -void LocaleService::Refresh() { nsTArray<nsCString> newLocales; @@ -88,31 +78,28 @@ LocaleService::Refresh() * mozILocaleService methods */ NS_IMETHODIMP -LocaleService::GetAppLocales(JSContext* aCtx, JS::MutableHandleValue aRetVal) +LocaleService::GetAppLocales(uint32_t* aCount, char*** aOutArray) { if (mAppLocales.IsEmpty()) { ReadAppLocales(mAppLocales); } - uint32_t appLocalesNum = mAppLocales.Length(); - - JS::RootedObject locales(aCtx, JS_NewArrayObject(aCtx, appLocalesNum)); - JS::Rooted<JS::Value> value(aCtx); + *aCount = mAppLocales.Length(); + *aOutArray = static_cast<char**>(moz_xmalloc(*aCount * sizeof(char*))); - for (size_t i = 0; i < appLocalesNum; i++) { - const nsCString& loc = mAppLocales[i]; - JSString* str = JS_NewStringCopyN(aCtx, loc.get(), loc.Length()); - value.setString(str); - JS_DefineElement(aCtx, locales, i, value, JSPROP_ENUMERATE); + for (uint32_t i = 0; i < *aCount; i++) { + (*aOutArray)[i] = moz_xstrdup(mAppLocales[i].get()); } - aRetVal.setObject(*locales); return NS_OK; } NS_IMETHODIMP -LocaleService::GetAppLocale(JSContext* aCtx, nsACString& aRetVal) +LocaleService::GetAppLocale(nsACString& aRetVal) { - GetAppLocale(aRetVal); + if (mAppLocales.IsEmpty()) { + ReadAppLocales(mAppLocales); + } + aRetVal = mAppLocales[0]; return NS_OK; }
\ No newline at end of file |