1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 /* Platform specific code to invoke XPCOM methods on native objects */
8
9 #include "xptcprivate.h"
10
11 extern "C" {
12
13 // Remember that these 'words' are 32bit DWORDS
14
15 uint32_t
invoke_count_words(uint32_t paramCount,nsXPTCVariant * s)16 invoke_count_words(uint32_t paramCount, nsXPTCVariant* s)
17 {
18 uint32_t result = 0;
19 for(uint32_t i = 0; i < paramCount; i++, s++)
20 {
21 if(s->IsPtrData())
22 {
23 result++;
24 continue;
25 }
26 result++;
27 switch(s->type)
28 {
29 case nsXPTType::T_I64 :
30 case nsXPTType::T_U64 :
31 case nsXPTType::T_DOUBLE :
32 result++;
33 break;
34 }
35 }
36 return result;
37 }
38
39 void
invoke_copy_to_stack(uint32_t paramCount,nsXPTCVariant * s,uint32_t * d)40 invoke_copy_to_stack(uint32_t paramCount, nsXPTCVariant* s, uint32_t* d)
41 {
42 for(uint32_t i = 0; i < paramCount; i++, d++, s++)
43 {
44 if(s->IsPtrData())
45 {
46 *((void**)d) = s->ptr;
47 continue;
48 }
49
50 /* XXX: the following line is here (rather than as the default clause in
51 * the following switch statement) so that the Sun native compiler
52 * will generate the correct assembly code on the Solaris Intel
53 * platform. See the comments in bug #28817 for more details.
54 */
55
56 *((void**)d) = s->val.p;
57
58 switch(s->type)
59 {
60 case nsXPTType::T_I64 : *((int64_t*) d) = s->val.i64; d++; break;
61 case nsXPTType::T_U64 : *((uint64_t*)d) = s->val.u64; d++; break;
62 case nsXPTType::T_DOUBLE : *((double*) d) = s->val.d; d++; break;
63 }
64 }
65 }
66
67 }
68