Back to index

lightning-sunbird  0.9+nobinonly
xptcstubs_ppc_aix.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1999
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /* Implement shared vtbl methods. */
00039 
00040 #include "xptcprivate.h"
00041 
00042 #if defined(AIX)
00043 
00044 /*
00045         For PPC (AIX & MAC), the first 8 integral and the first 13 f.p. parameters 
00046         arrive in a separate chunk of data that has been loaded from the registers. 
00047         The args pointer has been set to the start of the parameters BEYOND the ones
00048         arriving in registers
00049 */
00050 extern "C" nsresult
00051 PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex, PRUint32* args, PRUint32 *gprData, double *fprData)
00052 {
00053     typedef struct {
00054         uint32 hi;
00055         uint32 lo;      // have to move 64 bit entities as 32 bit halves since
00056     } DU;               // stack slots are not guaranteed 16 byte aligned
00057 
00058 #define PARAM_BUFFER_COUNT     16
00059 #define PARAM_GPR_COUNT         7  
00060 
00061     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
00062     nsXPTCMiniVariant* dispatchParams = NULL;
00063     nsIInterfaceInfo* iface_info = NULL;
00064     const nsXPTMethodInfo* info;
00065     PRUint8 paramCount;
00066     PRUint8 i;
00067     nsresult result = NS_ERROR_FAILURE;
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     PRUint32* ap = args;
00087     PRUint32 iCount = 0;
00088     PRUint32 fpCount = 0;
00089     for(i = 0; i < paramCount; i++)
00090     {
00091         const nsXPTParamInfo& param = info->GetParam(i);
00092         const nsXPTType& type = param.GetType();
00093         nsXPTCMiniVariant* dp = &dispatchParams[i];
00094 
00095         if(param.IsOut() || !type.IsArithmetic())
00096         {
00097             if (iCount < PARAM_GPR_COUNT)
00098                 dp->val.p = (void*) gprData[iCount++];
00099             else
00100                 dp->val.p = (void*) *ap++;
00101             continue;
00102         }
00103         // else
00104         switch(type)
00105         {
00106         case nsXPTType::T_I8      :  if (iCount < PARAM_GPR_COUNT)
00107                                          dp->val.i8  = (PRInt8) gprData[iCount++];
00108                                      else
00109                                          dp->val.i8  = (PRInt8)  *ap++;
00110                                      break;
00111         case nsXPTType::T_I16     :  if (iCount < PARAM_GPR_COUNT)
00112                                          dp->val.i16  = (PRInt16) gprData[iCount++];
00113                                      else
00114                                          dp->val.i16  = (PRInt16)  *ap++;
00115                                      break;
00116         case nsXPTType::T_I32     :  if (iCount < PARAM_GPR_COUNT)
00117                                          dp->val.i32  = (PRInt32) gprData[iCount++];
00118                                      else
00119                                          dp->val.i32  = (PRInt32)  *ap++;
00120                                      break;
00121         case nsXPTType::T_I64     :  if (iCount < PARAM_GPR_COUNT)
00122                                          ((DU *)dp)->hi  = (PRInt32) gprData[iCount++];
00123                                      else
00124                                          ((DU *)dp)->hi  = (PRInt32)  *ap++;
00125                                      if (iCount < PARAM_GPR_COUNT)
00126                                          ((DU *)dp)->lo  = (PRUint32) gprData[iCount++];
00127                                      else
00128                                          ((DU *)dp)->lo  = (PRUint32)  *ap++;
00129                                      break;
00130         case nsXPTType::T_U8      :  if (iCount < PARAM_GPR_COUNT)
00131                                          dp->val.u8  = (PRUint8) gprData[iCount++];
00132                                      else
00133                                          dp->val.u8  = (PRUint8)  *ap++;
00134                                      break;
00135         case nsXPTType::T_U16     :  if (iCount < PARAM_GPR_COUNT)
00136                                          dp->val.u16  = (PRUint16) gprData[iCount++];
00137                                      else
00138                                          dp->val.u16  = (PRUint16)  *ap++;
00139                                      break;
00140         case nsXPTType::T_U32     :  if (iCount < PARAM_GPR_COUNT)
00141                                          dp->val.u32  = (PRUint32) gprData[iCount++];
00142                                      else
00143                                          dp->val.u32  = (PRUint32)  *ap++;
00144                                      break;
00145         case nsXPTType::T_U64     :  if (iCount < PARAM_GPR_COUNT)
00146                                          ((DU *)dp)->hi  = (PRUint32) gprData[iCount++];
00147                                      else
00148                                          ((DU *)dp)->hi  = (PRUint32)  *ap++;
00149                                      if (iCount < PARAM_GPR_COUNT)
00150                                          ((DU *)dp)->lo  = (PRUint32) gprData[iCount++];
00151                                      else
00152                                          ((DU *)dp)->lo  = (PRUint32)  *ap++;
00153                                      break;
00154         case nsXPTType::T_FLOAT   :  if (fpCount < 13) {
00155                                          dp->val.f  = (float) fprData[fpCount++];
00156                                          if (iCount < PARAM_GPR_COUNT)
00157                                              ++iCount;
00158                                          else
00159                                              ++ap;
00160                                      }
00161                                      else
00162                                          dp->val.f   = *((float*)   ap++);
00163                                      break;
00164         case nsXPTType::T_DOUBLE  :  if (fpCount < 13) {
00165                                          dp->val.d  = (double) fprData[fpCount++];
00166                                          if (iCount < PARAM_GPR_COUNT)
00167                                              ++iCount;
00168                                          else
00169                                              ++ap;
00170                                          if (iCount < PARAM_GPR_COUNT)
00171                                              ++iCount;
00172                                          else
00173                                              ++ap;
00174                                      }
00175                                      else {
00176                                          dp->val.f   = *((double*)   ap);
00177                                          ap += 2;
00178                                      }
00179                                      break;
00180         case nsXPTType::T_BOOL    :  if (iCount < PARAM_GPR_COUNT)
00181                                          dp->val.b  = (PRBool) gprData[iCount++];
00182                                      else
00183                                          dp->val.b  = (PRBool)  *ap++;
00184                                      break;
00185         case nsXPTType::T_CHAR    :  if (iCount < PARAM_GPR_COUNT)
00186                                          dp->val.c  = (char) gprData[iCount++];
00187                                      else
00188                                          dp->val.c  = (char)  *ap++;
00189                                      break;
00190         case nsXPTType::T_WCHAR   :  if (iCount < PARAM_GPR_COUNT)
00191                                          dp->val.wc  = (wchar_t) gprData[iCount++];
00192                                      else
00193                                          dp->val.wc  = (wchar_t)  *ap++;
00194                                      break;
00195         default:
00196             NS_ASSERTION(0, "bad type");
00197             break;
00198         }
00199     }
00200 
00201     result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
00202 
00203     NS_RELEASE(iface_info);
00204 
00205     if(dispatchParams != paramBuffer)
00206         delete [] dispatchParams;
00207 
00208     return result;
00209 }
00210 
00211 extern "C" int SharedStub(int);
00212 
00213 #define STUB_ENTRY(n)                \
00214 nsresult nsXPTCStubBase::Stub##n()   \
00215 {                                    \
00216     return SharedStub(n);        \
00217 }                                    \
00218 
00219 #define SENTINEL_ENTRY(n) \
00220 nsresult nsXPTCStubBase::Sentinel##n() \
00221 { \
00222     NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
00223     return NS_ERROR_NOT_IMPLEMENTED; \
00224 }
00225 
00226 #include "xptcstubsdef.inc"
00227 
00228 #endif /* AIX */