|
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/. */ |
|
5 |
|
6 /* Platform specific code to invoke XPCOM methods on native objects */ |
|
7 |
|
8 #include "xptcprivate.h" |
|
9 |
|
10 extern "C" void |
|
11 invoke_copy_to_stack(uint64_t* d, uint32_t paramCount, nsXPTCVariant* s) |
|
12 { |
|
13 for(; paramCount > 0; paramCount--, d++, s++) |
|
14 { |
|
15 if(s->IsPtrData()) |
|
16 { |
|
17 *((void**)d) = s->ptr; |
|
18 continue; |
|
19 } |
|
20 |
|
21 /* |
|
22 * AMD64 platform uses 8 bytes align. |
|
23 */ |
|
24 |
|
25 switch(s->type) |
|
26 { |
|
27 case nsXPTType::T_I8 : *((int8_t*) d) = s->val.i8; break; |
|
28 case nsXPTType::T_I16 : *((int16_t*) d) = s->val.i16; break; |
|
29 case nsXPTType::T_I32 : *((int32_t*) d) = s->val.i32; break; |
|
30 case nsXPTType::T_I64 : *((int64_t*) d) = s->val.i64; break; |
|
31 case nsXPTType::T_U8 : *((uint8_t*) d) = s->val.u8; break; |
|
32 case nsXPTType::T_U16 : *((uint16_t*)d) = s->val.u16; break; |
|
33 case nsXPTType::T_U32 : *((uint32_t*)d) = s->val.u32; break; |
|
34 case nsXPTType::T_U64 : *((uint64_t*)d) = s->val.u64; break; |
|
35 case nsXPTType::T_FLOAT : *((float*) d) = s->val.f; break; |
|
36 case nsXPTType::T_DOUBLE : *((double*) d) = s->val.d; break; |
|
37 case nsXPTType::T_BOOL : *((bool*) d) = s->val.b; break; |
|
38 case nsXPTType::T_CHAR : *((char*) d) = s->val.c; break; |
|
39 case nsXPTType::T_WCHAR : *((wchar_t*) d) = s->val.wc; break; |
|
40 default: |
|
41 // all the others are plain pointer types |
|
42 *((void**)d) = s->val.p; |
|
43 break; |
|
44 } |
|
45 } |
|
46 } |
|
47 |
|
48 extern "C" nsresult |
|
49 XPTC__InvokebyIndex(nsISupports* that, uint32_t methodIndex, |
|
50 uint32_t paramCount, nsXPTCVariant* params); |
|
51 |
|
52 extern "C" |
|
53 EXPORT_XPCOM_API(nsresult) |
|
54 NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex, |
|
55 uint32_t paramCount, nsXPTCVariant* params) |
|
56 { |
|
57 return XPTC__InvokebyIndex(that, methodIndex, paramCount, params); |
|
58 } |
|
59 |