1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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/
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.
13 * The Original Code is mozilla.org code.
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
23 /* Implement shared vtbl methods. */
25 #include "xptcprivate.h"
26 #include "xptiprivate.h"
28 #if defined(sparc) || defined(__sparc__)
31 PrepareAndDispatch(nsXPTCStubBase* self, PRUint64 methodIndex, PRUint64* args)
34 #define PARAM_BUFFER_COUNT 16
36 nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
37 nsXPTCMiniVariant* dispatchParams = NULL;
38 const nsXPTMethodInfo* info;
41 nsresult result = NS_ERROR_FAILURE;
43 NS_ASSERTION(self,"no self");
45 self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
46 NS_ASSERTION(info,"no interface info");
48 paramCount = info->GetParamCount();
50 // setup variant array pointer
51 if(paramCount > PARAM_BUFFER_COUNT)
52 dispatchParams = new nsXPTCMiniVariant[paramCount];
54 dispatchParams = paramBuffer;
55 NS_ASSERTION(dispatchParams,"no place for params");
57 return NS_ERROR_OUT_OF_MEMORY;
60 for(i = 0; i < paramCount; i++, ap++)
62 const nsXPTParamInfo& param = info->GetParam(i);
63 const nsXPTType& type = param.GetType();
64 nsXPTCMiniVariant* dp = &dispatchParams[i];
66 if(param.IsOut() || !type.IsArithmetic())
68 dp->val.p = (void*) *ap;
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;
88 NS_ASSERTION(0, "bad type");
93 result = self->mOuter->CallMethod((PRUint16)methodIndex, info, dispatchParams);
95 if(dispatchParams != paramBuffer)
96 delete [] dispatchParams;
101 extern "C" int SharedStub(int, int*);
103 #define STUB_ENTRY(n) \
104 nsresult nsXPTCStubBase::Stub##n() \
106 int dummy; /* defeat tail-call optimization */ \
107 return SharedStub(n, &dummy); \
110 #define SENTINEL_ENTRY(n) \
111 nsresult nsXPTCStubBase::Sentinel##n() \
113 NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
114 return NS_ERROR_NOT_IMPLEMENTED; \
117 #include "xptcstubsdef.inc"
119 #endif /* sparc || __sparc__ */