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) 1999
20
* the Initial Developer. All Rights Reserved.
24
* Alternatively, the contents of this file may be used under the terms of
25
* either of the GNU General Public License Version 2 or later (the "GPL"),
26
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the MPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the MPL, the GPL or the LGPL.
36
* ***** END LICENSE BLOCK ***** */
38
#include "xptcprivate.h"
42
#if (_MIPS_SIM != _ABIN32)
43
#error "This code is for IRIX N32 only"
47
* This is for IRIX N32 ABI
49
* When we're called, the "gp" registers are stored in gprData and
50
* the "fp" registers are stored in fprData. There are 8 regs
51
* available which coorespond to the first 7 parameters of the
52
* function and the "this" pointer. If there are additional parms,
53
* they are stored on the stack at address "args".
57
PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex, PRUint64* args,
58
PRUint64 *gprData, double *fprData)
60
#define PARAM_BUFFER_COUNT 16
61
#define PARAM_GPR_COUNT 7
62
#define PARAM_FPR_COUNT 7
64
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
65
nsXPTCMiniVariant* dispatchParams = NULL;
66
nsIInterfaceInfo* iface_info = NULL;
67
const nsXPTMethodInfo* info;
70
nsresult result = NS_ERROR_FAILURE;
72
NS_ASSERTION(self,"no self");
74
self->GetInterfaceInfo(&iface_info);
75
NS_ASSERTION(iface_info,"no interface info");
77
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
78
NS_ASSERTION(info,"no interface info");
80
paramCount = info->GetParamCount();
82
// setup variant array pointer
83
if(paramCount > PARAM_BUFFER_COUNT)
84
dispatchParams = new nsXPTCMiniVariant[paramCount];
86
dispatchParams = paramBuffer;
87
NS_ASSERTION(dispatchParams,"no place for params");
91
for(i = 0; i < paramCount; i++)
93
const nsXPTParamInfo& param = info->GetParam(i);
94
const nsXPTType& type = param.GetType();
95
nsXPTCMiniVariant* dp = &dispatchParams[i];
97
if(param.IsOut() || !type.IsArithmetic())
99
if (iCount < PARAM_GPR_COUNT)
100
dp->val.p = (void*)gprData[iCount++];
102
dp->val.p = (void*)*ap++;
108
case nsXPTType::T_I8:
109
if (iCount < PARAM_GPR_COUNT)
110
dp->val.i8 = (PRInt8)gprData[iCount++];
112
dp->val.i8 = (PRInt8)*ap++;
115
case nsXPTType::T_I16:
116
if (iCount < PARAM_GPR_COUNT)
117
dp->val.i16 = (PRInt16)gprData[iCount++];
119
dp->val.i16 = (PRInt16)*ap++;
122
case nsXPTType::T_I32:
123
if (iCount < PARAM_GPR_COUNT)
124
dp->val.i32 = (PRInt32)gprData[iCount++];
126
dp->val.i32 = (PRInt32)*ap++;
129
case nsXPTType::T_I64:
130
if (iCount < PARAM_GPR_COUNT)
131
dp->val.i64 = (PRInt64)gprData[iCount++];
133
dp->val.i64 = (PRInt64)*ap++;
136
case nsXPTType::T_U8:
137
if (iCount < PARAM_GPR_COUNT)
138
dp->val.u8 = (PRUint8)gprData[iCount++];
140
dp->val.u8 = (PRUint8)*ap++;
143
case nsXPTType::T_U16:
144
if (iCount < PARAM_GPR_COUNT)
145
dp->val.u16 = (PRUint16)gprData[iCount++];
147
dp->val.u16 = (PRUint16)*ap++;
150
case nsXPTType::T_U32:
151
if (iCount < PARAM_GPR_COUNT)
152
dp->val.u32 = (PRUint32)gprData[iCount++];
154
dp->val.u32 = (PRUint32)*ap++;
157
case nsXPTType::T_U64:
158
if (iCount < PARAM_GPR_COUNT)
159
dp->val.u64 = (PRUint64)gprData[iCount++];
161
dp->val.u64 = (PRUint64)*ap++;
164
case nsXPTType::T_FLOAT:
165
if (iCount < PARAM_FPR_COUNT)
166
dp->val.f = (double)fprData[iCount++];
168
dp->val.f = *((double*)ap++);
171
case nsXPTType::T_DOUBLE:
172
if (iCount < PARAM_FPR_COUNT)
173
dp->val.d = (double)fprData[iCount++];
175
dp->val.d = *((double*)ap++);
178
case nsXPTType::T_BOOL:
179
if (iCount < PARAM_GPR_COUNT)
180
dp->val.b = (PRBool)gprData[iCount++];
182
dp->val.b = (PRBool)*ap++;
185
case nsXPTType::T_CHAR:
186
if (iCount < PARAM_GPR_COUNT)
187
dp->val.c = (char)gprData[iCount++];
189
dp->val.c = (char)*ap++;
192
case nsXPTType::T_WCHAR:
193
if (iCount < PARAM_GPR_COUNT)
194
dp->val.wc = (wchar_t)gprData[iCount++];
196
dp->val.wc = (wchar_t)*ap++;
200
NS_ASSERTION(0, "bad type");
205
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
207
NS_RELEASE(iface_info);
209
if(dispatchParams != paramBuffer)
210
delete [] dispatchParams;
215
#define STUB_ENTRY(n) /* defined in the assembly file */
217
#define SENTINEL_ENTRY(n) \
218
nsresult nsXPTCStubBase::Sentinel##n() \
220
NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
221
return NS_ERROR_NOT_IMPLEMENTED; \
224
#include "xptcstubsdef.inc"