Back to index

lightning-sunbird  0.9+nobinonly
xptcinvoke_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  *   Brendan Eich     <brendan@mozilla.org>
00027  *
00028  * Alternatively, the contents of this file may be used under the terms of
00029  * either of the GNU General Public License Version 2 or later (the "GPL"),
00030  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00031  * in which case the provisions of the GPL or the LGPL are applicable instead
00032  * of those above. If you wish to allow use of your version of this file only
00033  * under the terms of either the GPL or the LGPL, and not to allow others to
00034  * use your version of this file under the terms of the MPL, indicate your
00035  * decision by deleting the provisions above and replace them with the notice
00036  * and other provisions required by the GPL or the LGPL. If you do not delete
00037  * the provisions above, a recipient may use your version of this file under
00038  * the terms of any one of the MPL, the GPL or the LGPL.
00039  *
00040  * ***** END LICENSE BLOCK ***** */
00041 
00042 /* This code is for MIPS using the O32 ABI. */
00043 
00044 /* Platform specific code to invoke XPCOM methods on native objects */
00045 
00046 #include "xptcprivate.h"
00047 
00048 
00049 extern "C" uint32
00050 invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
00051 {
00052     // Count a word for a0 even though it's never stored or loaded
00053     // We do this only for alignment of register pairs.
00054     PRUint32 result = 1;
00055     for (PRUint32 i = 0; i < paramCount; i++, s++)
00056     {
00057         result++;
00058 
00059         if (s->IsPtrData())
00060             continue;
00061 
00062         switch(s->type)
00063         {
00064         case nsXPTType::T_I64    :
00065         case nsXPTType::T_U64    :
00066         case nsXPTType::T_DOUBLE :
00067            if (result & 1)
00068               result++;
00069            result++;
00070            break;
00071         }
00072     }
00073     return (result + 1) & ~(PRUint32)1;
00074 }
00075 
00076 extern "C" void
00077 invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount,
00078                      nsXPTCVariant* s)
00079 {
00080     // Skip the unused a0 slot, which we keep only for register pair alignment.
00081     d++;
00082 
00083     for (PRUint32 i = 0; i < paramCount; i++, d++, s++)
00084     {
00085         if (s->IsPtrData())
00086         {
00087             *((void**)d) = s->ptr;
00088             continue;
00089         }
00090 
00091         *((void**)d) = s->val.p;
00092 
00093         switch(s->type)
00094         {
00095         case nsXPTType::T_I64    :
00096             if ((PRWord)d & 4) d++;
00097             *((PRInt64*) d)  = s->val.i64;    d++;
00098             break;
00099         case nsXPTType::T_U64    :
00100             if ((PRWord)d & 4) d++;
00101             *((PRUint64*) d) = s->val.u64;    d++;
00102             break;
00103         case nsXPTType::T_DOUBLE :
00104             if ((PRWord)d & 4) d++;
00105             *((double*)   d) = s->val.d;      d++;
00106             break;
00107         }
00108     }
00109 }
00110 
00111 extern "C" nsresult _XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
00112                                         PRUint32 paramCount,
00113                                         nsXPTCVariant* params);
00114 
00115 extern "C"
00116 XPTC_PUBLIC_API(nsresult)
00117 XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
00118                    PRUint32 paramCount, nsXPTCVariant* params)
00119 {
00120     return _XPTC_InvokeByIndex(that, methodIndex, paramCount, params);
00121 }    
00122