michael@0: /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* Implement shared vtbl methods. */ michael@0: michael@0: #include "xptcprivate.h" michael@0: #include "xptiprivate.h" michael@0: michael@0: #if defined(AIX) michael@0: michael@0: /* michael@0: For PPC (AIX & MAC), the first 8 integral and the first 13 f.p. parameters michael@0: arrive in a separate chunk of data that has been loaded from the registers. michael@0: The args pointer has been set to the start of the parameters BEYOND the ones michael@0: arriving in registers michael@0: */ michael@0: extern "C" nsresult ATTRIBUTE_USED michael@0: PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args, uint32_t *gprData, double *fprData) michael@0: { michael@0: typedef struct { michael@0: uint32_t hi; michael@0: uint32_t lo; // have to move 64 bit entities as 32 bit halves since michael@0: } DU; // stack slots are not guaranteed 16 byte aligned michael@0: michael@0: #define PARAM_BUFFER_COUNT 16 michael@0: #define PARAM_GPR_COUNT 7 michael@0: michael@0: nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; michael@0: nsXPTCMiniVariant* dispatchParams = nullptr; michael@0: const nsXPTMethodInfo* info = nullptr; michael@0: uint8_t paramCount; michael@0: uint8_t i; michael@0: nsresult result = NS_ERROR_FAILURE; michael@0: michael@0: NS_ASSERTION(self,"no self"); michael@0: michael@0: self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info); michael@0: NS_ASSERTION(info,"no method info"); michael@0: michael@0: paramCount = info->GetParamCount(); michael@0: michael@0: // setup variant array pointer michael@0: if(paramCount > PARAM_BUFFER_COUNT) michael@0: dispatchParams = new nsXPTCMiniVariant[paramCount]; michael@0: else michael@0: dispatchParams = paramBuffer; michael@0: NS_ASSERTION(dispatchParams,"no place for params"); michael@0: michael@0: uint32_t* ap = args; michael@0: uint32_t iCount = 0; michael@0: uint32_t fpCount = 0; michael@0: for(i = 0; i < paramCount; i++) michael@0: { michael@0: const nsXPTParamInfo& param = info->GetParam(i); michael@0: const nsXPTType& type = param.GetType(); michael@0: nsXPTCMiniVariant* dp = &dispatchParams[i]; michael@0: michael@0: if(param.IsOut() || !type.IsArithmetic()) michael@0: { michael@0: if (iCount < PARAM_GPR_COUNT) michael@0: dp->val.p = (void*) gprData[iCount++]; michael@0: else michael@0: dp->val.p = (void*) *ap++; michael@0: continue; michael@0: } michael@0: // else michael@0: switch(type) michael@0: { michael@0: case nsXPTType::T_I8 : if (iCount < PARAM_GPR_COUNT) michael@0: dp->val.i8 = (int8_t) gprData[iCount++]; michael@0: else michael@0: dp->val.i8 = (int8_t) *ap++; michael@0: break; michael@0: case nsXPTType::T_I16 : if (iCount < PARAM_GPR_COUNT) michael@0: dp->val.i16 = (int16_t) gprData[iCount++]; michael@0: else michael@0: dp->val.i16 = (int16_t) *ap++; michael@0: break; michael@0: case nsXPTType::T_I32 : if (iCount < PARAM_GPR_COUNT) michael@0: dp->val.i32 = (int32_t) gprData[iCount++]; michael@0: else michael@0: dp->val.i32 = (int32_t) *ap++; michael@0: break; michael@0: case nsXPTType::T_I64 : if (iCount < PARAM_GPR_COUNT) michael@0: ((DU *)dp)->hi = (int32_t) gprData[iCount++]; michael@0: else michael@0: ((DU *)dp)->hi = (int32_t) *ap++; michael@0: if (iCount < PARAM_GPR_COUNT) michael@0: ((DU *)dp)->lo = (uint32_t) gprData[iCount++]; michael@0: else michael@0: ((DU *)dp)->lo = (uint32_t) *ap++; michael@0: break; michael@0: case nsXPTType::T_U8 : if (iCount < PARAM_GPR_COUNT) michael@0: dp->val.u8 = (uint8_t) gprData[iCount++]; michael@0: else michael@0: dp->val.u8 = (uint8_t) *ap++; michael@0: break; michael@0: case nsXPTType::T_U16 : if (iCount < PARAM_GPR_COUNT) michael@0: dp->val.u16 = (uint16_t) gprData[iCount++]; michael@0: else michael@0: dp->val.u16 = (uint16_t) *ap++; michael@0: break; michael@0: case nsXPTType::T_U32 : if (iCount < PARAM_GPR_COUNT) michael@0: dp->val.u32 = (uint32_t) gprData[iCount++]; michael@0: else michael@0: dp->val.u32 = (uint32_t) *ap++; michael@0: break; michael@0: case nsXPTType::T_U64 : if (iCount < PARAM_GPR_COUNT) michael@0: ((DU *)dp)->hi = (uint32_t) gprData[iCount++]; michael@0: else michael@0: ((DU *)dp)->hi = (uint32_t) *ap++; michael@0: if (iCount < PARAM_GPR_COUNT) michael@0: ((DU *)dp)->lo = (uint32_t) gprData[iCount++]; michael@0: else michael@0: ((DU *)dp)->lo = (uint32_t) *ap++; michael@0: break; michael@0: case nsXPTType::T_FLOAT : if (fpCount < 13) { michael@0: dp->val.f = (float) fprData[fpCount++]; michael@0: if (iCount < PARAM_GPR_COUNT) michael@0: ++iCount; michael@0: else michael@0: ++ap; michael@0: } michael@0: else michael@0: dp->val.f = *((float*) ap++); michael@0: break; michael@0: case nsXPTType::T_DOUBLE : if (fpCount < 13) { michael@0: dp->val.d = (double) fprData[fpCount++]; michael@0: if (iCount < PARAM_GPR_COUNT) michael@0: ++iCount; michael@0: else michael@0: ++ap; michael@0: if (iCount < PARAM_GPR_COUNT) michael@0: ++iCount; michael@0: else michael@0: ++ap; michael@0: } michael@0: else { michael@0: dp->val.f = *((double*) ap); michael@0: ap += 2; michael@0: } michael@0: break; michael@0: case nsXPTType::T_BOOL : if (iCount < PARAM_GPR_COUNT) michael@0: dp->val.b = (bool) gprData[iCount++]; michael@0: else michael@0: dp->val.b = (bool) *ap++; michael@0: break; michael@0: case nsXPTType::T_CHAR : if (iCount < PARAM_GPR_COUNT) michael@0: dp->val.c = (char) gprData[iCount++]; michael@0: else michael@0: dp->val.c = (char) *ap++; michael@0: break; michael@0: case nsXPTType::T_WCHAR : if (iCount < PARAM_GPR_COUNT) michael@0: dp->val.wc = (wchar_t) gprData[iCount++]; michael@0: else michael@0: dp->val.wc = (wchar_t) *ap++; michael@0: break; michael@0: default: michael@0: NS_ERROR("bad type"); michael@0: break; michael@0: } michael@0: } michael@0: michael@0: result = self->mOuter->CallMethod((uint16_t)methodIndex,info,dispatchParams); michael@0: michael@0: if(dispatchParams != paramBuffer) michael@0: delete [] dispatchParams; michael@0: michael@0: return result; michael@0: } michael@0: michael@0: #define STUB_ENTRY(n) michael@0: michael@0: #define SENTINEL_ENTRY(n) \ michael@0: nsresult nsXPTCStubBase::Sentinel##n() \ michael@0: { \ michael@0: NS_ERROR("nsXPTCStubBase::Sentinel called"); \ michael@0: return NS_ERROR_NOT_IMPLEMENTED; \ michael@0: } michael@0: michael@0: #include "xptcstubsdef.inc" michael@0: michael@0: #endif /* AIX */