Back to index

lightning-sunbird  0.9+nobinonly
xptcstubs_sparc64_openbsd.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * The contents of this file are subject to the Mozilla Public
00004  * License Version 1.1 (the "License"); you may not use this file
00005  * except in compliance with the License. You may obtain a copy of
00006  * the License at http://www.mozilla.org/MPL/
00007  * 
00008  * Software distributed under the License is distributed on an "AS
00009  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
00010  * implied. See the License for the specific language governing
00011  * rights and limitations under the License.
00012  * 
00013  * The Original Code is mozilla.org code.
00014  * 
00015  * The Initial Developer of the Original Code is Netscape
00016  * Communications Corporation. Portions created by Netscape are
00017  * Copyright (C) 2001 Netscape Communications Corporation. All
00018  * Rights Reserved.
00019  * 
00020  * Contributor(s): 
00021  *   Stuart Parmenter <pavlov@netscape.com>
00022  */
00023 
00024 /* Implement shared vtbl methods. */
00025 
00026 #include "xptcprivate.h"
00027 
00028 #if defined(sparc) || defined(__sparc__)
00029 
00030 extern "C" nsresult
00031 PrepareAndDispatch(nsXPTCStubBase* self, PRUint64 methodIndex, PRUint64* args)
00032 {
00033 
00034 #define PARAM_BUFFER_COUNT     16
00035 
00036     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
00037     nsXPTCMiniVariant* dispatchParams = NULL;
00038     nsIInterfaceInfo* iface_info = NULL;
00039     const nsXPTMethodInfo* info;
00040     PRUint8 paramCount;
00041     PRUint8 i;
00042     nsresult result = NS_ERROR_FAILURE;
00043 
00044     NS_ASSERTION(self,"no self");
00045 
00046     self->GetInterfaceInfo(&iface_info);
00047     NS_ASSERTION(iface_info,"no interface info");
00048 
00049     iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
00050     NS_ASSERTION(info,"no interface info");
00051 
00052     paramCount = info->GetParamCount();
00053 
00054     // setup variant array pointer
00055     if(paramCount > PARAM_BUFFER_COUNT)
00056         dispatchParams = new nsXPTCMiniVariant[paramCount];
00057     else
00058         dispatchParams = paramBuffer;
00059     NS_ASSERTION(dispatchParams,"no place for params");
00060 
00061     PRUint64* ap = args;
00062     for(i = 0; i < paramCount; i++, ap++)
00063     {
00064         const nsXPTParamInfo& param = info->GetParam(i);
00065         const nsXPTType& type = param.GetType();
00066         nsXPTCMiniVariant* dp = &dispatchParams[i];
00067 
00068         if(param.IsOut() || !type.IsArithmetic())
00069         {
00070             dp->val.p = (void*) *ap;
00071             continue;
00072         }
00073         // else
00074         switch(type)
00075         {
00076         case nsXPTType::T_BOOL   : dp->val.b   = *((PRInt64*)  ap);      break;
00077         case nsXPTType::T_CHAR   : dp->val.c   = *((PRUint64*) ap);      break;
00078         case nsXPTType::T_WCHAR  : dp->val.wc  = *((PRInt64*) ap);       break;
00079         case nsXPTType::T_I8     : dp->val.i8  = *((PRInt64*)  ap);      break;
00080         case nsXPTType::T_I16    : dp->val.i16 = *((PRInt64*) ap);       break;
00081         case nsXPTType::T_I32    : dp->val.i32 = *((PRInt64*) ap);       break;
00082         case nsXPTType::T_I64    : dp->val.i64 = *((PRInt64*) ap);       break;
00083         case nsXPTType::T_U8     : dp->val.u8  = *((PRUint64*) ap);      break;
00084         case nsXPTType::T_U16    : dp->val.u16 = *((PRUint64*)ap);       break;
00085         case nsXPTType::T_U32    : dp->val.u32 = *((PRUint64*)ap);       break;
00086         case nsXPTType::T_U64    : dp->val.u64 = *((PRUint64*) ap);      break;
00087         case nsXPTType::T_FLOAT  : dp->val.f   = ((float*)   ap)[1];     break;
00088         case nsXPTType::T_DOUBLE : dp->val.d   = *((double*) ap);        break;
00089         default:
00090             NS_ASSERTION(0, "bad type");
00091             break;
00092         }
00093     }
00094 
00095     result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
00096 
00097     NS_RELEASE(iface_info);
00098 
00099     if(dispatchParams != paramBuffer)
00100         delete [] dispatchParams;
00101 
00102     return result;
00103 }
00104 
00105 extern "C" int SharedStub(int, int*);
00106 
00107 #define STUB_ENTRY(n) \
00108 nsresult nsXPTCStubBase::Stub##n() \
00109 { \
00110        int dummy; /* defeat tail-call optimization */ \
00111        return SharedStub(n, &dummy); \
00112 }
00113 
00114 #define SENTINEL_ENTRY(n) \
00115 nsresult nsXPTCStubBase::Sentinel##n() \
00116 { \
00117     NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
00118     return NS_ERROR_NOT_IMPLEMENTED; \
00119 }
00120 
00121 #include "xptcstubsdef.inc"
00122 
00123 #endif /* sparc || __sparc__ */