Back to index

lightning-sunbird  0.9+nobinonly
xptcstubs_pa32.cpp
Go to the documentation of this file.
00001 
00002 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00003  *
00004  * ***** BEGIN LICENSE BLOCK *****
00005  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00006  *
00007  * The contents of this file are subject to the Mozilla Public License Version
00008  * 1.1 (the "License"); you may not use this file except in compliance with
00009  * the License. You may obtain a copy of the License at
00010  * http://www.mozilla.org/MPL/
00011  *
00012  * Software distributed under the License is distributed on an "AS IS" basis,
00013  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00014  * for the specific language governing rights and limitations under the
00015  * License.
00016  *
00017  * The Original Code is mozilla.org code.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corporation.
00021  * Portions created by the Initial Developer are Copyright (C) 1999
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 /* Implement shared vtbl methods. */
00041 
00042 #include "xptcprivate.h"
00043 
00044 #if _HPUX
00045 #error "This code is for HP-PA RISC 32 bit mode only"
00046 #endif
00047 
00048 extern "C" nsresult
00049 PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex,
00050   PRUint32* args, PRUint32* floatargs)
00051 {
00052 
00053   typedef struct {
00054     uint32 hi;
00055     uint32 lo;
00056   } DU;
00057 
00058 #define PARAM_BUFFER_COUNT     16
00059 
00060   nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
00061   nsXPTCMiniVariant* dispatchParams = NULL;
00062   nsIInterfaceInfo* iface_info = NULL;
00063   const nsXPTMethodInfo* info;
00064   PRInt32 regwords = 1; /* self pointer is not in the variant records */
00065   nsresult result = NS_ERROR_FAILURE;
00066   PRUint8 paramCount;
00067   PRUint8 i;
00068 
00069   NS_ASSERTION(self,"no self");
00070 
00071   self->GetInterfaceInfo(&iface_info);
00072   NS_ASSERTION(iface_info,"no interface info");
00073 
00074   iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
00075   NS_ASSERTION(info,"no interface info");
00076 
00077   paramCount = info->GetParamCount();
00078 
00079   // setup variant array pointer
00080   if(paramCount > PARAM_BUFFER_COUNT)
00081     dispatchParams = new nsXPTCMiniVariant[paramCount];
00082   else
00083     dispatchParams = paramBuffer;
00084   NS_ASSERTION(dispatchParams,"no place for params");
00085 
00086   for(i = 0; i < paramCount; ++i, --args)
00087   {
00088     const nsXPTParamInfo& param = info->GetParam(i);
00089     const nsXPTType& type = param.GetType();
00090     nsXPTCMiniVariant* dp = &dispatchParams[i];
00091 
00092     if(param.IsOut() || !type.IsArithmetic())
00093     {
00094       dp->val.p = (void*) *args;
00095       ++regwords;
00096       continue;
00097     }
00098     switch(type)
00099     {
00100     case nsXPTType::T_I8     : dp->val.i8  = *((PRInt32*) args); break;
00101     case nsXPTType::T_I16    : dp->val.i16 = *((PRInt32*) args); break;
00102     case nsXPTType::T_I32    : dp->val.i32 = *((PRInt32*) args); break;
00103     case nsXPTType::T_DOUBLE :
00104                                if (regwords & 1)
00105                                {
00106                                  ++regwords; /* align on double word */
00107                                  --args;
00108                                }
00109                                if (regwords == 0 || regwords == 2)
00110                                {
00111                                  dp->val.d=*((double*) (floatargs + regwords));
00112                                  --args;
00113                                }
00114                                else
00115                                {
00116                                  dp->val.d = *((double*) --args);
00117                                }
00118                                regwords += 2;
00119                                continue;
00120     case nsXPTType::T_U64    :
00121     case nsXPTType::T_I64    :
00122                                if (regwords & 1)
00123                                {
00124                                  ++regwords; /* align on double word */
00125                                  --args;
00126                                }
00127                                ((DU *)dp)->lo = *((PRUint32*) args);
00128                                ((DU *)dp)->hi = *((PRUint32*) --args);
00129                                regwords += 2;
00130                                continue;
00131     case nsXPTType::T_FLOAT  :
00132                                if (regwords >= 4)
00133                                  dp->val.f = *((float*) args);
00134                                else
00135                                  dp->val.f = *((float*) floatargs+4+regwords);
00136                                break;
00137     case nsXPTType::T_U8     : dp->val.u8  = *((PRUint32*) args); break;
00138     case nsXPTType::T_U16    : dp->val.u16 = *((PRUint32*) args); break;
00139     case nsXPTType::T_U32    : dp->val.u32 = *((PRUint32*) args); break;
00140     case nsXPTType::T_BOOL   : dp->val.b   = *((PRBool*)   args); break;
00141     case nsXPTType::T_CHAR   : dp->val.c   = *((PRUint32*) args); break;
00142     case nsXPTType::T_WCHAR  : dp->val.wc  = *((PRInt32*)  args); break;
00143     default:
00144       NS_ASSERTION(0, "bad type");
00145       break;
00146     }
00147     ++regwords;
00148   }
00149 
00150   result = self->CallMethod((PRUint16) methodIndex, info, dispatchParams);
00151 
00152   NS_RELEASE(iface_info);
00153 
00154   if(dispatchParams != paramBuffer)
00155     delete [] dispatchParams;
00156 
00157   return result;
00158 }
00159 
00160 extern "C" int SharedStub(int);
00161 
00162 #define STUB_ENTRY(n)       \
00163 nsresult nsXPTCStubBase::Stub##n()  \
00164 {                           \
00165     return SharedStub(n);   \
00166 }
00167 
00168 #define SENTINEL_ENTRY(n) \
00169 nsresult nsXPTCStubBase::Sentinel##n() \
00170 { \
00171     NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
00172     return NS_ERROR_NOT_IMPLEMENTED; \
00173 }
00174 
00175 #include "xptcstubsdef.inc"
00176