xpcom/reflect/xptcall/src/md/unix/xptcstubs_mips.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_mips.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,112 @@
     1.4 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * Version: MPL 1.1
     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 +#include "xptcprivate.h"
    1.12 +#include "xptiprivate.h"
    1.13 +
    1.14 +#include <stdint.h>
    1.15 +
    1.16 +/*
    1.17 + * This is for MIPS O32 ABI
    1.18 + * Args contains a0-3 and then the stack.
    1.19 + * Because a0 is 'this', we want to skip it
    1.20 + */
    1.21 +extern "C" nsresult ATTRIBUTE_USED
    1.22 +PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
    1.23 +{
    1.24 +    args++; // always skip over a0
    1.25 +
    1.26 +#define PARAM_BUFFER_COUNT		16
    1.27 +
    1.28 +    nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
    1.29 +    nsXPTCMiniVariant* dispatchParams = nullptr;
    1.30 +    const nsXPTMethodInfo* info;
    1.31 +    uint8_t paramCount;
    1.32 +    uint8_t i;
    1.33 +    nsresult result = NS_ERROR_FAILURE;
    1.34 +
    1.35 +    NS_ASSERTION(self,"no self");
    1.36 +
    1.37 +    self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info);
    1.38 +    NS_ASSERTION(info,"no method info");
    1.39 +
    1.40 +    paramCount = info->GetParamCount();
    1.41 +
    1.42 +    // setup variant array pointer
    1.43 +    if(paramCount > PARAM_BUFFER_COUNT)
    1.44 +        dispatchParams = new nsXPTCMiniVariant[paramCount];
    1.45 +    else
    1.46 +        dispatchParams = paramBuffer;
    1.47 +    NS_ASSERTION(dispatchParams,"no place for params");
    1.48 +
    1.49 +    uint32_t* ap = args;
    1.50 +    for(i = 0; i < paramCount; i++, ap++)
    1.51 +    {
    1.52 +        const nsXPTParamInfo& param = info->GetParam(i);
    1.53 +        const nsXPTType& type = param.GetType();
    1.54 +        nsXPTCMiniVariant* dp = &dispatchParams[i];
    1.55 +
    1.56 +        if(param.IsOut() || !type.IsArithmetic())
    1.57 +        {
    1.58 +            dp->val.p = (void*) *ap;
    1.59 +            continue;
    1.60 +        }
    1.61 +
    1.62 +        switch(type)
    1.63 +        {
    1.64 +        case nsXPTType::T_I64   :
    1.65 +            if ((intptr_t)ap & 4) ap++;
    1.66 +            dp->val.i64 = *((int64_t*) ap); ap++;
    1.67 +            break;
    1.68 +        case nsXPTType::T_U64   :
    1.69 +            if ((intptr_t)ap & 4) ap++;
    1.70 +            dp->val.u64 = *((int64_t*) ap); ap++;
    1.71 +            break;
    1.72 +        case nsXPTType::T_DOUBLE:
    1.73 +            if ((intptr_t)ap & 4) ap++;
    1.74 +            dp->val.d   = *((double*) ap);  ap++;
    1.75 +            break;
    1.76 +#ifdef IS_LITTLE_ENDIAN
    1.77 +        default:
    1.78 +            dp->val.p = (void*) *ap;
    1.79 +            break;
    1.80 +#else
    1.81 +        case nsXPTType::T_I8    : dp->val.i8  = (int8_t)   *ap; break;
    1.82 +        case nsXPTType::T_I16   : dp->val.i16 = (int16_t)  *ap; break;
    1.83 +        case nsXPTType::T_I32   : dp->val.i32 = (int32_t)  *ap; break;
    1.84 +        case nsXPTType::T_U8    : dp->val.u8  = (uint8_t)  *ap; break;
    1.85 +        case nsXPTType::T_U16   : dp->val.u16 = (uint16_t) *ap; break;
    1.86 +        case nsXPTType::T_U32   : dp->val.u32 = (uint32_t) *ap; break;
    1.87 +        case nsXPTType::T_BOOL  : dp->val.b   = (bool)   *ap; break;
    1.88 +        case nsXPTType::T_CHAR  : dp->val.c   = (char)     *ap; break;
    1.89 +        case nsXPTType::T_WCHAR : dp->val.wc  = (wchar_t)  *ap; break;
    1.90 +        case nsXPTType::T_FLOAT : dp->val.f   = *(float *)  ap; break;
    1.91 +        default:
    1.92 +            NS_ASSERTION(0, "bad type");
    1.93 +            break;
    1.94 +#endif
    1.95 +        }
    1.96 +    }
    1.97 +
    1.98 +    result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams);
    1.99 +
   1.100 +    if(dispatchParams != paramBuffer)
   1.101 +        delete [] dispatchParams;
   1.102 +
   1.103 +    return result;
   1.104 +}
   1.105 +
   1.106 +#define STUB_ENTRY(n) // done in the .s file
   1.107 +
   1.108 +#define SENTINEL_ENTRY(n) \
   1.109 +nsresult nsXPTCStubBase::Sentinel##n() \
   1.110 +{ \
   1.111 +    NS_ERROR("nsXPTCStubBase::Sentinel called"); \
   1.112 +    return NS_ERROR_NOT_IMPLEMENTED; \
   1.113 +}
   1.114 +
   1.115 +#include "xptcstubsdef.inc"

mercurial