Back to index

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