~ubuntu-branches/ubuntu/gutsy/virtualbox-ose/gutsy

« back to all changes in this revision

Viewing changes to src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_irix.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-09-08 16:44:58 UTC
  • Revision ID: james.westby@ubuntu.com-20070908164458-wao29470vqtr8ksy
Tags: upstream-1.5.0-dfsg2
ImportĀ upstreamĀ versionĀ 1.5.0-dfsg2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
4
 *
 
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/
 
9
 *
 
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
 
13
 * License.
 
14
 *
 
15
 * The Original Code is mozilla.org code.
 
16
 *
 
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.
 
21
 *
 
22
 * Contributor(s):
 
23
 *
 
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.
 
35
 *
 
36
 * ***** END LICENSE BLOCK ***** */
 
37
 
 
38
#include "xptcprivate.h"
 
39
 
 
40
#if defined(IRIX)
 
41
 
 
42
#if (_MIPS_SIM != _ABIN32)
 
43
#error "This code is for IRIX N32 only"
 
44
#endif
 
45
 
 
46
/*
 
47
 * This is for IRIX N32 ABI
 
48
 *
 
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".
 
54
 *
 
55
 */
 
56
extern "C" nsresult
 
57
PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex, PRUint64* args,
 
58
                   PRUint64 *gprData, double *fprData)
 
59
{
 
60
#define PARAM_BUFFER_COUNT              16
 
61
#define PARAM_GPR_COUNT                 7
 
62
#define PARAM_FPR_COUNT                 7
 
63
 
 
64
    nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
 
65
    nsXPTCMiniVariant* dispatchParams = NULL;
 
66
    nsIInterfaceInfo* iface_info = NULL;
 
67
    const nsXPTMethodInfo* info;
 
68
    PRUint8 paramCount;
 
69
    PRUint8 i;
 
70
    nsresult result = NS_ERROR_FAILURE;
 
71
 
 
72
    NS_ASSERTION(self,"no self");
 
73
 
 
74
    self->GetInterfaceInfo(&iface_info);
 
75
    NS_ASSERTION(iface_info,"no interface info");
 
76
 
 
77
    iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
 
78
    NS_ASSERTION(info,"no interface info");
 
79
 
 
80
    paramCount = info->GetParamCount();
 
81
 
 
82
    // setup variant array pointer
 
83
    if(paramCount > PARAM_BUFFER_COUNT)
 
84
        dispatchParams = new nsXPTCMiniVariant[paramCount];
 
85
    else
 
86
        dispatchParams = paramBuffer;
 
87
    NS_ASSERTION(dispatchParams,"no place for params");
 
88
 
 
89
    PRUint64* ap = args;
 
90
    PRUint32 iCount = 0;
 
91
    for(i = 0; i < paramCount; i++)
 
92
    {
 
93
        const nsXPTParamInfo& param = info->GetParam(i);
 
94
        const nsXPTType& type = param.GetType();
 
95
        nsXPTCMiniVariant* dp = &dispatchParams[i];
 
96
 
 
97
        if(param.IsOut() || !type.IsArithmetic())
 
98
        {
 
99
            if (iCount < PARAM_GPR_COUNT)
 
100
                dp->val.p = (void*)gprData[iCount++];
 
101
            else
 
102
                dp->val.p = (void*)*ap++;
 
103
            continue;
 
104
        }
 
105
        // else
 
106
        switch(type)
 
107
        {
 
108
        case nsXPTType::T_I8:
 
109
           if (iCount < PARAM_GPR_COUNT)
 
110
              dp->val.i8  = (PRInt8)gprData[iCount++];
 
111
           else
 
112
              dp->val.i8  = (PRInt8)*ap++;
 
113
           break;
 
114
 
 
115
        case nsXPTType::T_I16:
 
116
            if (iCount < PARAM_GPR_COUNT)
 
117
               dp->val.i16  = (PRInt16)gprData[iCount++];
 
118
            else
 
119
               dp->val.i16  = (PRInt16)*ap++;
 
120
            break;
 
121
 
 
122
        case nsXPTType::T_I32:
 
123
            if (iCount < PARAM_GPR_COUNT)
 
124
               dp->val.i32  = (PRInt32)gprData[iCount++];
 
125
            else
 
126
               dp->val.i32  = (PRInt32)*ap++;
 
127
            break;
 
128
 
 
129
        case nsXPTType::T_I64:
 
130
            if (iCount < PARAM_GPR_COUNT)
 
131
               dp->val.i64  = (PRInt64)gprData[iCount++];
 
132
            else
 
133
               dp->val.i64  = (PRInt64)*ap++;
 
134
            break;
 
135
 
 
136
        case nsXPTType::T_U8:
 
137
            if (iCount < PARAM_GPR_COUNT)
 
138
               dp->val.u8  = (PRUint8)gprData[iCount++];
 
139
            else
 
140
               dp->val.u8  = (PRUint8)*ap++;
 
141
            break;
 
142
 
 
143
        case nsXPTType::T_U16:
 
144
            if (iCount < PARAM_GPR_COUNT)
 
145
               dp->val.u16  = (PRUint16)gprData[iCount++];
 
146
            else
 
147
                dp->val.u16  = (PRUint16)*ap++;
 
148
            break;
 
149
 
 
150
        case nsXPTType::T_U32:
 
151
            if (iCount < PARAM_GPR_COUNT)
 
152
               dp->val.u32  = (PRUint32)gprData[iCount++];
 
153
            else
 
154
               dp->val.u32  = (PRUint32)*ap++;
 
155
            break;
 
156
 
 
157
        case nsXPTType::T_U64:
 
158
            if (iCount < PARAM_GPR_COUNT)
 
159
               dp->val.u64  = (PRUint64)gprData[iCount++];
 
160
            else
 
161
               dp->val.u64  = (PRUint64)*ap++;
 
162
            break;
 
163
 
 
164
        case nsXPTType::T_FLOAT:
 
165
             if (iCount < PARAM_FPR_COUNT)
 
166
                dp->val.f  = (double)fprData[iCount++];
 
167
             else
 
168
                dp->val.f  = *((double*)ap++);
 
169
             break;
 
170
 
 
171
        case nsXPTType::T_DOUBLE:
 
172
              if (iCount < PARAM_FPR_COUNT)
 
173
                 dp->val.d  = (double)fprData[iCount++];
 
174
              else
 
175
                 dp->val.d  = *((double*)ap++);
 
176
              break;
 
177
 
 
178
        case nsXPTType::T_BOOL:
 
179
           if (iCount < PARAM_GPR_COUNT)
 
180
              dp->val.b  = (PRBool)gprData[iCount++];
 
181
           else
 
182
              dp->val.b  = (PRBool)*ap++;
 
183
           break;
 
184
 
 
185
        case nsXPTType::T_CHAR:
 
186
           if (iCount < PARAM_GPR_COUNT)
 
187
              dp->val.c  = (char)gprData[iCount++];
 
188
           else
 
189
              dp->val.c  = (char)*ap++;
 
190
           break;
 
191
 
 
192
        case nsXPTType::T_WCHAR:
 
193
           if (iCount < PARAM_GPR_COUNT)
 
194
              dp->val.wc  = (wchar_t)gprData[iCount++];
 
195
           else
 
196
              dp->val.wc  = (wchar_t)*ap++;
 
197
           break;
 
198
 
 
199
        default:
 
200
            NS_ASSERTION(0, "bad type");
 
201
            break;
 
202
        }
 
203
    }
 
204
 
 
205
    result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
 
206
 
 
207
    NS_RELEASE(iface_info);
 
208
 
 
209
    if(dispatchParams != paramBuffer)
 
210
        delete [] dispatchParams;
 
211
 
 
212
    return result;
 
213
}
 
214
 
 
215
#define STUB_ENTRY(n)           /* defined in the assembly file */
 
216
 
 
217
#define SENTINEL_ENTRY(n) \
 
218
nsresult nsXPTCStubBase::Sentinel##n() \
 
219
{ \
 
220
    NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
 
221
    return NS_ERROR_NOT_IMPLEMENTED; \
 
222
}
 
223
 
 
224
#include "xptcstubsdef.inc"
 
225
 
 
226
#endif