|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef nsLocaleConstructors_h__ |
|
7 #define nsLocaleConstructors_h__ |
|
8 |
|
9 #include "nsCollationCID.h" |
|
10 #include "nsDateTimeFormatCID.h" |
|
11 #include "mozilla/ModuleUtils.h" |
|
12 #include "nsILocaleService.h" |
|
13 #include "nsIScriptableDateFormat.h" |
|
14 #include "nsIServiceManager.h" |
|
15 #include "nsLanguageAtomService.h" |
|
16 #include "nsPlatformCharset.h" |
|
17 |
|
18 #if defined(XP_MACOSX) |
|
19 #define USE_MAC_LOCALE |
|
20 #endif |
|
21 |
|
22 #if defined(XP_UNIX) && !defined(XP_MACOSX) |
|
23 #define USE_UNIX_LOCALE |
|
24 #endif |
|
25 |
|
26 #ifdef XP_WIN |
|
27 #include "windows/nsCollationWin.h" |
|
28 #include "windows/nsDateTimeFormatWin.h" |
|
29 #endif |
|
30 |
|
31 #ifdef USE_MAC_LOCALE |
|
32 #include "mac/nsCollationMacUC.h" |
|
33 #include "mac/nsDateTimeFormatMac.h" |
|
34 #endif |
|
35 |
|
36 #ifdef USE_UNIX_LOCALE |
|
37 #include "unix/nsCollationUnix.h" |
|
38 #include "unix/nsDateTimeFormatUnix.h" |
|
39 #endif |
|
40 |
|
41 #define NSLOCALE_MAKE_CTOR(ctor_, iface_, func_) \ |
|
42 static nsresult \ |
|
43 ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) \ |
|
44 { \ |
|
45 *aResult = nullptr; \ |
|
46 if (aOuter) \ |
|
47 return NS_ERROR_NO_AGGREGATION; \ |
|
48 iface_* inst; \ |
|
49 nsresult rv = func_(&inst); \ |
|
50 if (NS_SUCCEEDED(rv)) { \ |
|
51 rv = inst->QueryInterface(aIID, aResult); \ |
|
52 NS_RELEASE(inst); \ |
|
53 } \ |
|
54 return rv; \ |
|
55 } |
|
56 |
|
57 |
|
58 NSLOCALE_MAKE_CTOR(CreateLocaleService, nsILocaleService, NS_NewLocaleService) |
|
59 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationFactory) |
|
60 //NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableDateTimeFormat) |
|
61 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLanguageAtomService) |
|
62 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPlatformCharset, Init) |
|
63 |
|
64 #ifdef XP_WIN |
|
65 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationWin) |
|
66 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatWin) |
|
67 #endif |
|
68 |
|
69 #ifdef USE_UNIX_LOCALE |
|
70 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationUnix) |
|
71 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatUnix) |
|
72 #endif |
|
73 |
|
74 #ifdef USE_MAC_LOCALE |
|
75 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationMacUC) |
|
76 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatMac) |
|
77 #endif |
|
78 |
|
79 #endif |