1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3
* ***** BEGIN LICENSE BLOCK *****
4
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
* The contents of this file are subject to the Mozilla Public License Version
7
* 1.1 (the "License"); you may not use this file except in compliance with
8
* the License. You may obtain a copy of the License at
9
* http://www.mozilla.org/MPL/
11
* Software distributed under the License is distributed on an "AS IS" basis,
12
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
* for the specific language governing rights and limitations under the
16
* The Original Code is mozilla.org Code.
18
* The Initial Developer of the Original Code is
19
* Netscape Communications Corporation.
20
* Portions created by the Initial Developer are Copyright (C) 1999
21
* the Initial Developer. All Rights Reserved.
24
* John Fairhurst <john_fairhurst@iname.com>
25
* Henry Sobotka <sobotka@axess.com> added VAC++ support
26
* and fixed emx asm to work with gcc 2.95.2 (Jan. 2000)
28
* Alternatively, the contents of this file may be used under the terms of
29
* either of the GNU General Public License Version 2 or later (the "GPL"),
30
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31
* in which case the provisions of the GPL or the LGPL are applicable instead
32
* of those above. If you wish to allow use of your version of this file only
33
* under the terms of either the GPL or the LGPL, and not to allow others to
34
* use your version of this file under the terms of the MPL, indicate your
35
* decision by deleting the provisions above and replace them with the notice
36
* and other provisions required by the GPL or the LGPL. If you do not delete
37
* the provisions above, a recipient may use your version of this file under
38
* the terms of any one of the MPL, the GPL or the LGPL.
40
* ***** END LICENSE BLOCK ***** */
42
/* Implement shared vtbl methods */
44
#include "xptcprivate.h"
46
#if !defined (__EMX__) && !defined(__IBMCPP__)
47
#error "This code is only for OS/2"
50
// Procedure in xptcall_vacpp.asm
52
extern nsresult SetEntryFromIndex(int stubidx);
57
PrepareAndDispatch( nsXPTCStubBase *self, PRUint32 methodIndex,
61
PrepareAndDispatch( nsXPTCStubBase *self, PRUint32 methodIndex,
65
#define PARAM_BUFFER_COUNT 16
67
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
68
nsXPTCMiniVariant* dispatchParams = NULL;
69
nsIInterfaceInfo* iface_info = NULL;
70
const nsXPTMethodInfo* info;
73
nsresult result = NS_ERROR_FAILURE;
75
// If anything fails before stackBytesToPop can be set then
76
// the failure is completely catastrophic!
78
NS_ASSERTION(self,"no self");
80
self->GetInterfaceInfo(&iface_info);
81
NS_ASSERTION(iface_info,"no interface info");
83
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
84
NS_ASSERTION(info,"no interface info");
86
paramCount = info->GetParamCount();
89
/* If paramCount is > 0, write out the EDX pointer to the
90
space on the stack args[0]. args[-4] is the space on
91
the stack where it was pushed */
95
/* If this is the second parameter, or if the first parameter is an
96
8 byte long long, write out the ECX pointer to the space on the
97
stack args[1]. args[-3] is the space on the stack where it was
99
nsXPTType type = info->GetParam(0).GetType();
100
if( paramCount > 1 ||
101
type == nsXPTType::T_I64 || type == nsXPTType::T_U64 )
108
// setup variant array pointer
109
if(paramCount > PARAM_BUFFER_COUNT)
110
dispatchParams = new nsXPTCMiniVariant[paramCount];
112
dispatchParams = paramBuffer;
113
NS_ASSERTION(dispatchParams,"no place for params");
116
for(i = 0; i < paramCount; i++, ap++)
118
const nsXPTParamInfo& param = info->GetParam(i);
119
const nsXPTType& type = param.GetType();
120
nsXPTCMiniVariant* dp = &dispatchParams[i];
122
if(param.IsOut() || !type.IsArithmetic())
124
dp->val.p = (void*) *ap;
130
case nsXPTType::T_I8 : dp->val.i8 = *((PRInt8*) ap); break;
131
case nsXPTType::T_I16 : dp->val.i16 = *((PRInt16*) ap); break;
132
case nsXPTType::T_I32 : dp->val.i32 = *((PRInt32*) ap); break;
133
case nsXPTType::T_I64 : dp->val.i64 = *((PRInt64*) ap); ap++; break;
134
case nsXPTType::T_U8 : dp->val.u8 = *((PRUint8*) ap); break;
135
case nsXPTType::T_U16 : dp->val.u16 = *((PRUint16*)ap); break;
136
case nsXPTType::T_U32 : dp->val.u32 = *((PRUint32*)ap); break;
137
case nsXPTType::T_U64 : dp->val.u64 = *((PRUint64*)ap); ap++; break;
138
case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break;
139
case nsXPTType::T_DOUBLE : dp->val.d = *((double*) ap); ap++; break;
140
case nsXPTType::T_BOOL : dp->val.b = *((PRBool*) ap); break;
141
case nsXPTType::T_CHAR : dp->val.c = *((char*) ap); break;
142
case nsXPTType::T_WCHAR : dp->val.wc = *((wchar_t*) ap); break;
144
NS_ASSERTION(0, "bad type");
149
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
151
NS_RELEASE(iface_info);
153
if(dispatchParams != paramBuffer)
154
delete [] dispatchParams;
161
#define STUB_ENTRY(n)
165
#define STUB_ENTRY(n) \
166
nsresult nsXPTCStubBase::Stub##n() \
168
register nsresult (*method) (nsXPTCStubBase *, PRUint32, PRUint32 *) = PrepareAndDispatch; \
170
register nsresult result; \
171
__asm__ __volatile__( \
172
"leal 0x0c(%%ebp), %%ecx\n\t" /* args */ \
174
"pushl $"#n"\n\t" /* method index */ \
175
"movl 0x08(%%ebp), %%ecx\n\t" /* this */ \
177
"call *%%edx\n\t" /* PrepareAndDispatch */ \
179
: "=a" (result), /* %0 */ \
180
"=&c" (temp0), /* %1 */ \
181
"=d" (temp1) /* %2 */ \
182
: "2" (method) /* %2 */ \
188
#define SENTINEL_ENTRY(n) \
189
nsresult nsXPTCStubBase::Sentinel##n() \
191
NS_ASSERTION(0,"nsXPCWrappedJS::Sentinel called"); \
192
return NS_ERROR_NOT_IMPLEMENTED; \
195
#include "xptcstubsdef.inc"