1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_linux_m68k.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 1.4 +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* Implement shared vtbl methods. */ 1.10 + 1.11 +#include "xptcprivate.h" 1.12 +#include "xptiprivate.h" 1.13 + 1.14 +extern "C" { 1.15 + nsresult ATTRIBUTE_USED 1.16 + PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args) 1.17 + { 1.18 +#define PARAM_BUFFER_COUNT 16 1.19 + 1.20 + nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; 1.21 + nsXPTCMiniVariant* dispatchParams = nullptr; 1.22 + const nsXPTMethodInfo* info; 1.23 + uint8_t paramCount; 1.24 + uint8_t i; 1.25 + nsresult result = NS_ERROR_FAILURE; 1.26 + 1.27 + NS_ASSERTION(self,"no self"); 1.28 + 1.29 + self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info); 1.30 + NS_ASSERTION(info,"no method info"); 1.31 + 1.32 + paramCount = info->GetParamCount(); 1.33 + 1.34 + // setup variant array pointer 1.35 + if(paramCount > PARAM_BUFFER_COUNT) 1.36 + dispatchParams = new nsXPTCMiniVariant[paramCount]; 1.37 + else 1.38 + dispatchParams = paramBuffer; 1.39 + NS_ASSERTION(dispatchParams,"no place for params"); 1.40 + 1.41 + uint32_t* ap = args; 1.42 + for(i = 0; i < paramCount; i++, ap++) 1.43 + { 1.44 + const nsXPTParamInfo& param = info->GetParam(i); 1.45 + const nsXPTType& type = param.GetType(); 1.46 + nsXPTCMiniVariant* dp = &dispatchParams[i]; 1.47 + 1.48 + if(param.IsOut() || !type.IsArithmetic()) 1.49 + { 1.50 + dp->val.p = (void*) *ap; 1.51 + continue; 1.52 + } 1.53 + 1.54 + switch(type) 1.55 + { 1.56 + // the 8 and 16 bit types will have been promoted to 32 bits before 1.57 + // being pushed onto the stack. Since the 68k is big endian, we 1.58 + // need to skip over the leading high order bytes. 1.59 + case nsXPTType::T_I8 : dp->val.i8 = *(((int8_t*) ap) + 3); break; 1.60 + case nsXPTType::T_I16 : dp->val.i16 = *(((int16_t*) ap) + 1); break; 1.61 + case nsXPTType::T_I32 : dp->val.i32 = *((int32_t*) ap); break; 1.62 + case nsXPTType::T_I64 : dp->val.i64 = *((int64_t*) ap); ap++; break; 1.63 + case nsXPTType::T_U8 : dp->val.u8 = *(((uint8_t*) ap) + 3); break; 1.64 + case nsXPTType::T_U16 : dp->val.u16 = *(((uint16_t*)ap) + 1); break; 1.65 + case nsXPTType::T_U32 : dp->val.u32 = *((uint32_t*)ap); break; 1.66 + case nsXPTType::T_U64 : dp->val.u64 = *((uint64_t*)ap); ap++; break; 1.67 + case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break; 1.68 + case nsXPTType::T_DOUBLE : dp->val.d = *((double*) ap); ap++; break; 1.69 + case nsXPTType::T_BOOL : dp->val.b = *((uint32_t* ap); break; 1.70 + case nsXPTType::T_CHAR : dp->val.c = *(((char*) ap) + 3); break; 1.71 + case nsXPTType::T_WCHAR : dp->val.wc = *((wchar_t*) ap); break; 1.72 + default: 1.73 + NS_ERROR("bad type"); 1.74 + break; 1.75 + } 1.76 + } 1.77 + 1.78 + result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams); 1.79 + 1.80 + if(dispatchParams != paramBuffer) 1.81 + delete [] dispatchParams; 1.82 + 1.83 + return result; 1.84 + } 1.85 +} 1.86 + 1.87 +#define STUB_ENTRY(n) \ 1.88 +nsresult nsXPTCStubBase::Stub##n() \ 1.89 +{ \ 1.90 + void *frame = __builtin_frame_address(0); \ 1.91 + return PrepareAndDispatch(this, n, (uint32_t*)frame + 3); \ 1.92 +} 1.93 + 1.94 +#define SENTINEL_ENTRY(n) \ 1.95 +nsresult nsXPTCStubBase::Sentinel##n() \ 1.96 +{ \ 1.97 + NS_ERROR("nsXPTCStubBase::Sentinel called"); \ 1.98 + return NS_ERROR_NOT_IMPLEMENTED; \ 1.99 +} 1.100 + 1.101 +#include "xptcstubsdef.inc"