xpcom/reflect/xptcall/src/md/unix/xptcstubs_pa32.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1
michael@0 2 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 3 *
michael@0 4 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 5 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 7
michael@0 8 /* Implement shared vtbl methods. */
michael@0 9
michael@0 10 #include "xptcprivate.h"
michael@0 11 #include "xptiprivate.h"
michael@0 12
michael@0 13 #if _HPUX
michael@0 14 #error "This code is for HP-PA RISC 32 bit mode only"
michael@0 15 #endif
michael@0 16
michael@0 17 extern "C" nsresult ATTRIBUTE_USED
michael@0 18 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex,
michael@0 19 uint32_t* args, uint32_t* floatargs)
michael@0 20 {
michael@0 21
michael@0 22 typedef struct {
michael@0 23 uint32_t hi;
michael@0 24 uint32_t lo;
michael@0 25 } DU;
michael@0 26
michael@0 27 #define PARAM_BUFFER_COUNT 16
michael@0 28
michael@0 29 nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
michael@0 30 nsXPTCMiniVariant* dispatchParams = nullptr;
michael@0 31 const nsXPTMethodInfo* info;
michael@0 32 int32_t regwords = 1; /* self pointer is not in the variant records */
michael@0 33 nsresult result = NS_ERROR_FAILURE;
michael@0 34 uint8_t paramCount;
michael@0 35 uint8_t i;
michael@0 36
michael@0 37 NS_ASSERTION(self,"no self");
michael@0 38
michael@0 39 self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info);
michael@0 40 NS_ASSERTION(info,"no method info");
michael@0 41 if (!info)
michael@0 42 return NS_ERROR_UNEXPECTED;
michael@0 43
michael@0 44 paramCount = info->GetParamCount();
michael@0 45
michael@0 46 // setup variant array pointer
michael@0 47 if(paramCount > PARAM_BUFFER_COUNT)
michael@0 48 dispatchParams = new nsXPTCMiniVariant[paramCount];
michael@0 49 else
michael@0 50 dispatchParams = paramBuffer;
michael@0 51 NS_ASSERTION(dispatchParams,"no place for params");
michael@0 52 if (!dispatchParams)
michael@0 53 return NS_ERROR_OUT_OF_MEMORY;
michael@0 54
michael@0 55 for(i = 0; i < paramCount; ++i, --args)
michael@0 56 {
michael@0 57 const nsXPTParamInfo& param = info->GetParam(i);
michael@0 58 const nsXPTType& type = param.GetType();
michael@0 59 nsXPTCMiniVariant* dp = &dispatchParams[i];
michael@0 60
michael@0 61 if(param.IsOut() || !type.IsArithmetic())
michael@0 62 {
michael@0 63 dp->val.p = (void*) *args;
michael@0 64 ++regwords;
michael@0 65 continue;
michael@0 66 }
michael@0 67 switch(type)
michael@0 68 {
michael@0 69 case nsXPTType::T_I8 : dp->val.i8 = *((int32_t*) args); break;
michael@0 70 case nsXPTType::T_I16 : dp->val.i16 = *((int32_t*) args); break;
michael@0 71 case nsXPTType::T_I32 : dp->val.i32 = *((int32_t*) args); break;
michael@0 72 case nsXPTType::T_DOUBLE :
michael@0 73 if (regwords & 1)
michael@0 74 {
michael@0 75 ++regwords; /* align on double word */
michael@0 76 --args;
michael@0 77 }
michael@0 78 if (regwords == 0 || regwords == 2)
michael@0 79 {
michael@0 80 dp->val.d=*((double*) (floatargs + regwords));
michael@0 81 --args;
michael@0 82 }
michael@0 83 else
michael@0 84 {
michael@0 85 dp->val.d = *((double*) --args);
michael@0 86 }
michael@0 87 regwords += 2;
michael@0 88 continue;
michael@0 89 case nsXPTType::T_U64 :
michael@0 90 case nsXPTType::T_I64 :
michael@0 91 if (regwords & 1)
michael@0 92 {
michael@0 93 ++regwords; /* align on double word */
michael@0 94 --args;
michael@0 95 }
michael@0 96 ((DU *)dp)->lo = *((uint32_t*) args);
michael@0 97 ((DU *)dp)->hi = *((uint32_t*) --args);
michael@0 98 regwords += 2;
michael@0 99 continue;
michael@0 100 case nsXPTType::T_FLOAT :
michael@0 101 if (regwords >= 4)
michael@0 102 dp->val.f = *((float*) args);
michael@0 103 else
michael@0 104 dp->val.f = *((float*) floatargs+4+regwords);
michael@0 105 break;
michael@0 106 case nsXPTType::T_U8 : dp->val.u8 = *((uint32_t*) args); break;
michael@0 107 case nsXPTType::T_U16 : dp->val.u16 = *((uint32_t*) args); break;
michael@0 108 case nsXPTType::T_U32 : dp->val.u32 = *((uint32_t*) args); break;
michael@0 109 case nsXPTType::T_BOOL : dp->val.b = *((uint32_t*) args); break;
michael@0 110 case nsXPTType::T_CHAR : dp->val.c = *((uint32_t*) args); break;
michael@0 111 case nsXPTType::T_WCHAR : dp->val.wc = *((int32_t*) args); break;
michael@0 112 default:
michael@0 113 NS_ERROR("bad type");
michael@0 114 break;
michael@0 115 }
michael@0 116 ++regwords;
michael@0 117 }
michael@0 118
michael@0 119 result = self->mOuter->CallMethod((uint16_t) methodIndex, info, dispatchParams);
michael@0 120
michael@0 121 if(dispatchParams != paramBuffer)
michael@0 122 delete [] dispatchParams;
michael@0 123
michael@0 124 return result;
michael@0 125 }
michael@0 126
michael@0 127 extern "C" nsresult SharedStub(int);
michael@0 128
michael@0 129 #define STUB_ENTRY(n) \
michael@0 130 nsresult nsXPTCStubBase::Stub##n() \
michael@0 131 { \
michael@0 132 return SharedStub(n); \
michael@0 133 }
michael@0 134
michael@0 135 #define SENTINEL_ENTRY(n) \
michael@0 136 nsresult nsXPTCStubBase::Sentinel##n() \
michael@0 137 { \
michael@0 138 NS_ERROR("nsXPTCStubBase::Sentinel called"); \
michael@0 139 return NS_ERROR_NOT_IMPLEMENTED; \
michael@0 140 }
michael@0 141
michael@0 142 #include "xptcstubsdef.inc"
michael@0 143

mercurial