]> gitweb @ CieloNegro.org - pkgsrc-firefox3.git/blob - files/xptcstubs_sparc64_netbsd.cpp
Initial revision of the upstream www/firefox3
[pkgsrc-firefox3.git] / files / xptcstubs_sparc64_netbsd.cpp
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * The contents of this file are subject to the Netscape Public
4  * License Version 1.1 (the "License"); you may not use this file
5  * except in compliance with the License. You may obtain a copy of
6  * the License at http://www.mozilla.org/NPL/
7  *
8  * Software distributed under the License is distributed on an "AS
9  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10  * implied. See the License for the specific language governing
11  * rights and limitations under the License.
12  *
13  * The Original Code is mozilla.org code.
14  *
15  * The Initial Developer of the Original Code is Netscape
16  * Communications Corporation.  Portions created by Netscape are
17  * Copyright (C) 1999 Netscape Communications Corporation. All
18  * Rights Reserved.
19  *
20  * Contributor(s): 
21  */
22
23 /* Implement shared vtbl methods. */
24
25 #include "xptcprivate.h"
26 #include "xptiprivate.h"
27
28 #if defined(sparc) || defined(__sparc__)
29
30 extern "C" nsresult
31 PrepareAndDispatch(nsXPTCStubBase* self, PRUint64 methodIndex, PRUint64* args)
32 {
33
34 #define PARAM_BUFFER_COUNT     16
35
36     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
37     nsXPTCMiniVariant* dispatchParams = NULL;
38     const nsXPTMethodInfo* info;
39     PRUint8 paramCount;
40     PRUint8 i;
41     nsresult result = NS_ERROR_FAILURE;
42
43     NS_ASSERTION(self,"no self");
44
45     self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
46     NS_ASSERTION(info,"no interface info");
47
48     paramCount = info->GetParamCount();
49
50     // setup variant array pointer
51     if(paramCount > PARAM_BUFFER_COUNT)
52         dispatchParams = new nsXPTCMiniVariant[paramCount];
53     else
54         dispatchParams = paramBuffer;
55     NS_ASSERTION(dispatchParams,"no place for params");
56     if (!dispatchParams)
57         return NS_ERROR_OUT_OF_MEMORY;
58
59     PRUint64* ap = args;
60     for(i = 0; i < paramCount; i++, ap++)
61     {
62         const nsXPTParamInfo& param = info->GetParam(i);
63         const nsXPTType& type = param.GetType();
64         nsXPTCMiniVariant* dp = &dispatchParams[i];
65
66         if(param.IsOut() || !type.IsArithmetic())
67         {
68             dp->val.p = (void*) *ap;
69             continue;
70         }
71         // else
72         switch(type)
73         {
74         case nsXPTType::T_BOOL   : dp->val.b   = *((PRInt64*)  ap);      break;
75         case nsXPTType::T_CHAR   : dp->val.c   = *((PRUint64*) ap);      break;
76         case nsXPTType::T_WCHAR  : dp->val.wc  = *((PRInt64*) ap);       break;
77         case nsXPTType::T_I8     : dp->val.i8  = *((PRInt64*)  ap);      break;
78         case nsXPTType::T_I16    : dp->val.i16 = *((PRInt64*) ap);       break;
79         case nsXPTType::T_I32    : dp->val.i32 = *((PRInt64*) ap);       break;
80         case nsXPTType::T_I64    : dp->val.i64 = *((PRInt64*) ap);       break;
81         case nsXPTType::T_U8     : dp->val.u8  = *((PRUint64*) ap);      break;
82         case nsXPTType::T_U16    : dp->val.u16 = *((PRUint64*)ap);       break;
83         case nsXPTType::T_U32    : dp->val.u32 = *((PRUint64*)ap);       break;
84         case nsXPTType::T_U64    : dp->val.u64 = *((PRUint64*) ap);      break;
85         case nsXPTType::T_FLOAT  : dp->val.f   = ((float*)   ap)[1];     break;
86         case nsXPTType::T_DOUBLE : dp->val.d   = *((double*) ap);        break;
87         default:
88             NS_ASSERTION(0, "bad type");
89             break;
90         }
91     }
92
93     result = self->mOuter->CallMethod((PRUint16)methodIndex, info, dispatchParams);
94
95     if(dispatchParams != paramBuffer)
96         delete [] dispatchParams;
97
98     return result;
99 }
100
101 extern "C" int SharedStub(int, int*);
102
103 #define STUB_ENTRY(n) \
104 nsresult nsXPTCStubBase::Stub##n() \
105 { \
106         int dummy; /* defeat tail-call optimization */ \
107         return SharedStub(n, &dummy); \
108 }
109
110 #define SENTINEL_ENTRY(n) \
111 nsresult nsXPTCStubBase::Sentinel##n() \
112 { \
113     NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
114     return NS_ERROR_NOT_IMPLEMENTED; \
115 }
116
117 #include "xptcstubsdef.inc"
118
119 #endif /* sparc || __sparc__ */