|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
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 |
|
7 |
|
8 #include "nsUCSupport.h" |
|
9 #include "nsUCConstructors.h" |
|
10 |
|
11 template<class T> |
|
12 inline NS_METHOD StabilizedQueryInterface(T* aNewObject, |
|
13 REFNSIID aIID, |
|
14 void **aResult) |
|
15 { |
|
16 NS_ADDREF(aNewObject); |
|
17 nsresult rv = aNewObject->QueryInterface(aIID, aResult); |
|
18 NS_RELEASE(aNewObject); |
|
19 return rv; |
|
20 } |
|
21 |
|
22 NS_METHOD |
|
23 CreateMultiTableDecoder(int32_t aTableCount, const uRange * aRangeArray, |
|
24 uScanClassID * aScanClassArray, |
|
25 uMappingTable ** aMappingTable, |
|
26 uint32_t aMaxLengthFactor, |
|
27 nsISupports* aOuter, |
|
28 REFNSIID aIID, |
|
29 void** aResult) |
|
30 { |
|
31 |
|
32 if (aOuter) |
|
33 return NS_ERROR_NO_AGGREGATION; |
|
34 |
|
35 nsMultiTableDecoderSupport* decoder = |
|
36 new nsMultiTableDecoderSupport(aTableCount, aRangeArray, |
|
37 aScanClassArray, aMappingTable, |
|
38 aMaxLengthFactor); |
|
39 if (!decoder) |
|
40 return NS_ERROR_OUT_OF_MEMORY; |
|
41 |
|
42 return StabilizedQueryInterface(decoder, aIID, aResult); |
|
43 } |
|
44 |
|
45 NS_METHOD |
|
46 CreateMultiTableEncoder(int32_t aTableCount, |
|
47 uScanClassID * aScanClassArray, |
|
48 uShiftOutTable ** aShiftOutTable, |
|
49 uMappingTable ** aMappingTable, |
|
50 uint32_t aMaxLengthFactor, |
|
51 nsISupports* aOuter, |
|
52 REFNSIID aIID, |
|
53 void** aResult) |
|
54 { |
|
55 |
|
56 if (aOuter) |
|
57 return NS_ERROR_NO_AGGREGATION; |
|
58 |
|
59 nsMultiTableEncoderSupport* encoder = |
|
60 new nsMultiTableEncoderSupport(aTableCount, |
|
61 aScanClassArray, |
|
62 aShiftOutTable, |
|
63 aMappingTable, |
|
64 aMaxLengthFactor); |
|
65 if (!encoder) |
|
66 return NS_ERROR_OUT_OF_MEMORY; |
|
67 |
|
68 return StabilizedQueryInterface(encoder, aIID, aResult); |
|
69 } |
|
70 |
|
71 NS_METHOD |
|
72 CreateMultiTableEncoder(int32_t aTableCount, |
|
73 uScanClassID * aScanClassArray, |
|
74 uMappingTable ** aMappingTable, |
|
75 uint32_t aMaxLengthFactor, |
|
76 nsISupports* aOuter, |
|
77 REFNSIID aIID, |
|
78 void** aResult) |
|
79 { |
|
80 return CreateMultiTableEncoder(aTableCount, aScanClassArray, |
|
81 nullptr, |
|
82 aMappingTable, aMaxLengthFactor, |
|
83 aOuter, aIID, aResult); |
|
84 } |
|
85 |
|
86 NS_METHOD |
|
87 CreateTableEncoder(uScanClassID aScanClass, |
|
88 uShiftOutTable * aShiftOutTable, |
|
89 uMappingTable * aMappingTable, |
|
90 uint32_t aMaxLengthFactor, |
|
91 nsISupports* aOuter, |
|
92 REFNSIID aIID, |
|
93 void** aResult) |
|
94 { |
|
95 if (aOuter) |
|
96 return NS_ERROR_NO_AGGREGATION; |
|
97 |
|
98 nsTableEncoderSupport* encoder = |
|
99 new nsTableEncoderSupport(aScanClass, |
|
100 aShiftOutTable, aMappingTable, |
|
101 aMaxLengthFactor); |
|
102 if (!encoder) |
|
103 return NS_ERROR_OUT_OF_MEMORY; |
|
104 |
|
105 return StabilizedQueryInterface(encoder, aIID, aResult); |
|
106 } |
|
107 |
|
108 NS_METHOD |
|
109 CreateTableEncoder(uScanClassID aScanClass, |
|
110 uMappingTable * aMappingTable, |
|
111 uint32_t aMaxLengthFactor, |
|
112 nsISupports* aOuter, |
|
113 REFNSIID aIID, |
|
114 void** aResult) |
|
115 { |
|
116 return CreateTableEncoder(aScanClass, nullptr, |
|
117 aMappingTable, aMaxLengthFactor, |
|
118 aOuter, aIID, aResult); |
|
119 } |
|
120 |
|
121 NS_METHOD |
|
122 CreateTableDecoder(uScanClassID aScanClass, |
|
123 uShiftInTable * aShiftInTable, |
|
124 uMappingTable * aMappingTable, |
|
125 uint32_t aMaxLengthFactor, |
|
126 nsISupports* aOuter, |
|
127 REFNSIID aIID, |
|
128 void** aResult) |
|
129 { |
|
130 if (aOuter) |
|
131 return NS_ERROR_NO_AGGREGATION; |
|
132 |
|
133 nsTableDecoderSupport* decoder = |
|
134 new nsTableDecoderSupport(aScanClass, aShiftInTable, aMappingTable, |
|
135 aMaxLengthFactor); |
|
136 if (!decoder) |
|
137 return NS_ERROR_OUT_OF_MEMORY; |
|
138 |
|
139 return StabilizedQueryInterface(decoder, aIID, aResult); |
|
140 } |
|
141 |
|
142 NS_METHOD |
|
143 CreateOneByteDecoder(uMappingTable * aMappingTable, |
|
144 |
|
145 nsISupports* aOuter, |
|
146 REFNSIID aIID, |
|
147 void** aResult) |
|
148 { |
|
149 if (aOuter) return NS_ERROR_NO_AGGREGATION; |
|
150 |
|
151 nsOneByteDecoderSupport* decoder = |
|
152 new nsOneByteDecoderSupport(aMappingTable); |
|
153 |
|
154 if (!decoder) |
|
155 return NS_ERROR_OUT_OF_MEMORY; |
|
156 |
|
157 return StabilizedQueryInterface(decoder, aIID, aResult); |
|
158 } |