LCOV - code coverage report
Current view: directory - objdir/dist/include - xptinfo.h (source / functions) Found Hit Coverage
Test: app.info Lines: 56 54 96.4 %
Date: 2012-06-02 Functions: 33 31 93.9 %

       1                 : /* -*- Mode: C++; tab-width: 8; 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.org 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) 1999
      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                 : /* XPTI_PUBLIC_API and XPTI_GetInterfaceInfoManager declarations. */
      39                 : 
      40                 : #ifndef xptiinfo_h___
      41                 : #define xptiinfo_h___
      42                 : 
      43                 : #include "prtypes.h"
      44                 : #include "nscore.h"
      45                 : #include "xpt_struct.h"
      46                 : 
      47                 : class nsIInterfaceInfoManager;
      48                 : 
      49                 : // Flyweight wrapper classes for xpt_struct.h structs. 
      50                 : // Everything here is dependent upon - and sensitive to changes in -
      51                 : // xpcom/typelib/xpt/public/xpt_struct.h!
      52                 : 
      53                 : class nsXPTType : public XPTTypeDescriptorPrefix
      54                 : {
      55                 : // NO DATA - this a flyweight wrapper
      56                 : public:
      57        18250057 :     nsXPTType()
      58        18250057 :         {}    // random contents
      59        52465615 :     nsXPTType(const XPTTypeDescriptorPrefix& prefix)
      60        52465615 :         {*(XPTTypeDescriptorPrefix*)this = prefix;}
      61                 : 
      62           82669 :     nsXPTType(const PRUint8& prefix)
      63           82669 :         {*(PRUint8*)this = prefix;}
      64                 : 
      65          476394 :     nsXPTType& operator=(PRUint8 val)
      66          476394 :         {flags = val; return *this;}
      67                 : 
      68        17684841 :     nsXPTType& operator=(const nsXPTType& other)
      69        17684841 :         {flags = other.flags; return *this;}
      70                 : 
      71         7103237 :     operator PRUint8() const
      72         7103237 :         {return flags;}
      73                 : 
      74                 :     // 'Arithmetic' here roughly means that the value is self-contained and
      75                 :     // doesn't depend on anything else in memory (ie: not a pointer, not an
      76                 :     // XPCOM object, not a jsval, etc).
      77                 :     //
      78                 :     // Supposedly this terminology comes from Harbison/Steele, but it's still
      79                 :     // a rather crappy name. We'd change it if it wasn't used all over the
      80                 :     // place in xptcall. :-(
      81        31976996 :     bool IsArithmetic() const
      82        31976996 :         {return flags <= T_WCHAR;}
      83                 : 
      84                 :     // We used to abuse 'pointer' flag bit in typelib format quite extensively.
      85                 :     // We've gotten rid of most of the cases, but there's still a fair amount
      86                 :     // of refactoring to be done in XPCWrappedJSClass before we can safely stop
      87                 :     // asking about this. In the mean time, we've got a temporary version of
      88                 :     // IsPointer() that should be equivalent to what's in the typelib.
      89          315022 :     bool deprecated_IsPointer() const
      90          315022 :         {return !IsArithmetic() && TagPart() != T_JSVAL;}
      91                 : 
      92         6814991 :     bool IsInterfacePointer() const
      93         6814991 :         {  switch (TagPart()) {
      94                 :              default:
      95         5341141 :                return false;
      96                 :              case T_INTERFACE:
      97                 :              case T_INTERFACE_IS:
      98         1473850 :                return true;
      99                 :            }
     100                 :         }
     101                 : 
     102        17654970 :     bool IsArray() const
     103        17654970 :         {return TagPart() == T_ARRAY;}
     104                 : 
     105                 :     // 'Dependent' means that params of this type are dependent upon other 
     106                 :     // params. e.g. an T_INTERFACE_IS is dependent upon some other param at 
     107                 :     // runtime to say what the interface type of this param really is.
     108        12078365 :     bool IsDependent() const
     109        12078365 :         {  switch (TagPart()) {
     110                 :              default:
     111        11860909 :                return false;
     112                 :              case T_INTERFACE_IS:
     113                 :              case TD_ARRAY:
     114                 :              case T_PSTRING_SIZE_IS:
     115                 :              case T_PWSTRING_SIZE_IS:
     116          217456 :                return true;
     117                 :            }
     118                 :         }
     119                 : 
     120       134583068 :     PRUint8 TagPart() const
     121       134583068 :         {return (PRUint8) (flags & XPT_TDP_TAGMASK);}
     122                 : 
     123                 :     enum
     124                 :     {
     125                 :         T_I8                = TD_INT8             ,
     126                 :         T_I16               = TD_INT16            ,
     127                 :         T_I32               = TD_INT32            ,
     128                 :         T_I64               = TD_INT64            ,
     129                 :         T_U8                = TD_UINT8            ,
     130                 :         T_U16               = TD_UINT16           ,
     131                 :         T_U32               = TD_UINT32           ,
     132                 :         T_U64               = TD_UINT64           ,
     133                 :         T_FLOAT             = TD_FLOAT            ,
     134                 :         T_DOUBLE            = TD_DOUBLE           ,
     135                 :         T_BOOL              = TD_BOOL             ,
     136                 :         T_CHAR              = TD_CHAR             ,
     137                 :         T_WCHAR             = TD_WCHAR            ,
     138                 :         T_VOID              = TD_VOID             ,
     139                 :         T_IID               = TD_PNSIID           ,
     140                 :         T_DOMSTRING         = TD_DOMSTRING        ,
     141                 :         T_CHAR_STR          = TD_PSTRING          ,
     142                 :         T_WCHAR_STR         = TD_PWSTRING         ,
     143                 :         T_INTERFACE         = TD_INTERFACE_TYPE   ,
     144                 :         T_INTERFACE_IS      = TD_INTERFACE_IS_TYPE,
     145                 :         T_ARRAY             = TD_ARRAY            ,
     146                 :         T_PSTRING_SIZE_IS   = TD_PSTRING_SIZE_IS  ,
     147                 :         T_PWSTRING_SIZE_IS  = TD_PWSTRING_SIZE_IS ,
     148                 :         T_UTF8STRING        = TD_UTF8STRING       ,
     149                 :         T_CSTRING           = TD_CSTRING          ,
     150                 :         T_ASTRING           = TD_ASTRING          ,
     151                 :         T_JSVAL             = TD_JSVAL
     152                 :     };
     153                 : // NO DATA - this a flyweight wrapper
     154                 : };
     155                 : 
     156                 : class nsXPTParamInfo : public XPTParamDescriptor
     157                 : {
     158                 : // NO DATA - this a flyweight wrapper
     159                 : public:
     160        68929373 :     nsXPTParamInfo(const XPTParamDescriptor& desc)
     161        68929373 :         {*(XPTParamDescriptor*)this = desc;}
     162                 : 
     163                 : 
     164         9381492 :     bool IsIn()  const    {return 0 != (XPT_PD_IS_IN(flags));}
     165        42087367 :     bool IsOut() const    {return 0 != (XPT_PD_IS_OUT(flags));}
     166        18335191 :     bool IsRetval() const {return 0 != (XPT_PD_IS_RETVAL(flags));}
     167        12399401 :     bool IsShared() const {return 0 != (XPT_PD_IS_SHARED(flags));}
     168        26253499 :     bool IsDipper() const {return 0 != (XPT_PD_IS_DIPPER(flags));}
     169          417542 :     bool IsOptional() const {return 0 != (XPT_PD_IS_OPTIONAL(flags));}
     170        52329155 :     const nsXPTType GetType() const {return type.prefix;}
     171                 : 
     172                 :     // Whether this parameter is passed indirectly on the stack. This mainly
     173                 :     // applies to out/inout params, but we use it unconditionally for certain
     174                 :     // types.
     175         9338031 :     bool IsIndirect() const {return IsOut() ||
     176         9338031 :                                GetType().TagPart() == nsXPTType::T_JSVAL;}
     177                 : 
     178                 :     // NOTE: other activities on types are done via methods on nsIInterfaceInfo
     179                 : 
     180                 : private:
     181                 :     nsXPTParamInfo();   // no implementation
     182                 : // NO DATA - this a flyweight wrapper
     183                 : };
     184                 : 
     185                 : class nsXPTMethodInfo : public XPTMethodDescriptor
     186                 : {
     187                 : // NO DATA - this a flyweight wrapper
     188                 : public:
     189                 :     nsXPTMethodInfo(const XPTMethodDescriptor& desc)
     190                 :         {*(XPTMethodDescriptor*)this = desc;}
     191                 : 
     192         1320867 :     bool IsGetter()      const {return 0 != (XPT_MD_IS_GETTER(flags) );}
     193         1493592 :     bool IsSetter()      const {return 0 != (XPT_MD_IS_SETTER(flags) );}
     194               0 :     bool IsNotXPCOM()    const {return 0 != (XPT_MD_IS_NOTXPCOM(flags));}
     195                 :     bool IsConstructor() const {return 0 != (XPT_MD_IS_CTOR(flags)   );}
     196               0 :     bool IsHidden()      const {return 0 != (XPT_MD_IS_HIDDEN(flags) );}
     197         6669641 :     bool WantsOptArgc()  const {return 0 != (XPT_MD_WANTS_OPT_ARGC(flags));}
     198         6669641 :     bool WantsContext()  const {return 0 != (XPT_MD_WANTS_CONTEXT(flags));}
     199         1486422 :     const char* GetName()  const {return name;}
     200        91080354 :     PRUint8 GetParamCount()  const {return num_args;}
     201                 :     /* idx was index before I got _sick_ of the warnings on Unix, sorry jband */
     202        62343666 :     const nsXPTParamInfo GetParam(PRUint8 idx) const
     203                 :         {
     204        62343666 :             NS_PRECONDITION(idx < GetParamCount(),"bad arg");
     205        62343666 :             return params[idx];
     206                 :         }
     207                 :     const nsXPTParamInfo GetResult() const
     208                 :         {return *result;}
     209                 : private:
     210                 :     nsXPTMethodInfo();  // no implementation
     211                 : // NO DATA - this a flyweight wrapper
     212                 : };
     213                 : 
     214                 : 
     215                 : // forward declaration
     216                 : struct nsXPTCMiniVariant;
     217                 : 
     218                 : class nsXPTConstant : public XPTConstDescriptor
     219                 : {
     220                 : // NO DATA - this a flyweight wrapper
     221                 : public:
     222                 :     nsXPTConstant(const XPTConstDescriptor& desc)
     223                 :         {*(XPTConstDescriptor*)this = desc;}
     224                 : 
     225          388193 :     const char* GetName() const
     226          388193 :         {return name;}
     227                 : 
     228           20080 :     const nsXPTType GetType() const
     229           20080 :         {return type.prefix;}
     230                 : 
     231                 :     // XXX this is ugly. But sometimes you gotta do what you gotta do.
     232                 :     // A reinterpret_cast won't do the trick here. And this plain C cast
     233                 :     // works correctly and is safe enough.
     234                 :     // See http://bugzilla.mozilla.org/show_bug.cgi?id=49641
     235           20080 :     const nsXPTCMiniVariant* GetValue() const
     236           20080 :         {return (nsXPTCMiniVariant*) &value;}
     237                 : private:
     238                 :     nsXPTConstant();    // no implementation
     239                 : // NO DATA - this a flyweight wrapper
     240                 : };
     241                 : 
     242                 : #endif /* xptiinfo_h___ */

Generated by: LCOV version 1.7