Back to index

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