Back to index

lightning-sunbird  0.9+nobinonly
xptcstubs_x86_64.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  * Makoto Kato <m_kato@ga2.so-net.ne.jp>.
00019  * Portions created by the Initial Developer are Copyright (C) 2004
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 the GNU General Public License Version 2 or later (the "GPL"), or
00026  * 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 /*
00043  * This is for Windows XP 64-Bit Edition / Server 2003 for AMD64 or later.
00044  */
00045 
00046 extern "C" nsresult
00047 PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex, PRUint64* args,
00048                    PRUint64 *gprData, double *fprData)
00049 {
00050 #define PARAM_BUFFER_COUNT  16
00051 //
00052 // "this" pointer is first parameter, so parameter count is 3.
00053 //
00054 #define PARAM_GPR_COUNT   3
00055 #define PARAM_FPR_COUNT   3
00056 
00057     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
00058     nsXPTCMiniVariant* dispatchParams = NULL;
00059     nsIInterfaceInfo* iface_info = NULL;
00060     const nsXPTMethodInfo* info;
00061     PRUint8 paramCount;
00062     PRUint8 i;
00063     nsresult result = NS_ERROR_FAILURE;
00064 
00065     NS_ASSERTION(self,"no self");
00066 
00067     self->GetInterfaceInfo(&iface_info);
00068     NS_ASSERTION(iface_info,"no interface info");
00069 
00070     iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
00071     NS_ASSERTION(info,"no interface info");
00072 
00073     paramCount = info->GetParamCount();
00074 
00075     //
00076     // setup variant array pointer
00077     //
00078 
00079     if(paramCount > PARAM_BUFFER_COUNT)
00080         dispatchParams = new nsXPTCMiniVariant[paramCount];
00081     else
00082         dispatchParams = paramBuffer;
00083 
00084     NS_ASSERTION(dispatchParams,"no place for params");
00085 
00086     PRUint64* ap = args;
00087     PRUint32 iCount = 0;
00088 
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 
00102             continue;
00103         }
00104         // else
00105         switch(type)
00106         {
00107         case nsXPTType::T_I8:
00108            if (iCount < PARAM_GPR_COUNT)
00109               dp->val.i8  = (PRInt8)gprData[iCount++];
00110            else
00111               dp->val.i8  = *((PRInt8*)ap++);
00112            break;
00113 
00114         case nsXPTType::T_I16:
00115             if (iCount < PARAM_GPR_COUNT)
00116                dp->val.i16  = (PRInt16)gprData[iCount++];
00117             else
00118                dp->val.i16  = *((PRInt16*)ap++);
00119             break;
00120 
00121         case nsXPTType::T_I32:
00122             if (iCount < PARAM_GPR_COUNT)
00123                dp->val.i32  = (PRInt32)gprData[iCount++];
00124             else
00125                dp->val.i32  = *((PRInt32*)ap++);
00126             break;
00127 
00128         case nsXPTType::T_I64:
00129             if (iCount < PARAM_GPR_COUNT)
00130                dp->val.i64  = (PRInt64)gprData[iCount++];
00131             else
00132                dp->val.i64  = *((PRInt64*)ap++);
00133             break;
00134 
00135         case nsXPTType::T_U8:
00136             if (iCount < PARAM_GPR_COUNT)
00137                dp->val.u8  = (PRUint8)gprData[iCount++];
00138             else
00139                dp->val.u8  = *((PRUint8*)ap++);
00140             break;
00141 
00142         case nsXPTType::T_U16:
00143             if (iCount < PARAM_GPR_COUNT)
00144                dp->val.u16  = (PRUint16)gprData[iCount++];
00145             else
00146                 dp->val.u16  = *((PRUint16*)ap++);
00147             break;
00148 
00149         case nsXPTType::T_U32:
00150             if (iCount < PARAM_GPR_COUNT)
00151                dp->val.u32  = (PRUint32)gprData[iCount++];
00152             else
00153                dp->val.u32  = *((PRUint32*)ap++);
00154             break;
00155 
00156         case nsXPTType::T_U64:
00157             if (iCount < PARAM_GPR_COUNT)
00158                dp->val.u64  = (PRUint64)gprData[iCount++];
00159             else
00160                dp->val.u64  = *((PRUint64*)ap++);
00161             break;
00162 
00163         case nsXPTType::T_FLOAT:
00164              if (iCount < PARAM_FPR_COUNT)
00165                 dp->val.f  = (float)fprData[iCount++];
00166              else
00167                 dp->val.f  = *((float*)ap++);
00168              break;
00169 
00170         case nsXPTType::T_DOUBLE:
00171               if (iCount < PARAM_FPR_COUNT)
00172                  dp->val.d  = (double)fprData[iCount++];
00173               else
00174                  dp->val.d  = *((double*)ap++);
00175               break;
00176 
00177         case nsXPTType::T_BOOL:
00178            if (iCount < PARAM_GPR_COUNT)
00179               dp->val.b  = (PRBool)gprData[iCount++];
00180            else
00181               dp->val.b  = *((PRBool*)ap++);
00182            break;
00183 
00184         case nsXPTType::T_CHAR:
00185            if (iCount < PARAM_GPR_COUNT)
00186               dp->val.c  = (char)gprData[iCount++];
00187            else
00188               dp->val.c  = *((char*)ap++);
00189            break;
00190 
00191         case nsXPTType::T_WCHAR:
00192            if (iCount < PARAM_GPR_COUNT)
00193               dp->val.wc  = (wchar_t)gprData[iCount++];
00194            else
00195               dp->val.wc  = *((wchar_t*)ap++);
00196            break;
00197 
00198         default:
00199             NS_ASSERTION(0, "bad type");
00200             break;
00201         }
00202     }
00203 
00204     result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
00205 
00206     NS_RELEASE(iface_info);
00207 
00208     if(dispatchParams != paramBuffer)
00209         delete [] dispatchParams;
00210 
00211     return result;
00212 }
00213 
00214 #define STUB_ENTRY(n)  /* defined in the assembly file */
00215 
00216 #define SENTINEL_ENTRY(n) \
00217 nsresult nsXPTCStubBase::Sentinel##n() \
00218 { \
00219     NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
00220     return NS_ERROR_NOT_IMPLEMENTED; \
00221 }
00222 
00223 #include "xptcstubsdef.inc"
00224 
00225 void
00226 xptc_dummy()
00227 {
00228 }
00229