LCOV - code coverage report
Current view: directory - intl/uconv/util - nsUCConstructors.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 43 29 67.4 %
Date: 2012-06-02 Functions: 12 10 83.3 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is Mozilla Communicator client code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : 
      39                 : 
      40                 : #include "nsUCSupport.h"
      41                 : #include "nsUCConstructors.h"
      42                 : 
      43                 : template<class T>
      44           19969 : inline NS_METHOD StabilizedQueryInterface(T* aNewObject,
      45                 :                                          REFNSIID aIID,
      46                 :                                          void **aResult)
      47                 : {
      48           19969 :     NS_ADDREF(aNewObject);
      49           19969 :     nsresult rv = aNewObject->QueryInterface(aIID, aResult);
      50           19969 :     NS_RELEASE(aNewObject);
      51           19969 :     return rv;
      52                 : }
      53                 : 
      54                 : NS_METHOD
      55            8852 : CreateMultiTableDecoder(PRInt32 aTableCount, const uRange * aRangeArray, 
      56                 :                         uScanClassID * aScanClassArray,
      57                 :                         uMappingTable ** aMappingTable,
      58                 :                         PRUint32 aMaxLengthFactor,
      59                 :                         nsISupports* aOuter,
      60                 :                         REFNSIID aIID,
      61                 :                         void** aResult)
      62                 : {
      63                 : 
      64            8852 :   if (aOuter)
      65               0 :     return NS_ERROR_NO_AGGREGATION;
      66                 :   
      67                 :   nsMultiTableDecoderSupport* decoder =
      68                 :     new nsMultiTableDecoderSupport(aTableCount, aRangeArray,
      69                 :                                    aScanClassArray, aMappingTable,
      70            8852 :                                    aMaxLengthFactor);
      71            8852 :   if (!decoder)
      72               0 :     return NS_ERROR_OUT_OF_MEMORY;
      73                 : 
      74            8852 :   return StabilizedQueryInterface(decoder, aIID, aResult);
      75                 : }
      76                 : 
      77                 : NS_METHOD
      78            8851 : CreateMultiTableEncoder(PRInt32 aTableCount,
      79                 :                         uScanClassID * aScanClassArray,
      80                 :                         uShiftOutTable ** aShiftOutTable,
      81                 :                         uMappingTable ** aMappingTable,
      82                 :                         PRUint32 aMaxLengthFactor,
      83                 :                         nsISupports* aOuter,
      84                 :                         REFNSIID aIID,
      85                 :                         void** aResult)
      86                 : {
      87                 : 
      88            8851 :   if (aOuter)
      89               0 :     return NS_ERROR_NO_AGGREGATION;
      90                 :   
      91                 :   nsMultiTableEncoderSupport* encoder =
      92                 :     new nsMultiTableEncoderSupport(aTableCount,
      93                 :                                    aScanClassArray,
      94                 :                                    aShiftOutTable,
      95                 :                                    aMappingTable,
      96            8851 :                                    aMaxLengthFactor);
      97            8851 :   if (!encoder)
      98               0 :     return NS_ERROR_OUT_OF_MEMORY;
      99                 : 
     100            8851 :   return StabilizedQueryInterface(encoder, aIID, aResult);
     101                 : }
     102                 : 
     103                 : NS_METHOD
     104            8848 : CreateMultiTableEncoder(PRInt32 aTableCount,
     105                 :                         uScanClassID * aScanClassArray,
     106                 :                         uMappingTable ** aMappingTable,
     107                 :                         PRUint32 aMaxLengthFactor,
     108                 :                         nsISupports* aOuter,
     109                 :                         REFNSIID aIID,
     110                 :                         void** aResult)
     111                 : {
     112                 :   return CreateMultiTableEncoder(aTableCount, aScanClassArray,
     113                 :                                  nsnull,
     114                 :                                  aMappingTable, aMaxLengthFactor,
     115            8848 :                                  aOuter, aIID, aResult);
     116                 : }
     117                 : 
     118                 : NS_METHOD
     119             987 : CreateTableEncoder(uScanClassID aScanClass,
     120                 :                    uShiftOutTable * aShiftOutTable,
     121                 :                    uMappingTable  * aMappingTable,
     122                 :                    PRUint32 aMaxLengthFactor,
     123                 :                    nsISupports* aOuter,
     124                 :                    REFNSIID aIID,
     125                 :                    void** aResult)
     126                 : {
     127             987 :   if (aOuter)
     128               0 :     return NS_ERROR_NO_AGGREGATION;
     129                 :   
     130                 :   nsTableEncoderSupport* encoder =
     131                 :       new nsTableEncoderSupport(aScanClass,
     132                 :                                 aShiftOutTable,  aMappingTable,
     133             987 :                                 aMaxLengthFactor);
     134             987 :   if (!encoder)
     135               0 :     return NS_ERROR_OUT_OF_MEMORY;
     136                 : 
     137             987 :   return StabilizedQueryInterface(encoder, aIID, aResult);
     138                 : }
     139                 : 
     140                 : NS_METHOD
     141             981 : CreateTableEncoder(uScanClassID aScanClass,
     142                 :                    uMappingTable  * aMappingTable,
     143                 :                    PRUint32 aMaxLengthFactor,
     144                 :                    nsISupports* aOuter,
     145                 :                    REFNSIID aIID,
     146                 :                    void** aResult)
     147                 : {
     148                 :     return CreateTableEncoder(aScanClass, nsnull,
     149                 :                               aMappingTable, aMaxLengthFactor,
     150             981 :                               aOuter, aIID, aResult);
     151                 : }
     152                 : 
     153                 : NS_METHOD
     154               0 : CreateTableDecoder(uScanClassID aScanClass,
     155                 :                    uShiftInTable * aShiftInTable,
     156                 :                    uMappingTable  * aMappingTable,
     157                 :                    PRUint32 aMaxLengthFactor,
     158                 :                    nsISupports* aOuter,
     159                 :                    REFNSIID aIID,
     160                 :                    void** aResult)
     161                 : {
     162               0 :   if (aOuter)
     163               0 :     return NS_ERROR_NO_AGGREGATION;
     164                 :   
     165                 :   nsTableDecoderSupport* decoder =
     166                 :       new nsTableDecoderSupport(aScanClass, aShiftInTable, aMappingTable,
     167               0 :                                 aMaxLengthFactor);
     168               0 :   if (!decoder)
     169               0 :     return NS_ERROR_OUT_OF_MEMORY;
     170                 : 
     171               0 :   return StabilizedQueryInterface(decoder, aIID, aResult);
     172                 : }
     173                 : 
     174                 : NS_METHOD
     175            1279 : CreateOneByteDecoder(uMappingTable * aMappingTable,
     176                 :                      
     177                 :                      nsISupports* aOuter,
     178                 :                      REFNSIID aIID,
     179                 :                      void** aResult)
     180                 : {
     181            1279 :     if (aOuter) return NS_ERROR_NO_AGGREGATION;
     182                 :     
     183                 :     nsOneByteDecoderSupport* decoder =
     184            1279 :         new nsOneByteDecoderSupport(aMappingTable);
     185                 : 
     186            1279 :     if (!decoder)
     187               0 :         return NS_ERROR_OUT_OF_MEMORY;
     188                 :     
     189            1279 :     return StabilizedQueryInterface(decoder, aIID, aResult);
     190                 : }

Generated by: LCOV version 1.7