Back to index

lightning-sunbird  0.9+nobinonly
xptcstubs_mips.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  * Version: MPL 1.1
00003  *
00004  * ***** BEGIN LICENSE BLOCK *****
00005  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00006  *
00007  * The contents of this file are subject to the Mozilla Public License Version
00008  * 1.1 (the "License"); you may not use this file except in compliance with
00009  * the License. You may obtain a copy of the License at
00010  * http://www.mozilla.org/MPL/
00011  *
00012  * Software distributed under the License is distributed on an "AS IS" basis,
00013  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00014  * for the specific language governing rights and limitations under the
00015  * License.
00016  *
00017  * The Original Code is mozilla.org code.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corp, Inc.
00021  * Portions created by the Initial Developer are Copyright (C) 2001
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *   Stuart Parmenter <pavlov@netscape.com>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either of the GNU General Public License Version 2 or later (the "GPL"),
00029  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 #include "xptcprivate.h"
00042 
00043 /*
00044  * This is for MIPS O32 ABI
00045  * Args contains a0-3 and then the stack.
00046  * Because a0 is 'this', we want to skip it
00047  */
00048 extern "C" nsresult
00049 PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex, PRUint32* args)
00050 {
00051     args++; // always skip over a0
00052 
00053 #define PARAM_BUFFER_COUNT         16
00054 
00055     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
00056     nsXPTCMiniVariant* dispatchParams = NULL;
00057     nsIInterfaceInfo* iface_info = NULL;
00058     const nsXPTMethodInfo* info;
00059     PRUint8 paramCount;
00060     PRUint8 i;
00061     nsresult result = NS_ERROR_FAILURE;
00062 
00063     NS_ASSERTION(self,"no self");
00064 
00065     self->GetInterfaceInfo(&iface_info);
00066     NS_ASSERTION(iface_info,"no interface info");
00067 
00068     iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
00069     NS_ASSERTION(info,"no interface info");
00070 
00071     paramCount = info->GetParamCount();
00072 
00073     // setup variant array pointer
00074     if(paramCount > PARAM_BUFFER_COUNT)
00075         dispatchParams = new nsXPTCMiniVariant[paramCount];
00076     else
00077         dispatchParams = paramBuffer;
00078     NS_ASSERTION(dispatchParams,"no place for params");
00079 
00080     PRUint32* ap = args;
00081     for(i = 0; i < paramCount; i++, ap++)
00082     {
00083         const nsXPTParamInfo& param = info->GetParam(i);
00084         const nsXPTType& type = param.GetType();
00085         nsXPTCMiniVariant* dp = &dispatchParams[i];
00086 
00087         if(param.IsOut() || !type.IsArithmetic())
00088         {
00089             dp->val.p = (void*) *ap;
00090             continue;
00091         }
00092 
00093         dp->val.p = (void*) *ap;
00094 
00095         switch(type)
00096         {
00097         case nsXPTType::T_I64   :
00098             if ((PRWord)ap & 4) ap++;
00099             dp->val.i64 = *((PRInt64*) ap); ap++;
00100             break;
00101         case nsXPTType::T_U64   :
00102             if ((PRWord)ap & 4) ap++;
00103             dp->val.u64 = *((PRInt64*) ap); ap++;
00104             break;
00105         case nsXPTType::T_DOUBLE:
00106             if ((PRWord)ap & 4) ap++;
00107             dp->val.d   = *((double*) ap);  ap++;
00108             break;
00109         }
00110     }
00111 
00112     result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
00113 
00114     NS_RELEASE(iface_info);
00115 
00116     if(dispatchParams != paramBuffer)
00117         delete [] dispatchParams;
00118 
00119     return result;
00120 }
00121 
00122 #define STUB_ENTRY(n) // done in the .s file
00123 
00124 #define SENTINEL_ENTRY(n) \
00125 nsresult nsXPTCStubBase::Sentinel##n() \
00126 { \
00127     NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
00128     return NS_ERROR_NOT_IMPLEMENTED; \
00129 }
00130 
00131 #include "xptcstubsdef.inc"