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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | /* Implement shared vtbl methods. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "xptcprivate.h" |
michael@0 | 8 | #include "xptiprivate.h" |
michael@0 | 9 | |
michael@0 | 10 | #if defined(AIX) |
michael@0 | 11 | |
michael@0 | 12 | /* |
michael@0 | 13 | For PPC (AIX & MAC), the first 8 integral and the first 13 f.p. parameters |
michael@0 | 14 | arrive in a separate chunk of data that has been loaded from the registers. |
michael@0 | 15 | The args pointer has been set to the start of the parameters BEYOND the ones |
michael@0 | 16 | arriving in registers |
michael@0 | 17 | */ |
michael@0 | 18 | extern "C" nsresult ATTRIBUTE_USED |
michael@0 | 19 | PrepareAndDispatch(nsXPTCStubBase* self, uint64_t methodIndex, uint64_t* args, uint64_t *gprData, double *fprData) |
michael@0 | 20 | { |
michael@0 | 21 | |
michael@0 | 22 | #define PARAM_BUFFER_COUNT 16 |
michael@0 | 23 | #define PARAM_GPR_COUNT 7 |
michael@0 | 24 | |
michael@0 | 25 | nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; |
michael@0 | 26 | nsXPTCMiniVariant* dispatchParams = nullptr; |
michael@0 | 27 | const nsXPTMethodInfo* info = nullptr; |
michael@0 | 28 | uint8_t paramCount; |
michael@0 | 29 | uint8_t i; |
michael@0 | 30 | nsresult result = NS_ERROR_FAILURE; |
michael@0 | 31 | |
michael@0 | 32 | NS_ASSERTION(self,"no self"); |
michael@0 | 33 | |
michael@0 | 34 | self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info); |
michael@0 | 35 | NS_ASSERTION(info,"no method info"); |
michael@0 | 36 | |
michael@0 | 37 | paramCount = info->GetParamCount(); |
michael@0 | 38 | |
michael@0 | 39 | // setup variant array pointer |
michael@0 | 40 | if(paramCount > PARAM_BUFFER_COUNT) |
michael@0 | 41 | dispatchParams = new nsXPTCMiniVariant[paramCount]; |
michael@0 | 42 | else |
michael@0 | 43 | dispatchParams = paramBuffer; |
michael@0 | 44 | NS_ASSERTION(dispatchParams,"no place for params"); |
michael@0 | 45 | |
michael@0 | 46 | uint64_t* ap = args; |
michael@0 | 47 | uint32_t iCount = 0; |
michael@0 | 48 | uint32_t fpCount = 0; |
michael@0 | 49 | for(i = 0; i < paramCount; i++) |
michael@0 | 50 | { |
michael@0 | 51 | const nsXPTParamInfo& param = info->GetParam(i); |
michael@0 | 52 | const nsXPTType& type = param.GetType(); |
michael@0 | 53 | nsXPTCMiniVariant* dp = &dispatchParams[i]; |
michael@0 | 54 | |
michael@0 | 55 | if(param.IsOut() || !type.IsArithmetic()) |
michael@0 | 56 | { |
michael@0 | 57 | if (iCount < PARAM_GPR_COUNT) |
michael@0 | 58 | dp->val.p = (void*) gprData[iCount++]; |
michael@0 | 59 | else |
michael@0 | 60 | dp->val.p = (void*) *ap++; |
michael@0 | 61 | continue; |
michael@0 | 62 | } |
michael@0 | 63 | // else |
michael@0 | 64 | switch(type) |
michael@0 | 65 | { |
michael@0 | 66 | case nsXPTType::T_I8 : if (iCount < PARAM_GPR_COUNT) |
michael@0 | 67 | dp->val.i8 = (int8_t) gprData[iCount++]; |
michael@0 | 68 | else |
michael@0 | 69 | dp->val.i8 = (int8_t) *ap++; |
michael@0 | 70 | break; |
michael@0 | 71 | case nsXPTType::T_I16 : if (iCount < PARAM_GPR_COUNT) |
michael@0 | 72 | dp->val.i16 = (int16_t) gprData[iCount++]; |
michael@0 | 73 | else |
michael@0 | 74 | dp->val.i16 = (int16_t) *ap++; |
michael@0 | 75 | break; |
michael@0 | 76 | case nsXPTType::T_I32 : if (iCount < PARAM_GPR_COUNT) |
michael@0 | 77 | dp->val.i32 = (int32_t) gprData[iCount++]; |
michael@0 | 78 | else |
michael@0 | 79 | dp->val.i32 = (int32_t) *ap++; |
michael@0 | 80 | break; |
michael@0 | 81 | case nsXPTType::T_I64 : if (iCount < PARAM_GPR_COUNT) |
michael@0 | 82 | dp->val.i64 = (int64_t) gprData[iCount++]; |
michael@0 | 83 | else |
michael@0 | 84 | dp->val.i64 = (int64_t) *ap++; |
michael@0 | 85 | break; |
michael@0 | 86 | case nsXPTType::T_U8 : if (iCount < PARAM_GPR_COUNT) |
michael@0 | 87 | dp->val.u8 = (uint8_t) gprData[iCount++]; |
michael@0 | 88 | else |
michael@0 | 89 | dp->val.u8 = (uint8_t) *ap++; |
michael@0 | 90 | break; |
michael@0 | 91 | case nsXPTType::T_U16 : if (iCount < PARAM_GPR_COUNT) |
michael@0 | 92 | dp->val.u16 = (uint16_t) gprData[iCount++]; |
michael@0 | 93 | else |
michael@0 | 94 | dp->val.u16 = (uint16_t) *ap++; |
michael@0 | 95 | break; |
michael@0 | 96 | case nsXPTType::T_U32 : if (iCount < PARAM_GPR_COUNT) |
michael@0 | 97 | dp->val.u32 = (uint32_t) gprData[iCount++]; |
michael@0 | 98 | else |
michael@0 | 99 | dp->val.u32 = (uint32_t) *ap++; |
michael@0 | 100 | break; |
michael@0 | 101 | case nsXPTType::T_U64 : if (iCount < PARAM_GPR_COUNT) |
michael@0 | 102 | dp->val.u64 = (uint64_t) gprData[iCount++]; |
michael@0 | 103 | else |
michael@0 | 104 | dp->val.u64 = (uint64_t) *ap++; |
michael@0 | 105 | break; |
michael@0 | 106 | case nsXPTType::T_FLOAT : if (fpCount < 13) { |
michael@0 | 107 | dp->val.f = (float) fprData[fpCount++]; |
michael@0 | 108 | if (iCount < PARAM_GPR_COUNT) |
michael@0 | 109 | ++iCount; |
michael@0 | 110 | else |
michael@0 | 111 | ++ap; |
michael@0 | 112 | } |
michael@0 | 113 | else |
michael@0 | 114 | dp->val.f = *((float*) ap++); |
michael@0 | 115 | break; |
michael@0 | 116 | case nsXPTType::T_DOUBLE : if (fpCount < 13) { |
michael@0 | 117 | dp->val.d = (double) fprData[fpCount++]; |
michael@0 | 118 | if (iCount < PARAM_GPR_COUNT) |
michael@0 | 119 | ++iCount; |
michael@0 | 120 | else |
michael@0 | 121 | ++ap; |
michael@0 | 122 | if (iCount < PARAM_GPR_COUNT) |
michael@0 | 123 | ++iCount; |
michael@0 | 124 | else |
michael@0 | 125 | ++ap; |
michael@0 | 126 | } |
michael@0 | 127 | else { |
michael@0 | 128 | dp->val.f = *((double*) ap); |
michael@0 | 129 | ap += 2; |
michael@0 | 130 | } |
michael@0 | 131 | break; |
michael@0 | 132 | case nsXPTType::T_BOOL : if (iCount < PARAM_GPR_COUNT) |
michael@0 | 133 | dp->val.b = (bool) gprData[iCount++]; |
michael@0 | 134 | else |
michael@0 | 135 | dp->val.b = (bool) *ap++; |
michael@0 | 136 | break; |
michael@0 | 137 | case nsXPTType::T_CHAR : if (iCount < PARAM_GPR_COUNT) |
michael@0 | 138 | dp->val.c = (char) gprData[iCount++]; |
michael@0 | 139 | else |
michael@0 | 140 | dp->val.c = (char) *ap++; |
michael@0 | 141 | break; |
michael@0 | 142 | case nsXPTType::T_WCHAR : if (iCount < PARAM_GPR_COUNT) |
michael@0 | 143 | dp->val.wc = (wchar_t) gprData[iCount++]; |
michael@0 | 144 | else |
michael@0 | 145 | dp->val.wc = (wchar_t) *ap++; |
michael@0 | 146 | break; |
michael@0 | 147 | default: |
michael@0 | 148 | NS_ERROR("bad type"); |
michael@0 | 149 | break; |
michael@0 | 150 | } |
michael@0 | 151 | } |
michael@0 | 152 | |
michael@0 | 153 | result = self->mOuter->CallMethod((uint16_t)methodIndex,info,dispatchParams); |
michael@0 | 154 | |
michael@0 | 155 | if(dispatchParams != paramBuffer) |
michael@0 | 156 | delete [] dispatchParams; |
michael@0 | 157 | |
michael@0 | 158 | return result; |
michael@0 | 159 | } |
michael@0 | 160 | |
michael@0 | 161 | #define STUB_ENTRY(n) |
michael@0 | 162 | |
michael@0 | 163 | #define SENTINEL_ENTRY(n) \ |
michael@0 | 164 | nsresult nsXPTCStubBase::Sentinel##n() \ |
michael@0 | 165 | { \ |
michael@0 | 166 | NS_ERROR("nsXPTCStubBase::Sentinel called"); \ |
michael@0 | 167 | return NS_ERROR_NOT_IMPLEMENTED; \ |
michael@0 | 168 | } |
michael@0 | 169 | |
michael@0 | 170 | #include "xptcstubsdef.inc" |
michael@0 | 171 | |
michael@0 | 172 | #endif /* AIX */ |