intl/uconv/util/nsUCConstructors.cpp

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

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

mercurial