gecko-dev/xpcom/base/nsMacPreferencesReader.mm

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

80 строки
2.8 KiB
Plaintext
Исходник Обычный вид История

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Bug 1733308 - Fix non-unified builds errors in xpcom/base. r=xpcom-reviewers,mccr8 objdir/dist/include/mozilla/DeferredFinalize.h:30:1: error: unknown type name 'MOZ_NEVER_INLINE' objdir/dist/include/mozilla/dom/BindingUtils.h:2776:5: error: no matching function for call to 'DeferredFinalize' xpcom/base/AvailableMemoryTracker.cpp:55,40:: error: expected class name xpcom/base/AvailableMemoryTracker.cpp:59,3:: error: 'AddRef' marked 'override' but does not override any member functions xpcom/base/AvailableMemoryTracker.cpp:59,3:: error: 'QueryInterface' marked 'override' but does not override any member functions xpcom/base/AvailableMemoryTracker.cpp:59,3:: error: 'Release' marked 'override' but does not override any member functions xpcom/base/AvailableMemoryTracker.cpp:61,29:: error: unknown type name 'nsIHandleReportCallback' xpcom/base/AvailableMemoryTracker.cpp:65,37:: error: use of undeclared identifier 'KIND_OTHER' xpcom/base/AvailableMemoryTracker.cpp:65,49:: error: use of undeclared identifier 'UNITS_COUNT_CUMULATIVE' xpcom/base/AvailableMemoryTracker.cpp:77,1:: error: invalid application of 'sizeof' to an incomplete type 'const QITableEntry []' xpcom/base/AvailableMemoryTracker.cpp:77,1:: error: static_cast from '(anonymous namespace)::LowEventsReporter *' to 'nsISupports *', which are not related by inheritance, is not allowed xpcom/base/AvailableMemoryTracker.cpp:77,38:: error: unknown type name 'nsIMemoryReporter' xpcom/base/AvailableMemoryTracker.cpp:77,38:: error: use of undeclared identifier 'nsIMemoryReporter' xpcom/base/AvailableMemoryTracker.cpp:187,3:: error: use of undeclared identifier 'RegisterLowMemoryEventsPhysicalDistinguishedAmount' xpcom/base/AvailableMemoryWatcherWin.cpp:31,47:: error: base class has incomplete type xpcom/base/AvailableMemoryWatcherWin.cpp:37,3:: error: unknown type name 'NS_DECL_NSIOBSERVER' xpcom/base/AvailableMemoryWatcherWin.cpp:38,3:: error: 'virtual' can only appear on non-static member functions xpcom/base/AvailableMemoryWatcherWin.cpp:38,3:: error: expected ';' at end of declaration list xpcom/base/AvailableMemoryWatcherWin.cpp:38,3:: error: static_assert failed due to requirement 'std::is_convertible<mozilla::nsAvailableMemoryWatcher *, nsINamed *>::value' "nsITimerCallback implementations must also implement nsINamed" xpcom/base/AvailableMemoryWatcherWin.cpp:39,3:: error: must use 'enum' tag to refer to type 'nsresult' in this scope xpcom/base/AvailableMemoryWatcherWin.cpp:42,3:: error: must use 'enum' tag to refer to type 'nsresult' in this scope xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: cannot initialize object parameter of type 'mozilla::nsAvailableMemoryWatcherBase' with an expression of type 'mozilla::nsAvailableMemoryWatcher' xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: invalid application of 'sizeof' to an incomplete type 'const QITableEntry []' xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: must use 'enum' tag to refer to type 'nsresult' in this scope xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: static_cast from 'mozilla::nsAvailableMemoryWatcher *' to 'nsINamed *', which are not related by inheritance, is not allowed xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: static_cast from 'mozilla::nsAvailableMemoryWatcher *' to 'nsIObserver *', which are not related by inheritance, is not allowed xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: static_cast from 'mozilla::nsAvailableMemoryWatcher *' to 'nsITimerCallback *', which are not related by inheritance, is not allowed xpcom/base/AvailableMemoryWatcherWin.cpp:103,59:: error: 'nsIObserver' does not refer to a value xpcom/base/AvailableMemoryWatcherWin.cpp:103,59:: error: incomplete type 'nsIObserver' named in nested name specifier xpcom/base/AvailableMemoryWatcherWin.cpp:140,45:: error: cannot initialize a parameter of type 'nsIObserver *' with an rvalue of type 'mozilla::nsAvailableMemoryWatcher *' xpcom/base/AvailableMemoryWatcherWin.cpp:140,5:: error: must use 'enum' tag to refer to type 'nsresult' in this scope xpcom/base/CycleCollectedJSRuntime.cpp:1605,7:: error: use of undeclared identifier 'PR_GetEnv' xpcom/base/CycleCollectedJSRuntime.cpp:1605:7: error: use of undeclared identifier 'PR_GetEnv' xpcom/base/DeferredFinalize.cpp:12,15:: error: out-of-line definition of 'DeferredFinalize' does not match any declaration in namespace 'mozilla' xpcom/base/DeferredFinalize.cpp:12:15: error: out-of-line definition of 'DeferredFinalize' does not match any declaration in namespace 'mozilla' xpcom/base/MemoryTelemetry.cpp:48,27:: error: unused variable 'kTotalMemoryCollectorTimeout' [-Werror,-Wunused-const-variable] xpcom/base/MemoryTelemetry.cpp:48:27: error: unused variable 'kTotalMemoryCollectorTimeout' [-Werror,-Wunused-const-variable] xpcom/base/nsErrorService.cpp:42,21:: error: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension [-Werror,-Wc++20-extensions] xpcom/base/nsErrorService.cpp:42,21:: error: use of undeclared identifier 'MakeUnique'; did you mean 'mozilla::MakeUnique'? xpcom/base/nsErrorService.cpp:42:21: error: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension [-Werror,-Wc++20-extensions] xpcom/base/nsErrorService.cpp:42:21: error: use of undeclared identifier 'MakeUnique'; did you mean 'mozilla::MakeUnique'? xpcom/base/nsMacPreferencesReader.mm:20:12: error: implicit instantiation of undefined template 'nsTSubstring<char16_t>' xpcom/base/nsMacPreferencesReader.mm:24:60: error: use of undeclared identifier 'NSString' xpcom/base/nsMacPreferencesReader.mm:24:69: error: expected expression xpcom/base/nsMacPreferencesReader.mm:26:48: error: unknown type name 'NSArray' xpcom/base/nsMacPreferencesReader.mm:28:30: error: use of undeclared identifier 'NSString' xpcom/base/nsMacPreferencesReader.mm:29:30: error: no matching function for call to 'MakeStringSpan' xpcom/base/nsMacPreferencesReader.mm:29:51: error: instance method '-UTF8String' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access] xpcom/base/nsMacPreferencesReader.mm:30:22: error: instance method '-isKindOfClass:' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access] xpcom/base/nsMacPreferencesReader.mm:30:37: error: receiver type 'int (*)(int)' is not 'id' or interface pointer, consider casting it to 'id' [-Werror,-Wreceiver-expr] xpcom/base/nsMacPreferencesReader.mm:30:37: error: use of undeclared identifier 'NSNumber'; did you mean 'isnumber'? xpcom/base/nsMacPreferencesReader.mm:30:46: error: instance method '-class' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access] xpcom/base/nsMacPreferencesReader.mm:31:27: error: cannot initialize a parameter of type 'int64_t' (aka 'long long') with an rvalue of type 'id' xpcom/base/nsMacPreferencesReader.mm:31:33: error: instance method '-longLongValue' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access] xpcom/base/nsMacPreferencesReader.mm:32:37: error: use of undeclared identifier 'NSArray' xpcom/base/nsMacPreferencesReader.mm:34:7: error: no matching function for call to 'EvaluateArray' xpcom/base/nsMacPreferencesReader.mm:36:37: error: use of undeclared identifier 'NSDictionary' xpcom/base/nsMacPreferencesReader.mm:38:7: error: no matching function for call to 'EvaluateDict' xpcom/base/nsMacPreferencesReader.mm:44:60: error: use of undeclared identifier 'NSString' xpcom/base/nsMacPreferencesReader.mm:44:69: error: expected expression xpcom/base/nsSystemInfo.cpp:415,35:: error: no template named 'NotNull'; did you mean 'NonNull'? xpcom/base/nsSystemInfo.cpp:419,25:: error: member reference type 'NonNull<IWSCProductList *>' is not a pointer; did you mean to use '.'? xpcom/base/nsSystemInfo.cpp:419,27:: error: no member named 'get_Count' in 'mozilla::dom::NonNull<IWSCProductList *>' xpcom/base/nsSystemInfo.cpp:426,19:: error: member reference type 'NonNull<IWSCProductList *>' is not a pointer; did you mean to use '.'? xpcom/base/nsSystemInfo.cpp:426,21:: error: no member named 'get_Item' in 'mozilla::dom::NonNull<IWSCProductList *>' xpcom/base/nsSystemInfo.cpp:484,17:: error: use of undeclared identifier 'ArrayLength'; did you mean 'mozilla::ArrayLength'? xpcom/base/nsSystemInfo.cpp:484,47:: error: use of undeclared identifier 'ArrayLength'; did you mean 'mozilla::ArrayLength'? xpcom/base/nsSystemInfo.cpp:487,36:: error: use of undeclared identifier 'ArrayLength'; did you mean 'mozilla::ArrayLength'? xpcom/base/nsSystemInfo.cpp:500,10:: error: no matching function for call to 'EnumWSCProductList' xpcom/base/nsSystemInfo.cpp:500,46:: error: use of undeclared identifier 'WrapNotNull'; did you mean 'mozilla::WrapNotNull'? xpcom/base/nsTraceRefcnt.cpp:313,32:: error: use of undeclared identifier 'MakeUnique' xpcom/base/nsTraceRefcnt.cpp:313:32: error: use of undeclared identifier 'MakeUnique' xpcom/base/nsTraceRefcnt.cpp:461,19:: error: no matching member function for call to 'WithEntryHandle' xpcom/base/nsTraceRefcnt.cpp:461:19: error: no matching member function for call to 'WithEntryHandle' xpcom/base/nsTraceRefcnt.cpp:468,33:: error: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension [-Werror,-Wc++20-extensions] xpcom/base/nsTraceRefcnt.cpp:468,33:: error: use of undeclared identifier 'MakeUnique' xpcom/base/nsTraceRefcnt.cpp:468:33: error: use of undeclared identifier 'MakeUnique' xpcom/base/nsTraceRefcnt.cpp:736,20:: error: use of undeclared identifier '_write' Differential Revision: https://phabricator.services.mozilla.com/D127036
2021-10-01 04:49:16 +03:00
#include "MacStringHelpers.h"
#include "nsMacPreferencesReader.h"
Bug 1733308 - Fix non-unified builds errors in xpcom/base. r=xpcom-reviewers,mccr8 objdir/dist/include/mozilla/DeferredFinalize.h:30:1: error: unknown type name 'MOZ_NEVER_INLINE' objdir/dist/include/mozilla/dom/BindingUtils.h:2776:5: error: no matching function for call to 'DeferredFinalize' xpcom/base/AvailableMemoryTracker.cpp:55,40:: error: expected class name xpcom/base/AvailableMemoryTracker.cpp:59,3:: error: 'AddRef' marked 'override' but does not override any member functions xpcom/base/AvailableMemoryTracker.cpp:59,3:: error: 'QueryInterface' marked 'override' but does not override any member functions xpcom/base/AvailableMemoryTracker.cpp:59,3:: error: 'Release' marked 'override' but does not override any member functions xpcom/base/AvailableMemoryTracker.cpp:61,29:: error: unknown type name 'nsIHandleReportCallback' xpcom/base/AvailableMemoryTracker.cpp:65,37:: error: use of undeclared identifier 'KIND_OTHER' xpcom/base/AvailableMemoryTracker.cpp:65,49:: error: use of undeclared identifier 'UNITS_COUNT_CUMULATIVE' xpcom/base/AvailableMemoryTracker.cpp:77,1:: error: invalid application of 'sizeof' to an incomplete type 'const QITableEntry []' xpcom/base/AvailableMemoryTracker.cpp:77,1:: error: static_cast from '(anonymous namespace)::LowEventsReporter *' to 'nsISupports *', which are not related by inheritance, is not allowed xpcom/base/AvailableMemoryTracker.cpp:77,38:: error: unknown type name 'nsIMemoryReporter' xpcom/base/AvailableMemoryTracker.cpp:77,38:: error: use of undeclared identifier 'nsIMemoryReporter' xpcom/base/AvailableMemoryTracker.cpp:187,3:: error: use of undeclared identifier 'RegisterLowMemoryEventsPhysicalDistinguishedAmount' xpcom/base/AvailableMemoryWatcherWin.cpp:31,47:: error: base class has incomplete type xpcom/base/AvailableMemoryWatcherWin.cpp:37,3:: error: unknown type name 'NS_DECL_NSIOBSERVER' xpcom/base/AvailableMemoryWatcherWin.cpp:38,3:: error: 'virtual' can only appear on non-static member functions xpcom/base/AvailableMemoryWatcherWin.cpp:38,3:: error: expected ';' at end of declaration list xpcom/base/AvailableMemoryWatcherWin.cpp:38,3:: error: static_assert failed due to requirement 'std::is_convertible<mozilla::nsAvailableMemoryWatcher *, nsINamed *>::value' "nsITimerCallback implementations must also implement nsINamed" xpcom/base/AvailableMemoryWatcherWin.cpp:39,3:: error: must use 'enum' tag to refer to type 'nsresult' in this scope xpcom/base/AvailableMemoryWatcherWin.cpp:42,3:: error: must use 'enum' tag to refer to type 'nsresult' in this scope xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: cannot initialize object parameter of type 'mozilla::nsAvailableMemoryWatcherBase' with an expression of type 'mozilla::nsAvailableMemoryWatcher' xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: invalid application of 'sizeof' to an incomplete type 'const QITableEntry []' xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: must use 'enum' tag to refer to type 'nsresult' in this scope xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: static_cast from 'mozilla::nsAvailableMemoryWatcher *' to 'nsINamed *', which are not related by inheritance, is not allowed xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: static_cast from 'mozilla::nsAvailableMemoryWatcher *' to 'nsIObserver *', which are not related by inheritance, is not allowed xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: static_cast from 'mozilla::nsAvailableMemoryWatcher *' to 'nsITimerCallback *', which are not related by inheritance, is not allowed xpcom/base/AvailableMemoryWatcherWin.cpp:103,59:: error: 'nsIObserver' does not refer to a value xpcom/base/AvailableMemoryWatcherWin.cpp:103,59:: error: incomplete type 'nsIObserver' named in nested name specifier xpcom/base/AvailableMemoryWatcherWin.cpp:140,45:: error: cannot initialize a parameter of type 'nsIObserver *' with an rvalue of type 'mozilla::nsAvailableMemoryWatcher *' xpcom/base/AvailableMemoryWatcherWin.cpp:140,5:: error: must use 'enum' tag to refer to type 'nsresult' in this scope xpcom/base/CycleCollectedJSRuntime.cpp:1605,7:: error: use of undeclared identifier 'PR_GetEnv' xpcom/base/CycleCollectedJSRuntime.cpp:1605:7: error: use of undeclared identifier 'PR_GetEnv' xpcom/base/DeferredFinalize.cpp:12,15:: error: out-of-line definition of 'DeferredFinalize' does not match any declaration in namespace 'mozilla' xpcom/base/DeferredFinalize.cpp:12:15: error: out-of-line definition of 'DeferredFinalize' does not match any declaration in namespace 'mozilla' xpcom/base/MemoryTelemetry.cpp:48,27:: error: unused variable 'kTotalMemoryCollectorTimeout' [-Werror,-Wunused-const-variable] xpcom/base/MemoryTelemetry.cpp:48:27: error: unused variable 'kTotalMemoryCollectorTimeout' [-Werror,-Wunused-const-variable] xpcom/base/nsErrorService.cpp:42,21:: error: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension [-Werror,-Wc++20-extensions] xpcom/base/nsErrorService.cpp:42,21:: error: use of undeclared identifier 'MakeUnique'; did you mean 'mozilla::MakeUnique'? xpcom/base/nsErrorService.cpp:42:21: error: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension [-Werror,-Wc++20-extensions] xpcom/base/nsErrorService.cpp:42:21: error: use of undeclared identifier 'MakeUnique'; did you mean 'mozilla::MakeUnique'? xpcom/base/nsMacPreferencesReader.mm:20:12: error: implicit instantiation of undefined template 'nsTSubstring<char16_t>' xpcom/base/nsMacPreferencesReader.mm:24:60: error: use of undeclared identifier 'NSString' xpcom/base/nsMacPreferencesReader.mm:24:69: error: expected expression xpcom/base/nsMacPreferencesReader.mm:26:48: error: unknown type name 'NSArray' xpcom/base/nsMacPreferencesReader.mm:28:30: error: use of undeclared identifier 'NSString' xpcom/base/nsMacPreferencesReader.mm:29:30: error: no matching function for call to 'MakeStringSpan' xpcom/base/nsMacPreferencesReader.mm:29:51: error: instance method '-UTF8String' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access] xpcom/base/nsMacPreferencesReader.mm:30:22: error: instance method '-isKindOfClass:' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access] xpcom/base/nsMacPreferencesReader.mm:30:37: error: receiver type 'int (*)(int)' is not 'id' or interface pointer, consider casting it to 'id' [-Werror,-Wreceiver-expr] xpcom/base/nsMacPreferencesReader.mm:30:37: error: use of undeclared identifier 'NSNumber'; did you mean 'isnumber'? xpcom/base/nsMacPreferencesReader.mm:30:46: error: instance method '-class' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access] xpcom/base/nsMacPreferencesReader.mm:31:27: error: cannot initialize a parameter of type 'int64_t' (aka 'long long') with an rvalue of type 'id' xpcom/base/nsMacPreferencesReader.mm:31:33: error: instance method '-longLongValue' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access] xpcom/base/nsMacPreferencesReader.mm:32:37: error: use of undeclared identifier 'NSArray' xpcom/base/nsMacPreferencesReader.mm:34:7: error: no matching function for call to 'EvaluateArray' xpcom/base/nsMacPreferencesReader.mm:36:37: error: use of undeclared identifier 'NSDictionary' xpcom/base/nsMacPreferencesReader.mm:38:7: error: no matching function for call to 'EvaluateDict' xpcom/base/nsMacPreferencesReader.mm:44:60: error: use of undeclared identifier 'NSString' xpcom/base/nsMacPreferencesReader.mm:44:69: error: expected expression xpcom/base/nsSystemInfo.cpp:415,35:: error: no template named 'NotNull'; did you mean 'NonNull'? xpcom/base/nsSystemInfo.cpp:419,25:: error: member reference type 'NonNull<IWSCProductList *>' is not a pointer; did you mean to use '.'? xpcom/base/nsSystemInfo.cpp:419,27:: error: no member named 'get_Count' in 'mozilla::dom::NonNull<IWSCProductList *>' xpcom/base/nsSystemInfo.cpp:426,19:: error: member reference type 'NonNull<IWSCProductList *>' is not a pointer; did you mean to use '.'? xpcom/base/nsSystemInfo.cpp:426,21:: error: no member named 'get_Item' in 'mozilla::dom::NonNull<IWSCProductList *>' xpcom/base/nsSystemInfo.cpp:484,17:: error: use of undeclared identifier 'ArrayLength'; did you mean 'mozilla::ArrayLength'? xpcom/base/nsSystemInfo.cpp:484,47:: error: use of undeclared identifier 'ArrayLength'; did you mean 'mozilla::ArrayLength'? xpcom/base/nsSystemInfo.cpp:487,36:: error: use of undeclared identifier 'ArrayLength'; did you mean 'mozilla::ArrayLength'? xpcom/base/nsSystemInfo.cpp:500,10:: error: no matching function for call to 'EnumWSCProductList' xpcom/base/nsSystemInfo.cpp:500,46:: error: use of undeclared identifier 'WrapNotNull'; did you mean 'mozilla::WrapNotNull'? xpcom/base/nsTraceRefcnt.cpp:313,32:: error: use of undeclared identifier 'MakeUnique' xpcom/base/nsTraceRefcnt.cpp:313:32: error: use of undeclared identifier 'MakeUnique' xpcom/base/nsTraceRefcnt.cpp:461,19:: error: no matching member function for call to 'WithEntryHandle' xpcom/base/nsTraceRefcnt.cpp:461:19: error: no matching member function for call to 'WithEntryHandle' xpcom/base/nsTraceRefcnt.cpp:468,33:: error: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension [-Werror,-Wc++20-extensions] xpcom/base/nsTraceRefcnt.cpp:468,33:: error: use of undeclared identifier 'MakeUnique' xpcom/base/nsTraceRefcnt.cpp:468:33: error: use of undeclared identifier 'MakeUnique' xpcom/base/nsTraceRefcnt.cpp:736,20:: error: use of undeclared identifier '_write' Differential Revision: https://phabricator.services.mozilla.com/D127036
2021-10-01 04:49:16 +03:00
#include "nsString.h"
#include "js/JSON.h"
#include "js/RootingAPI.h"
#include "js/Value.h"
#include "mozilla/JSONStringWriteFuncs.h"
NS_IMPL_ISUPPORTS(nsMacPreferencesReader, nsIMacPreferencesReader)
using namespace mozilla;
static void EvaluateDict(JSONWriter* aWriter, NSDictionary<NSString*, id>* aDict);
static void EvaluateArray(JSONWriter* aWriter, NSArray* aArray) {
for (id elem in aArray) {
if ([elem isKindOfClass:[NSString class]]) {
aWriter->StringElement(MakeStringSpan([elem UTF8String]));
} else if ([elem isKindOfClass:[NSNumber class]]) {
aWriter->IntElement([elem longLongValue]);
} else if ([elem isKindOfClass:[NSArray class]]) {
aWriter->StartArrayElement();
EvaluateArray(aWriter, elem);
aWriter->EndArray();
} else if ([elem isKindOfClass:[NSDictionary class]]) {
aWriter->StartObjectElement();
EvaluateDict(aWriter, elem);
aWriter->EndObject();
}
}
}
static void EvaluateDict(JSONWriter* aWriter, NSDictionary<NSString*, id>* aDict) {
for (NSString* key in aDict) {
id value = aDict[key];
if ([value isKindOfClass:[NSString class]]) {
aWriter->StringProperty(MakeStringSpan([key UTF8String]), MakeStringSpan([value UTF8String]));
} else if ([value isKindOfClass:[NSNumber class]]) {
aWriter->IntProperty(MakeStringSpan([key UTF8String]), [value longLongValue]);
} else if ([value isKindOfClass:[NSArray class]]) {
aWriter->StartArrayProperty(MakeStringSpan([key UTF8String]));
EvaluateArray(aWriter, value);
aWriter->EndArray();
} else if ([value isKindOfClass:[NSDictionary class]]) {
aWriter->StartObjectProperty(MakeStringSpan([key UTF8String]));
EvaluateDict(aWriter, value);
aWriter->EndObject();
}
}
}
NS_IMETHODIMP
nsMacPreferencesReader::PoliciesEnabled(bool* aPoliciesEnabled) {
NSString* policiesEnabledStr = [NSString stringWithUTF8String:ENTERPRISE_POLICIES_ENABLED_KEY];
*aPoliciesEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:policiesEnabledStr] == YES;
return NS_OK;
}
NS_IMETHODIMP
nsMacPreferencesReader::ReadPreferences(JSContext* aCx, JS::MutableHandle<JS::Value> aResult) {
JSONStringWriteFunc<nsAutoCString> jsonStr;
JSONWriter w(jsonStr);
w.Start();
EvaluateDict(&w, [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
w.End();
NS_ConvertUTF8toUTF16 jsonStr16(jsonStr.StringCRef());
JS::RootedValue val(aCx);
MOZ_ALWAYS_TRUE(JS_ParseJSON(aCx, jsonStr16.get(), jsonStr16.Length(), &val));
aResult.set(val);
return NS_OK;
}