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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 /* Implement shared vtbl methods. */
     8 #include "xptcprivate.h"
    10 nsresult ATTRIBUTE_USED
    11 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
    12 {
    13 #define PARAM_BUFFER_COUNT     16
    15     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
    16     nsXPTCMiniVariant* dispatchParams = nullptr;
    17     nsIInterfaceInfo* iface_info = nullptr;
    18     const nsXPTMethodInfo* info;
    19     uint8_t paramCount;
    20     uint8_t i;
    21     nsresult result = NS_ERROR_FAILURE;
    23     NS_ASSERTION(self,"no self");
    25     self->GetInterfaceInfo(&iface_info);
    26     NS_ASSERTION(iface_info,"no interface info");
    28     iface_info->GetMethodInfo(uint16_t(methodIndex), &info);
    29     NS_ASSERTION(info,"no interface info");
    31     paramCount = info->GetParamCount();
    33     // setup variant array pointer
    34     if(paramCount > PARAM_BUFFER_COUNT)
    35         dispatchParams = new nsXPTCMiniVariant[paramCount];
    36     else
    37         dispatchParams = paramBuffer;
    38     NS_ASSERTION(dispatchParams,"no place for params");
    40     uint32_t* ap = args;
    41     for(i = 0; i < paramCount; i++, ap++)
    42     {
    43         const nsXPTParamInfo& param = info->GetParam(i);
    44         const nsXPTType& type = param.GetType();
    45         nsXPTCMiniVariant* dp = &dispatchParams[i];
    47         if(param.IsOut() || !type.IsArithmetic())
    48         {
    49             dp->val.p = (void*) *ap;
    50             continue;
    51         }
    52         // else
    53         switch(type)
    54         {
    55         case nsXPTType::T_I8     : dp->val.i8  = *((int8_t*)  ap);       break;
    56         case nsXPTType::T_I16    : dp->val.i16 = *((int16_t*) ap);       break;
    57         case nsXPTType::T_I32    : dp->val.i32 = *((int32_t*) ap);       break;
    58         case nsXPTType::T_I64    : dp->val.i64 = *((int64_t*) ap); ap++; break;
    59         case nsXPTType::T_U8     : dp->val.u8  = *((uint8_t*) ap);       break;
    60         case nsXPTType::T_U16    : dp->val.u16 = *((uint16_t*)ap);       break;
    61         case nsXPTType::T_U32    : dp->val.u32 = *((uint32_t*)ap);       break;
    62         case nsXPTType::T_U64    : dp->val.u64 = *((uint64_t*)ap); ap++; break;
    63         case nsXPTType::T_FLOAT  : dp->val.f   = *((float*)   ap);       break;
    64         case nsXPTType::T_DOUBLE : dp->val.d   = *((double*)  ap); ap++; break;
    65         case nsXPTType::T_BOOL   : dp->val.b   = *((bool*)  ap);       break;
    66         case nsXPTType::T_CHAR   : dp->val.c   = *((char*)    ap);       break;
    67         case nsXPTType::T_WCHAR  : dp->val.wc  = *((wchar_t*) ap);       break;
    68         default:
    69             NS_ERROR("bad type");
    70             break;
    71         }
    72     }
    74     result = self->CallMethod((uint16_t)methodIndex, info, dispatchParams);
    76     NS_RELEASE(iface_info);
    78     if(dispatchParams != paramBuffer)
    79         delete [] dispatchParams;
    81     return result;
    82 }
    84 /*
    85  * These stubs move just move the values passed in registers onto the stack,
    86  * so they are contiguous with values passed on the stack, and then calls
    87  * PrepareAndDispatch() to do the dirty work.
    88  */
    90 #define STUB_ENTRY(n)							\
    91 __asm__(								\
    92     ".global	_Stub"#n"__14nsXPTCStubBase\n\t"			\
    93 "_Stub"#n"__14nsXPTCStubBase:\n\t"					\
    94     "stmfd	sp!, {r1, r2, r3}	\n\t"				\
    95     "mov	ip, sp			\n\t"				\
    96     "stmfd	sp!, {fp, ip, lr, pc}	\n\t"				\
    97     "sub	fp, ip, #4		\n\t"				\
    98     "mov	r1, #"#n"		\n\t"    /* = methodIndex 	*/ \
    99     "add	r2, sp, #16		\n\t"				\
   100     "bl		_PrepareAndDispatch__FP14nsXPTCStubBaseUiPUi   \n\t"	\
   101     "ldmea	fp, {fp, sp, lr}	\n\t"				\
   102     "add	sp, sp, #12		\n\t"				\
   103     "mov	pc, lr			\n\t"				\
   104 );
   106 #define SENTINEL_ENTRY(n) \
   107 nsresult nsXPTCStubBase::Sentinel##n() \
   108 { \
   109     NS_ERROR("nsXPTCStubBase::Sentinel called"); \
   110     return NS_ERROR_NOT_IMPLEMENTED; \
   111 }
   113 #include "xptcstubsdef.inc"

mercurial