1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Mozilla Public License Version
6
* 1.1 (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/MPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998
20
* the Initial Developer. All Rights Reserved.
23
* Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
24
* beard@netscape.com (Patrick Beard)
25
* waterson@netscape.com (Chris Waterson)
27
* Alternatively, the contents of this file may be used under the terms of
28
* either of the GNU General Public License Version 2 or later (the "GPL"),
29
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30
* in which case the provisions of the GPL or the LGPL are applicable instead
31
* of those above. If you wish to allow use of your version of this file only
32
* under the terms of either the GPL or the LGPL, and not to allow others to
33
* use your version of this file under the terms of the MPL, indicate your
34
* decision by deleting the provisions above and replace them with the notice
35
* and other provisions required by the GPL or the LGPL. If you do not delete
36
* the provisions above, a recipient may use your version of this file under
37
* the terms of any one of the MPL, the GPL or the LGPL.
39
* ***** END LICENSE BLOCK ***** */
41
// Platform specific code to invoke XPCOM methods on native objects
43
// The purpose of XPTC_InvokeByIndex() is to map a platform
44
// indepenpent call to the platform ABI. To do that,
45
// XPTC_InvokeByIndex() has to determine the method to call via vtable
46
// access. The parameters for the method are read from the
47
// nsXPTCVariant* and prepared for th native ABI. For the Linux/PPC
48
// ABI this means that the first 8 integral and floating point
49
// parameters are passed in registers.
51
#include "xptcprivate.h"
53
// 8 integral parameters are passed in registers
56
// 8 floating point parameters are passed in registers, floats are
57
// promoted to doubles when passed in registers
61
invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
63
return PRUint32(((paramCount * 2) + 3) & ~3);
67
invoke_copy_to_stack(PRUint32* d,
73
PRUint32 gpr = 1; // skip one GP reg for 'that'
78
for(uint32 i = 0; i < paramCount; i++, s++) {
80
tempu32 = (PRUint32) s->ptr;
83
case nsXPTType::T_FLOAT: break;
84
case nsXPTType::T_DOUBLE: break;
85
case nsXPTType::T_I8: tempu32 = s->val.i8; break;
86
case nsXPTType::T_I16: tempu32 = s->val.i16; break;
87
case nsXPTType::T_I32: tempu32 = s->val.i32; break;
88
case nsXPTType::T_I64: tempu64 = s->val.i64; break;
89
case nsXPTType::T_U8: tempu32 = s->val.u8; break;
90
case nsXPTType::T_U16: tempu32 = s->val.u16; break;
91
case nsXPTType::T_U32: tempu32 = s->val.u32; break;
92
case nsXPTType::T_U64: tempu64 = s->val.u64; break;
93
case nsXPTType::T_BOOL: tempu32 = s->val.b; break;
94
case nsXPTType::T_CHAR: tempu32 = s->val.c; break;
95
case nsXPTType::T_WCHAR: tempu32 = s->val.wc; break;
96
default: tempu32 = (PRUint32) s->val.p; break;
100
if (!s->IsPtrData() && s->type == nsXPTType::T_DOUBLE) {
102
fpregs[fpr++] = s->val.d;
104
if ((PRUint32) d & 4) d++; // doubles are 8-byte aligned on stack
105
*((double*) d) = s->val.d;
111
else if (!s->IsPtrData() && s->type == nsXPTType::T_FLOAT) {
113
fpregs[fpr++] = s->val.f; // if passed in registers, floats are promoted to doubles
115
*((float*) d) = s->val.f;
121
else if (!s->IsPtrData() && (s->type == nsXPTType::T_I64
122
|| s->type == nsXPTType::T_U64)) {
123
if ((gpr + 1) < GPR_COUNT) {
124
if (gpr & 1) gpr++; // longlongs are aligned in odd/even register pairs, eg. r5/r6
125
*((PRUint64*) &gpregs[gpr]) = tempu64;
129
if ((PRUint32) d & 4) d++; // longlongs are 8-byte aligned on stack
130
*((PRUint64*) d) = tempu64;
136
gpregs[gpr++] = tempu32;
145
XPTC_PUBLIC_API(nsresult)
146
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
147
PRUint32 paramCount, nsXPTCVariant* params);