Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | /* Implement shared vtbl methods. */ |
michael@0 | 8 | |
michael@0 | 9 | #include "xptcprivate.h" |
michael@0 | 10 | #include "xptiprivate.h" |
michael@0 | 11 | |
michael@0 | 12 | #if defined(sparc) || defined(__sparc__) |
michael@0 | 13 | |
michael@0 | 14 | extern "C" nsresult ATTRIBUTE_USED |
michael@0 | 15 | PrepareAndDispatch(nsXPTCStubBase* self, uint64_t methodIndex, uint64_t* args) |
michael@0 | 16 | { |
michael@0 | 17 | |
michael@0 | 18 | #define PARAM_BUFFER_COUNT 16 |
michael@0 | 19 | |
michael@0 | 20 | nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; |
michael@0 | 21 | nsXPTCMiniVariant* dispatchParams = nullptr; |
michael@0 | 22 | const nsXPTMethodInfo* info; |
michael@0 | 23 | uint8_t paramCount; |
michael@0 | 24 | uint8_t i; |
michael@0 | 25 | nsresult result = NS_ERROR_FAILURE; |
michael@0 | 26 | |
michael@0 | 27 | NS_ASSERTION(self,"no self"); |
michael@0 | 28 | |
michael@0 | 29 | self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info); |
michael@0 | 30 | NS_ASSERTION(info,"no interface info"); |
michael@0 | 31 | |
michael@0 | 32 | paramCount = info->GetParamCount(); |
michael@0 | 33 | |
michael@0 | 34 | // setup variant array pointer |
michael@0 | 35 | if(paramCount > PARAM_BUFFER_COUNT) |
michael@0 | 36 | dispatchParams = new nsXPTCMiniVariant[paramCount]; |
michael@0 | 37 | else |
michael@0 | 38 | dispatchParams = paramBuffer; |
michael@0 | 39 | |
michael@0 | 40 | NS_ASSERTION(dispatchParams,"no place for params"); |
michael@0 | 41 | if (!dispatchParams) |
michael@0 | 42 | return NS_ERROR_OUT_OF_MEMORY; |
michael@0 | 43 | |
michael@0 | 44 | uint64_t* ap = args; |
michael@0 | 45 | for(i = 0; i < paramCount; i++, ap++) |
michael@0 | 46 | { |
michael@0 | 47 | const nsXPTParamInfo& param = info->GetParam(i); |
michael@0 | 48 | const nsXPTType& type = param.GetType(); |
michael@0 | 49 | nsXPTCMiniVariant* dp = &dispatchParams[i]; |
michael@0 | 50 | |
michael@0 | 51 | if(param.IsOut() || !type.IsArithmetic()) |
michael@0 | 52 | { |
michael@0 | 53 | dp->val.p = (void*) *ap; |
michael@0 | 54 | continue; |
michael@0 | 55 | } |
michael@0 | 56 | // else |
michael@0 | 57 | switch(type) |
michael@0 | 58 | { |
michael@0 | 59 | case nsXPTType::T_BOOL : dp->val.b = *((int64_t*) ap); break; |
michael@0 | 60 | case nsXPTType::T_CHAR : dp->val.c = *((uint64_t*) ap); break; |
michael@0 | 61 | case nsXPTType::T_WCHAR : dp->val.wc = *((int64_t*) ap); break; |
michael@0 | 62 | case nsXPTType::T_I8 : dp->val.i8 = *((int64_t*) ap); break; |
michael@0 | 63 | case nsXPTType::T_I16 : dp->val.i16 = *((int64_t*) ap); break; |
michael@0 | 64 | case nsXPTType::T_I32 : dp->val.i32 = *((int64_t*) ap); break; |
michael@0 | 65 | case nsXPTType::T_I64 : dp->val.i64 = *((int64_t*) ap); break; |
michael@0 | 66 | case nsXPTType::T_U8 : dp->val.u8 = *((uint64_t*) ap); break; |
michael@0 | 67 | case nsXPTType::T_U16 : dp->val.u16 = *((uint64_t*)ap); break; |
michael@0 | 68 | case nsXPTType::T_U32 : dp->val.u32 = *((uint64_t*)ap); break; |
michael@0 | 69 | case nsXPTType::T_U64 : dp->val.u64 = *((uint64_t*) ap); break; |
michael@0 | 70 | case nsXPTType::T_FLOAT : dp->val.f = ((float*) ap)[1]; break; |
michael@0 | 71 | case nsXPTType::T_DOUBLE : dp->val.d = *((double*) ap); break; |
michael@0 | 72 | default: |
michael@0 | 73 | NS_ERROR("bad type"); |
michael@0 | 74 | break; |
michael@0 | 75 | } |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams); |
michael@0 | 79 | |
michael@0 | 80 | if(dispatchParams != paramBuffer) |
michael@0 | 81 | delete [] dispatchParams; |
michael@0 | 82 | |
michael@0 | 83 | return result; |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | extern "C" nsresult SharedStub(int, int*); |
michael@0 | 87 | |
michael@0 | 88 | #define STUB_ENTRY(n) \ |
michael@0 | 89 | nsresult nsXPTCStubBase::Stub##n() \ |
michael@0 | 90 | { \ |
michael@0 | 91 | int dummy; /* defeat tail-call optimization */ \ |
michael@0 | 92 | return SharedStub(n, &dummy); \ |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | #define SENTINEL_ENTRY(n) \ |
michael@0 | 96 | nsresult nsXPTCStubBase::Sentinel##n() \ |
michael@0 | 97 | { \ |
michael@0 | 98 | NS_ERROR("nsXPTCStubBase::Sentinel called"); \ |
michael@0 | 99 | return NS_ERROR_NOT_IMPLEMENTED; \ |
michael@0 | 100 | } |
michael@0 | 101 | |
michael@0 | 102 | #include "xptcstubsdef.inc" |
michael@0 | 103 | |
michael@0 | 104 | #endif /* sparc || __sparc__ */ |