Back to index

lightning-sunbird  0.9+nobinonly
xptcinvoke_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) 1998
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 /* Platform specific code to invoke XPCOM methods on native objects */
00039 
00040 #include "xptcprivate.h"
00041 
00042 #if (_MIPS_SIM != _ABIN32)
00043 #error "This code is for IRIX N32 only"
00044 #endif
00045 
00046 extern "C" uint32
00047 invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
00048 {
00049     return(paramCount*2);
00050 }
00051 
00052 extern "C" void
00053 invoke_copy_to_stack(PRUint64* d, PRUint32 paramCount,
00054                      nsXPTCVariant* s, PRUint64 *regs)
00055 {
00056 #define N_ARG_REGS       7       /* 8 regs minus 1 for "this" ptr */
00057 
00058     for (PRUint32 i = 0; i < paramCount; i++, s++)
00059     {
00060         if (s->IsPtrData()) {
00061             if (i < N_ARG_REGS)
00062                regs[i] = (PRUint64)s->ptr;
00063             else
00064                *d++ = (PRUint64)s->ptr; 
00065             continue;
00066         }
00067         switch (s->type) {
00068         //
00069         // signed types first
00070         //
00071         case nsXPTType::T_I8:
00072            if (i < N_ARG_REGS)
00073               ((PRInt64*)regs)[i] = s->val.i8;
00074            else
00075               *d++ = s->val.i8;
00076            break;
00077         case nsXPTType::T_I16:
00078            if (i < N_ARG_REGS)
00079               ((PRInt64*)regs)[i] = s->val.i16;
00080            else
00081               *d++ = s->val.i16;
00082            break;
00083         case nsXPTType::T_I32:
00084            if (i < N_ARG_REGS)
00085               ((PRInt64*)regs)[i] = s->val.i32;
00086            else
00087               *d++ = s->val.i32;
00088            break;
00089         case nsXPTType::T_I64:
00090            if (i < N_ARG_REGS)
00091               ((PRInt64*)regs)[i] = s->val.i64;
00092            else
00093               *d++ = s->val.i64;
00094            break;
00095         //
00096         // unsigned types next
00097         //
00098         case nsXPTType::T_U8:
00099            if (i < N_ARG_REGS)
00100               regs[i] = s->val.u8;
00101            else
00102               *d++ = s->val.u8;
00103            break;
00104         case nsXPTType::T_U16:
00105            if (i < N_ARG_REGS)
00106               regs[i] = s->val.u16;
00107            else
00108               *d++ = s->val.u16;
00109            break;
00110         case nsXPTType::T_U32:
00111            if (i < N_ARG_REGS)
00112               regs[i] = s->val.u32;
00113            else
00114               *d++ = s->val.u32;
00115            break;
00116         case nsXPTType::T_U64:
00117            if (i < N_ARG_REGS)
00118               regs[i] = s->val.u64;
00119            else
00120               *d++ = s->val.u64;
00121            break;
00122         case nsXPTType::T_FLOAT:
00123            if (i < N_ARG_REGS)
00124               // Place a float in least significant bytes.
00125               *(float*)(((char*)&regs[i+1]) - sizeof(float)) = s->val.f;
00126            else
00127               *(float*)d++ = s->val.f;
00128            break;
00129         case nsXPTType::T_DOUBLE:
00130            if (i < N_ARG_REGS)
00131               *(double*)&regs[i] = s->val.d;
00132            else
00133               *(double*)d++ = s->val.d;
00134            break;
00135         case nsXPTType::T_BOOL:
00136            if (i < N_ARG_REGS)
00137               regs[i] = s->val.b;
00138            else
00139               *d++ = s->val.b;
00140            break;
00141         case nsXPTType::T_CHAR:
00142            if (i < N_ARG_REGS)
00143               regs[i] = s->val.c;
00144            else
00145               *d++ = s->val.c;
00146            break;
00147         case nsXPTType::T_WCHAR:
00148            if (i < N_ARG_REGS)
00149               regs[i] = s->val.wc;
00150            else
00151               *d++ = s->val.wc;
00152            break;
00153         default:
00154            // all the others are plain pointer types
00155            if (i < N_ARG_REGS)
00156               regs[i] = (PRUint64)s->val.p;
00157            else
00158               *d++ = (PRUint64)s->val.p;
00159            break;
00160         }
00161     }
00162 }
00163 
00164 extern "C" nsresult _XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
00165                    PRUint32 paramCount, nsXPTCVariant* params);
00166 
00167 extern "C"
00168 XPTC_PUBLIC_API(nsresult)
00169 XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
00170                    PRUint32 paramCount, nsXPTCVariant* params)
00171 {
00172     return _XPTC_InvokeByIndex(that, methodIndex, paramCount, params);
00173 }