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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_pa32.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,143 @@
     1.4 +
     1.5 +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.6 + *
     1.7 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.10 +
    1.11 +/* Implement shared vtbl methods. */
    1.12 +
    1.13 +#include "xptcprivate.h"
    1.14 +#include "xptiprivate.h" 
    1.15 +
    1.16 +#if _HPUX
    1.17 +#error "This code is for HP-PA RISC 32 bit mode only"
    1.18 +#endif
    1.19 +
    1.20 +extern "C" nsresult ATTRIBUTE_USED
    1.21 +PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex,
    1.22 +  uint32_t* args, uint32_t* floatargs)
    1.23 +{
    1.24 +
    1.25 +  typedef struct {
    1.26 +    uint32_t hi;
    1.27 +    uint32_t lo;
    1.28 +  } DU;
    1.29 +
    1.30 +#define PARAM_BUFFER_COUNT     16
    1.31 +
    1.32 +  nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
    1.33 +  nsXPTCMiniVariant* dispatchParams = nullptr;
    1.34 +  const nsXPTMethodInfo* info;
    1.35 +  int32_t regwords = 1; /* self pointer is not in the variant records */
    1.36 +  nsresult result = NS_ERROR_FAILURE;
    1.37 +  uint8_t paramCount;
    1.38 +  uint8_t i;
    1.39 +
    1.40 +  NS_ASSERTION(self,"no self");
    1.41 +
    1.42 +  self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info);
    1.43 +  NS_ASSERTION(info,"no method info");
    1.44 +  if (!info)
    1.45 +    return NS_ERROR_UNEXPECTED;
    1.46 +
    1.47 +  paramCount = info->GetParamCount();
    1.48 +
    1.49 +  // setup variant array pointer
    1.50 +  if(paramCount > PARAM_BUFFER_COUNT)
    1.51 +    dispatchParams = new nsXPTCMiniVariant[paramCount];
    1.52 +  else
    1.53 +    dispatchParams = paramBuffer;
    1.54 +  NS_ASSERTION(dispatchParams,"no place for params");
    1.55 +  if (!dispatchParams)
    1.56 +    return NS_ERROR_OUT_OF_MEMORY;
    1.57 +
    1.58 +  for(i = 0; i < paramCount; ++i, --args)
    1.59 +  {
    1.60 +    const nsXPTParamInfo& param = info->GetParam(i);
    1.61 +    const nsXPTType& type = param.GetType();
    1.62 +    nsXPTCMiniVariant* dp = &dispatchParams[i];
    1.63 +
    1.64 +    if(param.IsOut() || !type.IsArithmetic())
    1.65 +    {
    1.66 +      dp->val.p = (void*) *args;
    1.67 +      ++regwords;
    1.68 +      continue;
    1.69 +    }
    1.70 +    switch(type)
    1.71 +    {
    1.72 +    case nsXPTType::T_I8     : dp->val.i8  = *((int32_t*) args); break;
    1.73 +    case nsXPTType::T_I16    : dp->val.i16 = *((int32_t*) args); break;
    1.74 +    case nsXPTType::T_I32    : dp->val.i32 = *((int32_t*) args); break;
    1.75 +    case nsXPTType::T_DOUBLE :
    1.76 +                               if (regwords & 1)
    1.77 +                               {
    1.78 +                                 ++regwords; /* align on double word */
    1.79 +                                 --args;
    1.80 +                               }
    1.81 +                               if (regwords == 0 || regwords == 2)
    1.82 +                               {
    1.83 +                                 dp->val.d=*((double*) (floatargs + regwords));
    1.84 +                                 --args;
    1.85 +                               }
    1.86 +                               else
    1.87 +                               {
    1.88 +                                 dp->val.d = *((double*) --args);
    1.89 +                               }
    1.90 +                               regwords += 2;
    1.91 +                               continue;
    1.92 +    case nsXPTType::T_U64    :
    1.93 +    case nsXPTType::T_I64    :
    1.94 +                               if (regwords & 1)
    1.95 +                               {
    1.96 +                                 ++regwords; /* align on double word */
    1.97 +                                 --args;
    1.98 +                               }
    1.99 +                               ((DU *)dp)->lo = *((uint32_t*) args);
   1.100 +                               ((DU *)dp)->hi = *((uint32_t*) --args);
   1.101 +                               regwords += 2;
   1.102 +                               continue;
   1.103 +    case nsXPTType::T_FLOAT  :
   1.104 +                               if (regwords >= 4)
   1.105 +                                 dp->val.f = *((float*) args);
   1.106 +                               else
   1.107 +                                 dp->val.f = *((float*) floatargs+4+regwords);
   1.108 +                               break;
   1.109 +    case nsXPTType::T_U8     : dp->val.u8  = *((uint32_t*) args); break;
   1.110 +    case nsXPTType::T_U16    : dp->val.u16 = *((uint32_t*) args); break;
   1.111 +    case nsXPTType::T_U32    : dp->val.u32 = *((uint32_t*) args); break;
   1.112 +    case nsXPTType::T_BOOL   : dp->val.b   = *((uint32_t*) args); break;
   1.113 +    case nsXPTType::T_CHAR   : dp->val.c   = *((uint32_t*) args); break;
   1.114 +    case nsXPTType::T_WCHAR  : dp->val.wc  = *((int32_t*)  args); break;
   1.115 +    default:
   1.116 +      NS_ERROR("bad type");
   1.117 +      break;
   1.118 +    }
   1.119 +    ++regwords;
   1.120 +  }
   1.121 +
   1.122 +  result = self->mOuter->CallMethod((uint16_t) methodIndex, info, dispatchParams); 
   1.123 +
   1.124 +  if(dispatchParams != paramBuffer)
   1.125 +    delete [] dispatchParams;
   1.126 +
   1.127 +  return result;
   1.128 +}
   1.129 +
   1.130 +extern "C" nsresult SharedStub(int);
   1.131 +
   1.132 +#define STUB_ENTRY(n)       \
   1.133 +nsresult nsXPTCStubBase::Stub##n()  \
   1.134 +{                           \
   1.135 +    return SharedStub(n);   \
   1.136 +}
   1.137 +
   1.138 +#define SENTINEL_ENTRY(n) \
   1.139 +nsresult nsXPTCStubBase::Sentinel##n() \
   1.140 +{ \
   1.141 +    NS_ERROR("nsXPTCStubBase::Sentinel called"); \
   1.142 +    return NS_ERROR_NOT_IMPLEMENTED; \
   1.143 +}
   1.144 +
   1.145 +#include "xptcstubsdef.inc"
   1.146 +

mercurial