michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: michael@0: #include "nsUCSupport.h" michael@0: #include "nsUCConstructors.h" michael@0: michael@0: template michael@0: inline NS_METHOD StabilizedQueryInterface(T* aNewObject, michael@0: REFNSIID aIID, michael@0: void **aResult) michael@0: { michael@0: NS_ADDREF(aNewObject); michael@0: nsresult rv = aNewObject->QueryInterface(aIID, aResult); michael@0: NS_RELEASE(aNewObject); michael@0: return rv; michael@0: } michael@0: michael@0: NS_METHOD michael@0: CreateMultiTableDecoder(int32_t aTableCount, const uRange * aRangeArray, michael@0: uScanClassID * aScanClassArray, michael@0: uMappingTable ** aMappingTable, michael@0: uint32_t aMaxLengthFactor, michael@0: nsISupports* aOuter, michael@0: REFNSIID aIID, michael@0: void** aResult) michael@0: { michael@0: michael@0: if (aOuter) michael@0: return NS_ERROR_NO_AGGREGATION; michael@0: michael@0: nsMultiTableDecoderSupport* decoder = michael@0: new nsMultiTableDecoderSupport(aTableCount, aRangeArray, michael@0: aScanClassArray, aMappingTable, michael@0: aMaxLengthFactor); michael@0: if (!decoder) michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: michael@0: return StabilizedQueryInterface(decoder, aIID, aResult); michael@0: } michael@0: michael@0: NS_METHOD michael@0: CreateMultiTableEncoder(int32_t aTableCount, michael@0: uScanClassID * aScanClassArray, michael@0: uShiftOutTable ** aShiftOutTable, michael@0: uMappingTable ** aMappingTable, michael@0: uint32_t aMaxLengthFactor, michael@0: nsISupports* aOuter, michael@0: REFNSIID aIID, michael@0: void** aResult) michael@0: { michael@0: michael@0: if (aOuter) michael@0: return NS_ERROR_NO_AGGREGATION; michael@0: michael@0: nsMultiTableEncoderSupport* encoder = michael@0: new nsMultiTableEncoderSupport(aTableCount, michael@0: aScanClassArray, michael@0: aShiftOutTable, michael@0: aMappingTable, michael@0: aMaxLengthFactor); michael@0: if (!encoder) michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: michael@0: return StabilizedQueryInterface(encoder, aIID, aResult); michael@0: } michael@0: michael@0: NS_METHOD michael@0: CreateMultiTableEncoder(int32_t aTableCount, michael@0: uScanClassID * aScanClassArray, michael@0: uMappingTable ** aMappingTable, michael@0: uint32_t aMaxLengthFactor, michael@0: nsISupports* aOuter, michael@0: REFNSIID aIID, michael@0: void** aResult) michael@0: { michael@0: return CreateMultiTableEncoder(aTableCount, aScanClassArray, michael@0: nullptr, michael@0: aMappingTable, aMaxLengthFactor, michael@0: aOuter, aIID, aResult); michael@0: } michael@0: michael@0: NS_METHOD michael@0: CreateTableEncoder(uScanClassID aScanClass, michael@0: uShiftOutTable * aShiftOutTable, michael@0: uMappingTable * aMappingTable, michael@0: uint32_t aMaxLengthFactor, michael@0: nsISupports* aOuter, michael@0: REFNSIID aIID, michael@0: void** aResult) michael@0: { michael@0: if (aOuter) michael@0: return NS_ERROR_NO_AGGREGATION; michael@0: michael@0: nsTableEncoderSupport* encoder = michael@0: new nsTableEncoderSupport(aScanClass, michael@0: aShiftOutTable, aMappingTable, michael@0: aMaxLengthFactor); michael@0: if (!encoder) michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: michael@0: return StabilizedQueryInterface(encoder, aIID, aResult); michael@0: } michael@0: michael@0: NS_METHOD michael@0: CreateTableEncoder(uScanClassID aScanClass, michael@0: uMappingTable * aMappingTable, michael@0: uint32_t aMaxLengthFactor, michael@0: nsISupports* aOuter, michael@0: REFNSIID aIID, michael@0: void** aResult) michael@0: { michael@0: return CreateTableEncoder(aScanClass, nullptr, michael@0: aMappingTable, aMaxLengthFactor, michael@0: aOuter, aIID, aResult); michael@0: } michael@0: michael@0: NS_METHOD michael@0: CreateTableDecoder(uScanClassID aScanClass, michael@0: uShiftInTable * aShiftInTable, michael@0: uMappingTable * aMappingTable, michael@0: uint32_t aMaxLengthFactor, michael@0: nsISupports* aOuter, michael@0: REFNSIID aIID, michael@0: void** aResult) michael@0: { michael@0: if (aOuter) michael@0: return NS_ERROR_NO_AGGREGATION; michael@0: michael@0: nsTableDecoderSupport* decoder = michael@0: new nsTableDecoderSupport(aScanClass, aShiftInTable, aMappingTable, michael@0: aMaxLengthFactor); michael@0: if (!decoder) michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: michael@0: return StabilizedQueryInterface(decoder, aIID, aResult); michael@0: } michael@0: michael@0: NS_METHOD michael@0: CreateOneByteDecoder(uMappingTable * aMappingTable, michael@0: michael@0: nsISupports* aOuter, michael@0: REFNSIID aIID, michael@0: void** aResult) michael@0: { michael@0: if (aOuter) return NS_ERROR_NO_AGGREGATION; michael@0: michael@0: nsOneByteDecoderSupport* decoder = michael@0: new nsOneByteDecoderSupport(aMappingTable); michael@0: michael@0: if (!decoder) michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: michael@0: return StabilizedQueryInterface(decoder, aIID, aResult); michael@0: }