Back to index

lightning-sunbird  0.9+nobinonly
xptcstubs_irix.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include "xptcprivate.h"
00039 
00040 #if defined(IRIX)
00041 
00042 #if (_MIPS_SIM != _ABIN32)
00043 #error "This code is for IRIX N32 only"
00044 #endif
00045 
00046 /*
00047  * This is for IRIX N32 ABI
00048  *
00049  * When we're called, the "gp" registers are stored in gprData and
00050  * the "fp" registers are stored in fprData.  There are 8 regs
00051  * available which coorespond to the first 7 parameters of the
00052  * function and the "this" pointer.  If there are additional parms,
00053  * they are stored on the stack at address "args".
00054  *
00055  */
00056 extern "C" nsresult
00057 PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex, PRUint64* args,
00058                    PRUint64 *gprData, double *fprData)
00059 {
00060 #define PARAM_BUFFER_COUNT         16
00061 #define PARAM_GPR_COUNT                   7
00062 #define PARAM_FPR_COUNT                   7
00063 
00064     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
00065     nsXPTCMiniVariant* dispatchParams = NULL;
00066     nsIInterfaceInfo* iface_info = NULL;
00067     const nsXPTMethodInfo* info;
00068     PRUint8 paramCount;
00069     PRUint8 i;
00070     nsresult result = NS_ERROR_FAILURE;
00071 
00072     NS_ASSERTION(self,"no self");
00073 
00074     self->GetInterfaceInfo(&iface_info);
00075     NS_ASSERTION(iface_info,"no interface info");
00076 
00077     iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
00078     NS_ASSERTION(info,"no interface info");
00079 
00080     paramCount = info->GetParamCount();
00081 
00082     // setup variant array pointer
00083     if(paramCount > PARAM_BUFFER_COUNT)
00084         dispatchParams = new nsXPTCMiniVariant[paramCount];
00085     else
00086         dispatchParams = paramBuffer;
00087     NS_ASSERTION(dispatchParams,"no place for params");
00088 
00089     PRUint64* ap = args;
00090     PRUint32 iCount = 0;
00091     for(i = 0; i < paramCount; i++)
00092     {
00093         const nsXPTParamInfo& param = info->GetParam(i);
00094         const nsXPTType& type = param.GetType();
00095         nsXPTCMiniVariant* dp = &dispatchParams[i];
00096 
00097         if(param.IsOut() || !type.IsArithmetic())
00098         {
00099             if (iCount < PARAM_GPR_COUNT)
00100               dp->val.p = (void*)gprData[iCount++];
00101             else
00102               dp->val.p = (void*)*ap++;
00103             continue;
00104         }
00105         // else
00106         switch(type)
00107         {
00108         case nsXPTType::T_I8:
00109            if (iCount < PARAM_GPR_COUNT)
00110               dp->val.i8  = (PRInt8)gprData[iCount++];
00111            else
00112               dp->val.i8  = (PRInt8)*ap++;
00113            break;
00114 
00115         case nsXPTType::T_I16:
00116             if (iCount < PARAM_GPR_COUNT)
00117                dp->val.i16  = (PRInt16)gprData[iCount++];
00118             else
00119                dp->val.i16  = (PRInt16)*ap++;
00120             break;
00121 
00122         case nsXPTType::T_I32:
00123             if (iCount < PARAM_GPR_COUNT)
00124                dp->val.i32  = (PRInt32)gprData[iCount++];
00125             else
00126                dp->val.i32  = (PRInt32)*ap++;
00127             break;
00128 
00129         case nsXPTType::T_I64:
00130             if (iCount < PARAM_GPR_COUNT)
00131                dp->val.i64  = (PRInt64)gprData[iCount++];
00132             else
00133                dp->val.i64  = (PRInt64)*ap++;
00134             break;
00135 
00136         case nsXPTType::T_U8:
00137             if (iCount < PARAM_GPR_COUNT)
00138                dp->val.u8  = (PRUint8)gprData[iCount++];
00139             else
00140                dp->val.u8  = (PRUint8)*ap++;
00141             break;
00142 
00143         case nsXPTType::T_U16:
00144             if (iCount < PARAM_GPR_COUNT)
00145                dp->val.u16  = (PRUint16)gprData[iCount++];
00146             else
00147                 dp->val.u16  = (PRUint16)*ap++;
00148             break;
00149 
00150         case nsXPTType::T_U32:
00151             if (iCount < PARAM_GPR_COUNT)
00152                dp->val.u32  = (PRUint32)gprData[iCount++];
00153             else
00154                dp->val.u32  = (PRUint32)*ap++;
00155             break;
00156 
00157         case nsXPTType::T_U64:
00158             if (iCount < PARAM_GPR_COUNT)
00159                dp->val.u64  = (PRUint64)gprData[iCount++];
00160             else
00161                dp->val.u64  = (PRUint64)*ap++;
00162             break;
00163 
00164         case nsXPTType::T_FLOAT:
00165              if (iCount < PARAM_FPR_COUNT)
00166                 dp->val.f  = (double)fprData[iCount++];
00167              else
00168                 dp->val.f  = *((double*)ap++);
00169              break;
00170 
00171         case nsXPTType::T_DOUBLE:
00172               if (iCount < PARAM_FPR_COUNT)
00173                  dp->val.d  = (double)fprData[iCount++];
00174               else
00175                  dp->val.d  = *((double*)ap++);
00176               break;
00177 
00178         case nsXPTType::T_BOOL:
00179            if (iCount < PARAM_GPR_COUNT)
00180               dp->val.b  = (PRBool)gprData[iCount++];
00181            else
00182               dp->val.b  = (PRBool)*ap++;
00183            break;
00184 
00185         case nsXPTType::T_CHAR:
00186            if (iCount < PARAM_GPR_COUNT)
00187               dp->val.c  = (char)gprData[iCount++];
00188            else
00189               dp->val.c  = (char)*ap++;
00190            break;
00191 
00192         case nsXPTType::T_WCHAR:
00193            if (iCount < PARAM_GPR_COUNT)
00194               dp->val.wc  = (wchar_t)gprData[iCount++];
00195            else
00196               dp->val.wc  = (wchar_t)*ap++;
00197            break;
00198 
00199         default:
00200             NS_ASSERTION(0, "bad type");
00201             break;
00202         }
00203     }
00204 
00205     result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
00206 
00207     NS_RELEASE(iface_info);
00208 
00209     if(dispatchParams != paramBuffer)
00210         delete [] dispatchParams;
00211 
00212     return result;
00213 }
00214 
00215 #define STUB_ENTRY(n)              /* defined in the assembly file */
00216 
00217 #define SENTINEL_ENTRY(n) \
00218 nsresult nsXPTCStubBase::Sentinel##n() \
00219 { \
00220     NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
00221     return NS_ERROR_NOT_IMPLEMENTED; \
00222 }
00223 
00224 #include "xptcstubsdef.inc"
00225 
00226 #endif