Back to index

lightning-sunbird  0.9+nobinonly
xptcinvoke_ppc_rhapsody.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; 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 extern "C" uint32
00043 invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
00044 {
00045     PRUint32 result = 0;
00046     /*    fprintf(stderr,"invoke_count_words(%d,%p)\n",paramCount, s);*/
00047 
00048     for(PRUint32 i = 0; i < paramCount; i++, s++)
00049     {
00050         if(s->IsPtrData())
00051         {
00052             result++;
00053             continue;
00054         }
00055         switch(s->type)
00056         {
00057         case nsXPTType::T_I8     :
00058         case nsXPTType::T_I16    :
00059         case nsXPTType::T_I32    :
00060             result++;
00061             break;
00062         case nsXPTType::T_I64    :
00063             result+=2;
00064             break;
00065         case nsXPTType::T_U8     :
00066         case nsXPTType::T_U16    :
00067         case nsXPTType::T_U32    :
00068             result++;
00069             break;
00070         case nsXPTType::T_U64    :
00071             result+=2;
00072             break;
00073         case nsXPTType::T_FLOAT  :
00074             result++;
00075             break;
00076         case nsXPTType::T_DOUBLE :
00077             result+=2;
00078             break;
00079         case nsXPTType::T_BOOL   :
00080         case nsXPTType::T_CHAR   :
00081         case nsXPTType::T_WCHAR  :
00082             result++;
00083             break;
00084         default:
00085             // all the others are plain pointer types
00086             result++;
00087             break;
00088         }
00089     }
00090     return result;
00091 }
00092 
00093 extern "C" void
00094 invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s, double *fprData)
00095 {
00096        PRUint32 fpCount = 0;
00097 
00098     /*    fprintf(stderr,"invoke_copy_to_stack(%p, %d, %p, %p)\n", d, paramCount, s, fprData);*/
00099 
00100     for(PRUint32 i = 0; i < paramCount; i++, d++, s++)
00101     {
00102         if(s->IsPtrData())
00103         {
00104             *((void**)d) = s->ptr;
00105             continue;
00106         }
00107         switch(s->type)
00108         {
00109         case nsXPTType::T_I8     : *((PRInt32*) d) = s->val.i8;          break;
00110         case nsXPTType::T_I16    : *((PRInt32*) d) = s->val.i16;         break;
00111         case nsXPTType::T_I32    : *((PRInt32*) d) = s->val.i32;         break;
00112         case nsXPTType::T_I64    : *((PRInt64*) d) = s->val.i64; d++;    break;
00113         case nsXPTType::T_U8     : *((PRUint32*) d) = s->val.u8;          break;
00114         case nsXPTType::T_U16    : *((PRUint32*)d) = s->val.u16;         break;
00115         case nsXPTType::T_U32    : *((PRUint32*)d) = s->val.u32;         break;
00116         case nsXPTType::T_U64    : *((PRUint64*)d) = s->val.u64; d++;    break;
00117         case nsXPTType::T_FLOAT  : *((float*)   d) = s->val.f;
00118                                if (fpCount < 13)
00119                                     fprData[fpCount++] = s->val.f;
00120                                break;
00121         case nsXPTType::T_DOUBLE : *((double*)  d) = s->val.d;   d++;
00122                                if (fpCount < 13)
00123                                    fprData[fpCount++] = s->val.d;
00124                                break;
00125         case nsXPTType::T_BOOL   : *((PRBool*)  d) = s->val.b;           break;
00126         case nsXPTType::T_CHAR   : *((PRInt32*)    d) = s->val.c;        break;
00127         case nsXPTType::T_WCHAR  : *((PRUint32*) d) = s->val.wc;         break;
00128         default:
00129             // all the others are plain pointer types
00130             *((void**)d) = s->val.p;
00131             break;
00132         }
00133     }
00134 }
00135 
00136 extern "C" nsresult _XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
00137                    PRUint32 paramCount, nsXPTCVariant* params);
00138 
00139 extern "C"
00140 XPTC_PUBLIC_API(nsresult)
00141 XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
00142                    PRUint32 paramCount, nsXPTCVariant* params)
00143 {
00144     return _XPTC_InvokeByIndex(that, methodIndex, paramCount, params);
00145 }