mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
r=mkaply, sr=mkaply (OS/2 only) Patch from Andy Willis - add _declspec(dllexport/dllimport) for OS/2
This commit is contained in:
parent
b71e9517cd
commit
6b2e2b08ab
@ -37,7 +37,7 @@
|
||||
|
||||
DEPTH = ../../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
@ -46,17 +46,12 @@ MODULE = xpcom
|
||||
LIBRARY_NAME = xptcmd
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
|
||||
ifdef GNU_CXX
|
||||
CPPSRCS = \
|
||||
../unix/xptcinvoke_gcc_x86_unix.cpp \
|
||||
../unix/xptcstubs_gcc_x86_unix.cpp \
|
||||
xptcstubs_gcc_x86_os2.cpp \
|
||||
$(NULL)
|
||||
LOCAL_INCLUDES = -I$(srcdir)/../unix
|
||||
DEFINES += -DMOZ_NEED_LEADING_UNDERSCORE
|
||||
else
|
||||
CPPSRCS = xptcstubs_os2.cpp
|
||||
ASFILES = xptcinvoke_vacpp.asm xptcstubs_vacpp.asm
|
||||
endif
|
||||
|
||||
# Force use of PIC
|
||||
FORCE_USE_PIC = 1
|
||||
@ -70,7 +65,7 @@ include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -DEXPORT_XPTC_API
|
||||
|
||||
INCLUDES += -I$(srcdir)/../..
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../..
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(INSTALL) $(LIBRARY) ../..
|
||||
|
@ -1,185 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Fairhurst <john_fairhurst@iname.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*
|
||||
* This Original Code has been modified by IBM Corporation.
|
||||
* Modifications made by IBM described herein are
|
||||
* Copyright (c) International Business Machines
|
||||
* Corporation, 2000
|
||||
*
|
||||
* Modifications to Mozilla code or documentation
|
||||
* identified per MPL Section 3.3
|
||||
*
|
||||
* Date Modified by Description of modification
|
||||
* 03/22/2000 IBM Corp. Fixed multiple inheritance bug in XPTC_InvokeByIndex to adjust the
|
||||
* "that" (this) pointer appropriately.
|
||||
*/
|
||||
|
||||
/* Platform specific code to invoke XPCOM methods on native objects */
|
||||
|
||||
// This is 80% copied directly from other platforms; the assembler
|
||||
// stuff is all my fault, though. (jmf)
|
||||
|
||||
#if !defined(__EMX__)
|
||||
#error "This code is for OS/2 EMX only"
|
||||
#endif
|
||||
|
||||
#include "xptcprivate.h"
|
||||
|
||||
// Remember that these 'words' are 32-bit DWORDs
|
||||
static PRUint32
|
||||
invoke_count_words( PRUint32 paramCount, nsXPTCVariant* s)
|
||||
{
|
||||
PRUint32 result = 0;
|
||||
|
||||
for(PRUint32 i = 0; i < paramCount; i++, s++)
|
||||
{
|
||||
if(s->IsPtrData())
|
||||
result++;
|
||||
|
||||
else {
|
||||
|
||||
switch(s->type)
|
||||
{
|
||||
// 64-bit types
|
||||
case nsXPTType::T_I64 :
|
||||
case nsXPTType::T_U64 :
|
||||
case nsXPTType::T_DOUBLE :
|
||||
result+=2;
|
||||
break;
|
||||
|
||||
// all others are dwords
|
||||
default:
|
||||
result++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
invoke_copy_to_stack( PRUint32* d, uint32 paramCount, nsXPTCVariant* s)
|
||||
{
|
||||
for( PRUint32 i = 0; i < paramCount; i++, d++, s++)
|
||||
{
|
||||
if(s->IsPtrData())
|
||||
*((void**)d) = s->ptr;
|
||||
|
||||
else {
|
||||
|
||||
switch(s->type)
|
||||
{
|
||||
case nsXPTType::T_I8 : *((int8*) d) = s->val.i8; break;
|
||||
case nsXPTType::T_I16 : *((int16*) d) = s->val.i16; break;
|
||||
case nsXPTType::T_I32 : *((int32*) d) = s->val.i32; break;
|
||||
case nsXPTType::T_I64 : *((int64*) d) = s->val.i64; d++; break;
|
||||
case nsXPTType::T_U8 : *((uint8*) d) = s->val.u8; break;
|
||||
case nsXPTType::T_U16 : *((uint16*) d) = s->val.u16; break;
|
||||
case nsXPTType::T_U32 : *((uint32*) d) = s->val.u32; break;
|
||||
case nsXPTType::T_U64 : *((uint64*) d) = s->val.u64; d++; break;
|
||||
case nsXPTType::T_FLOAT : *((float*) d) = s->val.f; break;
|
||||
case nsXPTType::T_DOUBLE : *((double*) d) = s->val.d; d++; break;
|
||||
case nsXPTType::T_BOOL : *((PRBool*) d) = s->val.b; break;
|
||||
case nsXPTType::T_CHAR : *((char*) d) = s->val.c; break;
|
||||
case nsXPTType::T_WCHAR : *((wchar_t*)d) = s->val.wc; break;
|
||||
default:
|
||||
// all the others are plain pointer types
|
||||
*((void**)d) = s->val.p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
XPTC_PUBLIC_API(nsresult)
|
||||
XPTC_InvokeByIndex( nsISupports *that, PRUint32 index,
|
||||
PRUint32 paramcount, nsXPTCVariant* params)
|
||||
{
|
||||
int ibytes;
|
||||
void *pStack;
|
||||
int result = NS_OK;
|
||||
|
||||
// Find size in bytes necessary for call
|
||||
ibytes = 4 * invoke_count_words( paramcount, params);
|
||||
|
||||
__asm__ __volatile__(
|
||||
"movl %1, %%eax\n" /* load |ibytes| into eax */
|
||||
"subl %%eax, %%esp\n" /* make room on stack */
|
||||
"movl %%esp, %0" /* store base in |pStack| */
|
||||
: "=g" (pStack) /* %0 */
|
||||
: "g" (ibytes) /* %1 */
|
||||
: "ax", "memory", "sp"
|
||||
);
|
||||
|
||||
// Fill in that gap in the stack with the params to the method
|
||||
invoke_copy_to_stack( (PRUint32*) pStack, paramcount, params);
|
||||
|
||||
// push the hidden 'this' parameter, traverse the vtable,
|
||||
// and then call the method.
|
||||
|
||||
__asm__ __volatile__(
|
||||
"movl %2, %%eax\n" /* |that| ptr -> eax */
|
||||
"movl (%%eax), %%edx\n" /* vptr -> edx */
|
||||
"movl %3, %%ebx\n"
|
||||
"shl $3, %%ebx\n" /* 8 bytes per method.. */
|
||||
"addl $8, %%ebx\n" /* ..plus 8 to skip over 1st 8 bytes of vtbl */
|
||||
|
||||
"addl %%ebx, %%edx\n" /* find appropriate vtbl entry */
|
||||
"movswl (%%edx),%%ecx\n" /* get possible |that| ptr adjustment value */
|
||||
"addl %%ecx, %%eax\n" /* adjust the |that| ptr (needed for multiple inheritance) */
|
||||
"pushl %%eax\n" /* enstack the possibly-adjusted |that| */
|
||||
|
||||
"addl $4, %%edx\n" /* ..add 4 more to get to the method's entry point */
|
||||
|
||||
"call (%%edx)\n" /* call method */
|
||||
"movl %%eax, %0\n" /* save rc in |result| */
|
||||
"movl %1, %%ebx\n" /* clear up stack */
|
||||
"addl $4, %%ebx\n"
|
||||
"addl %%ebx, %%esp"
|
||||
: "=g" (result) /* %0 */
|
||||
: "g" (ibytes), /* %1 */
|
||||
"g" (that), /* %2 */
|
||||
"g" (index) /* %3 */
|
||||
: "ax", "bx", "dx", "memory", "sp"
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
@ -1,253 +0,0 @@
|
||||
; -*- Mode: asm; tab-width: 8; c-basic-offset: 4 -*-
|
||||
|
||||
; ***** BEGIN LICENSE BLOCK *****
|
||||
; Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
;
|
||||
; The contents of this file are subject to the Mozilla Public License Version
|
||||
; 1.1 (the "License"); you may not use this file except in compliance with
|
||||
; the License. You may obtain a copy of the License at
|
||||
; http://www.mozilla.org/MPL/
|
||||
;
|
||||
; Software distributed under the License is distributed on an "AS IS" basis,
|
||||
; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
; for the specific language governing rights and limitations under the
|
||||
; License.
|
||||
;
|
||||
; The Original Code is an OS/2 implementation of js_CompareAndSwap in assembly.
|
||||
;
|
||||
; The Initial Developer of the Original Code is
|
||||
; IBM Corporation.
|
||||
; Portions created by the Initial Developer are Copyright (C) 2001
|
||||
; the Initial Developer. All Rights Reserved.
|
||||
;
|
||||
; Contributor(s): Henry Sobotka <sobotka@axess.com>
|
||||
;
|
||||
; Alternatively, the contents of this file may be used under the terms of
|
||||
; either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
; the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
; in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
; of those above. If you wish to allow use of your version of this file only
|
||||
; under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
; use your version of this file under the terms of the MPL, indicate your
|
||||
; decision by deleting the provisions above and replace them with the notice
|
||||
; and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
; the provisions above, a recipient may use your version of this file under
|
||||
; the terms of any one of the MPL, the GPL or the LGPL.
|
||||
;
|
||||
; ***** END LICENSE BLOCK *****
|
||||
|
||||
; This Original Code has been modified by IBM Corporation.
|
||||
; Modifications made by IBM described herein are
|
||||
; Copyright (c) International Business Machines
|
||||
; Corporation, 2000
|
||||
;
|
||||
; Modifications to Mozilla code or documentation
|
||||
; identified per MPL Section 3.3
|
||||
;
|
||||
; Date Modified by Description of modification
|
||||
; 03/23/2000 IBM Corp. Various fixes for parameter passing and ; adjusting the 'this' pointer for
|
||||
; multiply inherited objects.
|
||||
|
||||
COMMENT |
|
||||
xptcall_vacpp.asm: ALP assembler procedures for VAC++ build of xptcall
|
||||
|
||||
We use essentially the same algorithm as the other platforms, except
|
||||
Optlink as calling convention. This means loading the three leftmost
|
||||
conforming (<= 4 bytes, enum or pointer) parameters into eax, edx and ecx,
|
||||
and the four leftmost float types atop the FP stack. As "this" goes into
|
||||
eax, we only have to load edx and ecx (if there are two parameters).
|
||||
Nonconforming parameters go on the stack. As the right-size space has
|
||||
to be allocated at the proper place (order of parameters) in the stack
|
||||
for each conforming parameter, we simply copy them all. |
|
||||
|
||||
|
||||
.486P
|
||||
.MODEL FLAT, OPTLINK
|
||||
.STACK
|
||||
|
||||
.CODE
|
||||
|
||||
t_Int4Bytes equ 001004h
|
||||
t_Int8Bytes equ 001008h
|
||||
t_Float4Bytes equ 000104h
|
||||
t_Float8Bytes equ 000108h
|
||||
|
||||
TypesArray dd t_Int4Bytes ; nsXPTType::T_I8
|
||||
dd t_Int4Bytes ; nsXPTType::T_I16
|
||||
dd t_Int4Bytes ; nsXPTType::T_I32
|
||||
dd t_Int8Bytes ; nsXPTType::T_I64 (***)
|
||||
dd t_Int4Bytes ; nsXPTType::T_U8
|
||||
dd t_Int4Bytes ; nsXPTType::T_U16
|
||||
dd t_Int4Bytes ; nsXPTType::T_U32
|
||||
dd t_Int8Bytes ; nsXPTType::T_U64 (***)
|
||||
dd t_Float4Bytes ; nsXPTType::T_FLOAT (***)
|
||||
dd t_Float8Bytes ; nsXPTType::T_DOUBLE (***)
|
||||
dd t_Int4Bytes ; nsXPTType::T_BOOL
|
||||
dd t_Int4Bytes ; nsXPTType::T_CHAR
|
||||
dd t_Int4Bytes ; nsXPTType::T_WCHAR
|
||||
dd t_Int4Bytes ; TD_VOID
|
||||
dd t_Int4Bytes ; TD_PNSIID
|
||||
dd t_Int4Bytes ; TD_DOMSTRING
|
||||
dd t_Int4Bytes ; TD_PSTRING
|
||||
dd t_Int4Bytes ; TD_PWSTRING
|
||||
dd t_Int4Bytes ; TD_INTERFACE_TYPE
|
||||
dd t_Int4Bytes ; TD_INTERFACE_IS_TYPE
|
||||
dd t_Int4Bytes ; TD_ARRAY
|
||||
dd t_Int4Bytes ; TD_PSTRING_SIZE_IS
|
||||
dd t_Int4Bytes ; TD_PWSTRING_SIZE_IS
|
||||
dd t_Int4Bytes ; TD_UTF8STRING
|
||||
dd t_Int4Bytes ; TD_CSTRING
|
||||
dd t_Int4Bytes ; TD_ASTRING
|
||||
; All other values default to 4 byte int/ptr
|
||||
|
||||
|
||||
|
||||
; Optlink puts 'that' in eax, 'index' in edx, 'paramcount' in ecx
|
||||
; 'params' is on the stack...
|
||||
XPTC_InvokeByIndex PROC OPTLINK EXPORT USES ebx edi esi, that, index, paramcount, params
|
||||
|
||||
LOCAL cparams:dword, fparams:dword, reg_edx:dword, reg_ecx:dword, count:dword
|
||||
|
||||
mov dword ptr [that], eax ; that
|
||||
mov dword ptr [index], edx ; index
|
||||
mov dword ptr [paramcount], ecx ; paramcount
|
||||
mov dword ptr [count], ecx ; save a copy of count
|
||||
|
||||
; #define FOURBYTES 4
|
||||
; #define EIGHTBYTES 8
|
||||
; #define FLOAT 0x00000100
|
||||
; #define INT 0x00001000
|
||||
; #define LENGTH 0x000000ff
|
||||
;
|
||||
;types[ ] = {
|
||||
; FOURBYES | INT, // int/uint/ptr/etc
|
||||
; EIGHTBYTES | INT, // long long
|
||||
; FOURBYES | FLOAT, // float
|
||||
; EIGHTBYTES | FLOAT // double
|
||||
;};
|
||||
; params+00h = val // double
|
||||
; params+08h = ptr
|
||||
; params+0ch = type
|
||||
; params+0dh = flags
|
||||
; PTR_IS_DATA = 0x01
|
||||
; ecx = params
|
||||
; edx = src
|
||||
; edi = dst
|
||||
; ebx = type (bh = int/float, bl = byte count)
|
||||
|
||||
xor eax, eax
|
||||
mov dword ptr [cparams],eax ; cparams = 0;
|
||||
mov dword ptr [fparams],eax ; fparams = 0;
|
||||
|
||||
shl ecx, 03h
|
||||
sub esp, ecx ; dst/esp = add esp, paramCount * 8
|
||||
mov edi, esp
|
||||
|
||||
push eax ; push 0 // "end" of floating point register stack...
|
||||
|
||||
mov ecx, dword ptr [params] ; // params is a "register" variable
|
||||
@While1:
|
||||
mov eax, dword ptr [count] ; while( count-- )
|
||||
or eax, eax ; // (test for zero)
|
||||
je @EndWhile1
|
||||
dec eax
|
||||
mov dword ptr [count], eax
|
||||
; {
|
||||
|
||||
test byte ptr [ecx+0dh],01h ; if ( params->flags & PTR_IS_DATA ) {
|
||||
je @IfElse1
|
||||
lea edx, dword ptr [ecx+08h] ; src = ¶ms->ptr;
|
||||
mov ebx, 01004h ; type = INT | FOURBYTES;
|
||||
jmp @EndIf1
|
||||
@IfElse1: ; } else {
|
||||
mov edx, ecx ; src = ¶ms->val
|
||||
movzx eax, byte ptr [ecx+0ch] ; type = types[params->type];
|
||||
cmp eax, 22 ; // range check params->type... (0 to 22)
|
||||
jle @TypeOK
|
||||
mov eax,2 ; // all others default to 4 byte int
|
||||
@TypeOK:
|
||||
mov ebx, dword ptr [TypesArray+eax*4]
|
||||
@EndIf1: ; }
|
||||
|
||||
test bh, 001h ; if ( type & FLOAT ) {
|
||||
je @EndIf2
|
||||
cmp dword ptr [fparams], 4 ; if ( fparams < 4 ) {
|
||||
jge @EndIf3
|
||||
push edx ; push src;
|
||||
push ebx ; push type
|
||||
inc dword ptr [fparams] ; fparams++;
|
||||
;;; movzx eax, bl ; // dst += (type & LENGTH);
|
||||
;;; add edi, eax ;
|
||||
;;; xor ebx, ebx ; // type = 0; // "handled"
|
||||
@EndIf3: ; }
|
||||
@EndIf2: ; }
|
||||
|
||||
; // copy bytes...
|
||||
@While2: or bl, bl ; while( type & LENGTH ) {
|
||||
je @EndWhile2
|
||||
test bh, 010h ; if( type & INT ) {
|
||||
je @EndIf4
|
||||
cmp dword ptr [cparams], 8 ; if( cparams < 8 ) {
|
||||
jge @EndIf5
|
||||
lea eax, dword ptr [reg_edx] ; (®_edx)[cparams] = *src;
|
||||
sub eax, dword ptr [cparams]
|
||||
mov esi, dword ptr [edx]
|
||||
mov dword ptr [eax], esi
|
||||
add dword ptr [cparams], 4 ; cparams += 4;
|
||||
;;; jmp @NoCopy ; // goto nocopy;
|
||||
@EndIf5: ; }
|
||||
@EndIf4: ; }
|
||||
mov eax, dword ptr [edx] ; *dst = *src;
|
||||
mov dword ptr [edi], eax
|
||||
@NoCopy: ;nocopy:
|
||||
add edi, 4 ; dst++;
|
||||
add edx, 4 ; src++;
|
||||
sub bl, 4 ; type -= 4;
|
||||
jmp @While2
|
||||
@EndWhile2: ; }
|
||||
add ecx, 010h ; params++;
|
||||
jmp @While1
|
||||
@EndWhile1: ; }
|
||||
|
||||
; // Set up fpu and regs can make the call...
|
||||
@While3: pop ebx ; while ( pop type ) {
|
||||
or ebx, ebx
|
||||
je @EndWhile3
|
||||
pop edx ; pop src
|
||||
cmp bl, 08h ; if( type & EIGHTBYTES ) {
|
||||
jne @IfElse6
|
||||
fld qword ptr [edx] ; fld qword ptr [src]
|
||||
jmp @EndIf6
|
||||
@IfElse6: ; } else {
|
||||
fld dword ptr [edx] ; fld dword ptr [src]
|
||||
@EndIf6: ; }
|
||||
jmp @While3
|
||||
@EndWhile3: ; }
|
||||
|
||||
; make the call
|
||||
mov eax, dword ptr [that] ; get 'that' ("this" ptr)
|
||||
mov ebx, dword ptr [index] ; get index
|
||||
shl ebx, 03h ; index *= 8 bytes per method
|
||||
add ebx, 08h ; += 8 at head of vtable
|
||||
add ebx, [eax] ; calculate address
|
||||
|
||||
mov ecx, dword ptr [ebx+04h]
|
||||
add eax, ecx
|
||||
sub esp, 04h ; make room for 'this' ptr on stack
|
||||
|
||||
mov edx, dword ptr [reg_edx]
|
||||
mov ecx, dword ptr [reg_ecx]
|
||||
|
||||
call dword ptr [ebx] ; call method
|
||||
|
||||
mov ecx, dword ptr [paramcount]
|
||||
shl ecx, 03h
|
||||
add esp, ecx ; remove space on stack for params
|
||||
add esp, 04h ; remove space on stack for 'this' ptr
|
||||
ret
|
||||
|
||||
ENDP
|
||||
|
||||
END
|
||||
|
||||
|
@ -35,21 +35,16 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* Implement shared vtbl methods */
|
||||
|
||||
// This is a 98% copy of other implementations; see comment at top of
|
||||
// xptcinvoke_emx.cpp for why this file exists.
|
||||
//
|
||||
/* Implement shared vtbl methods. */
|
||||
|
||||
#include "xptcprivate.h"
|
||||
#include "xptc_platforms_unixish_x86.h"
|
||||
#include "xptc_gcc_x86_unix.h"
|
||||
|
||||
#if !defined(__EMX__)
|
||||
#error "This code is for OS/2 EMX only"
|
||||
#endif
|
||||
|
||||
static nsresult
|
||||
PrepareAndDispatch( nsXPTCStubBase *self, PRUint32 methodIndex,
|
||||
PRUint32 *args)
|
||||
extern "C" {
|
||||
static nsresult ATTRIBUTE_USED
|
||||
__attribute__ ((regparm (3)))
|
||||
PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
|
||||
{
|
||||
#define PARAM_BUFFER_COUNT 16
|
||||
|
||||
@ -61,9 +56,6 @@ PrepareAndDispatch( nsXPTCStubBase *self, PRUint32 methodIndex,
|
||||
PRUint8 i;
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
|
||||
// If anything fails before stackBytesToPop can be set then
|
||||
// the failure is completely catastrophic!
|
||||
|
||||
NS_ASSERTION(self,"no self");
|
||||
|
||||
self->GetInterfaceInfo(&iface_info);
|
||||
@ -94,24 +86,12 @@ PrepareAndDispatch( nsXPTCStubBase *self, PRUint32 methodIndex,
|
||||
continue;
|
||||
}
|
||||
// else
|
||||
dp->val.p = (void*) *ap;
|
||||
switch(type)
|
||||
{
|
||||
case nsXPTType::T_I8 : dp->val.i8 = *((PRInt8*) ap); break;
|
||||
case nsXPTType::T_I16 : dp->val.i16 = *((PRInt16*) ap); break;
|
||||
case nsXPTType::T_I32 : dp->val.i32 = *((PRInt32*) ap); break;
|
||||
case nsXPTType::T_I64 : dp->val.i64 = *((PRInt64*) ap); ap++; break;
|
||||
case nsXPTType::T_U8 : dp->val.u8 = *((PRUint8*) ap); break;
|
||||
case nsXPTType::T_U16 : dp->val.u16 = *((PRUint16*)ap); break;
|
||||
case nsXPTType::T_U32 : dp->val.u32 = *((PRUint32*)ap); break;
|
||||
case nsXPTType::T_U64 : dp->val.u64 = *((PRUint64*)ap); ap++; break;
|
||||
case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break;
|
||||
case nsXPTType::T_DOUBLE : dp->val.d = *((double*) ap); ap++; break;
|
||||
case nsXPTType::T_BOOL : dp->val.b = *((PRBool*) ap); break;
|
||||
case nsXPTType::T_CHAR : dp->val.c = *((char*) ap); break;
|
||||
case nsXPTType::T_WCHAR : dp->val.wc = *((wchar_t*) ap); break;
|
||||
default:
|
||||
NS_ASSERTION(0, "bad type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,30 +104,67 @@ PrepareAndDispatch( nsXPTCStubBase *self, PRUint32 methodIndex,
|
||||
|
||||
return result;
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
#if defined(__declspec)
|
||||
#define SYMBOL_EXPORT(sym) \
|
||||
".stabs \"" sym ",0=" sym ",code\", 0x6c,0,0,-42\n\t"
|
||||
#else
|
||||
#define SYMBOL_EXPORT(sym)
|
||||
#endif
|
||||
|
||||
#define STUB_ENTRY(n) \
|
||||
nsresult nsXPTCStubBase::Stub##n() \
|
||||
{ \
|
||||
register void* method = PrepareAndDispatch; \
|
||||
register nsresult result; \
|
||||
__asm__ __volatile__( \
|
||||
"leal 0x0c(%%ebp), %%ecx\n\t" /* args */ \
|
||||
"pushl %%ecx\n\t" \
|
||||
"pushl $"#n"\n\t" /* method index */ \
|
||||
"movl 0x08(%%ebp), %%ecx\n\t" /* this */ \
|
||||
"pushl %%ecx\n\t" \
|
||||
"call *%%edx" /* PrepareAndDispatch */ \
|
||||
: "=a" (result) /* %0 */ \
|
||||
: "d" (method) /* %1 */ \
|
||||
: "ax", "dx", "cx", "memory" ); \
|
||||
return result; \
|
||||
}
|
||||
asm(".text\n\t" \
|
||||
".align 2\n\t" \
|
||||
".if " #n " < 10\n\t" \
|
||||
".globl " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase5Stub" #n "Ev\n\t" \
|
||||
".type " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase5Stub" #n "Ev,@function\n" \
|
||||
SYMBOL_EXPORT(SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase5Stub" #n "Ev") \
|
||||
SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase5Stub" #n "Ev:\n\t" \
|
||||
".elseif " #n " < 100\n\t" \
|
||||
".globl " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase6Stub" #n "Ev\n\t" \
|
||||
".type " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase6Stub" #n "Ev,@function\n" \
|
||||
SYMBOL_EXPORT(SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase6Stub" #n "Ev") \
|
||||
SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase6Stub" #n "Ev:\n\t" \
|
||||
".elseif " #n " < 1000\n\t" \
|
||||
".globl " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase7Stub" #n "Ev\n\t" \
|
||||
".type " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase7Stub" #n "Ev,@function\n" \
|
||||
SYMBOL_EXPORT(SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase7Stub" #n "Ev") \
|
||||
SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase7Stub" #n "Ev:\n\t" \
|
||||
".else\n\t" \
|
||||
".err \"stub number " #n " >= 1000 not yet supported\"\n\t" \
|
||||
".endif\n\t" \
|
||||
"movl $" #n ", %eax\n\t" \
|
||||
"jmp " SYMBOL_UNDERSCORE "SharedStub\n\t" \
|
||||
".if " #n " < 10\n\t" \
|
||||
".size " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase5Stub" #n "Ev,.-" SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase5Stub" #n "Ev\n\t" \
|
||||
".elseif " #n " < 100\n\t" \
|
||||
".size " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase6Stub" #n "Ev,.-" SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase6Stub" #n "Ev\n\t" \
|
||||
".else\n\t" \
|
||||
".size " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase7Stub" #n "Ev,.-" SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase7Stub" #n "Ev\n\t" \
|
||||
".endif");
|
||||
|
||||
// static nsresult SharedStub(PRUint32 methodIndex) __attribute__((regparm(1)))
|
||||
asm(".text\n\t"
|
||||
".align 2\n\t"
|
||||
".type " SYMBOL_UNDERSCORE "SharedStub,@function\n\t"
|
||||
SYMBOL_UNDERSCORE "SharedStub:\n\t"
|
||||
"leal 0x08(%esp), %ecx\n\t"
|
||||
"movl 0x04(%esp), %edx\n\t"
|
||||
"jmp " SYMBOL_UNDERSCORE "PrepareAndDispatch\n\t"
|
||||
".size " SYMBOL_UNDERSCORE "SharedStub,.-" SYMBOL_UNDERSCORE "SharedStub");
|
||||
|
||||
#define SENTINEL_ENTRY(n) \
|
||||
nsresult nsXPTCStubBase::Sentinel##n() \
|
||||
{ \
|
||||
NS_ASSERTION(0,"nsXPCWrappedJS::Sentinel called"); \
|
||||
NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
|
||||
return NS_ERROR_NOT_IMPLEMENTED; \
|
||||
}
|
||||
|
||||
#include "xptcstubsdef.inc"
|
||||
|
||||
void
|
||||
xptc_dummy()
|
||||
{
|
||||
}
|
||||
|
@ -1,195 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org Code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Fairhurst <john_fairhurst@iname.com>
|
||||
* Henry Sobotka <sobotka@axess.com> added VAC++ support
|
||||
* and fixed emx asm to work with gcc 2.95.2 (Jan. 2000)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* Implement shared vtbl methods */
|
||||
|
||||
#include "xptcprivate.h"
|
||||
|
||||
#if !defined (__EMX__) && !defined(__IBMCPP__)
|
||||
#error "This code is only for OS/2"
|
||||
#endif
|
||||
|
||||
// Procedure in xptcall_vacpp.asm
|
||||
#ifdef XP_OS2_VACPP
|
||||
extern nsresult SetEntryFromIndex(int stubidx);
|
||||
#endif
|
||||
|
||||
#ifdef XP_OS2_VACPP
|
||||
nsresult
|
||||
PrepareAndDispatch( nsXPTCStubBase *self, PRUint32 methodIndex,
|
||||
PRUint32 *args)
|
||||
#else
|
||||
static nsresult
|
||||
PrepareAndDispatch( nsXPTCStubBase *self, PRUint32 methodIndex,
|
||||
PRUint32 *args)
|
||||
#endif
|
||||
{
|
||||
#define PARAM_BUFFER_COUNT 16
|
||||
|
||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCMiniVariant* dispatchParams = NULL;
|
||||
nsIInterfaceInfo* iface_info = NULL;
|
||||
const nsXPTMethodInfo* info;
|
||||
PRUint8 paramCount;
|
||||
PRUint8 i;
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
|
||||
// If anything fails before stackBytesToPop can be set then
|
||||
// the failure is completely catastrophic!
|
||||
|
||||
NS_ASSERTION(self,"no self");
|
||||
|
||||
self->GetInterfaceInfo(&iface_info);
|
||||
NS_ASSERTION(iface_info,"no interface info");
|
||||
|
||||
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
|
||||
NS_ASSERTION(info,"no interface info");
|
||||
|
||||
paramCount = info->GetParamCount();
|
||||
|
||||
#ifdef XP_OS2_VACPP
|
||||
/* If paramCount is > 0, write out the EDX pointer to the
|
||||
space on the stack args[0]. args[-4] is the space on
|
||||
the stack where it was pushed */
|
||||
if (paramCount) {
|
||||
args[0] = args[-4];
|
||||
|
||||
/* If this is the second parameter, or if the first parameter is an
|
||||
8 byte long long, write out the ECX pointer to the space on the
|
||||
stack args[1]. args[-3] is the space on the stack where it was
|
||||
pushed */
|
||||
nsXPTType type = info->GetParam(0).GetType();
|
||||
if( paramCount > 1 ||
|
||||
type == nsXPTType::T_I64 || type == nsXPTType::T_U64 )
|
||||
{
|
||||
args[1] = args[-3];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// setup variant array pointer
|
||||
if(paramCount > PARAM_BUFFER_COUNT)
|
||||
dispatchParams = new nsXPTCMiniVariant[paramCount];
|
||||
else
|
||||
dispatchParams = paramBuffer;
|
||||
NS_ASSERTION(dispatchParams,"no place for params");
|
||||
|
||||
PRUint32* ap = args;
|
||||
for(i = 0; i < paramCount; i++, ap++)
|
||||
{
|
||||
const nsXPTParamInfo& param = info->GetParam(i);
|
||||
const nsXPTType& type = param.GetType();
|
||||
nsXPTCMiniVariant* dp = &dispatchParams[i];
|
||||
|
||||
if(param.IsOut() || !type.IsArithmetic())
|
||||
{
|
||||
dp->val.p = (void*) *ap;
|
||||
continue;
|
||||
}
|
||||
// else
|
||||
switch(type)
|
||||
{
|
||||
case nsXPTType::T_I8 : dp->val.i8 = *((PRInt8*) ap); break;
|
||||
case nsXPTType::T_I16 : dp->val.i16 = *((PRInt16*) ap); break;
|
||||
case nsXPTType::T_I32 : dp->val.i32 = *((PRInt32*) ap); break;
|
||||
case nsXPTType::T_I64 : dp->val.i64 = *((PRInt64*) ap); ap++; break;
|
||||
case nsXPTType::T_U8 : dp->val.u8 = *((PRUint8*) ap); break;
|
||||
case nsXPTType::T_U16 : dp->val.u16 = *((PRUint16*)ap); break;
|
||||
case nsXPTType::T_U32 : dp->val.u32 = *((PRUint32*)ap); break;
|
||||
case nsXPTType::T_U64 : dp->val.u64 = *((PRUint64*)ap); ap++; break;
|
||||
case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break;
|
||||
case nsXPTType::T_DOUBLE : dp->val.d = *((double*) ap); ap++; break;
|
||||
case nsXPTType::T_BOOL : dp->val.b = *((PRBool*) ap); break;
|
||||
case nsXPTType::T_CHAR : dp->val.c = *((char*) ap); break;
|
||||
case nsXPTType::T_WCHAR : dp->val.wc = *((wchar_t*) ap); break;
|
||||
default:
|
||||
NS_ASSERTION(0, "bad type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
|
||||
|
||||
NS_RELEASE(iface_info);
|
||||
|
||||
if(dispatchParams != paramBuffer)
|
||||
delete [] dispatchParams;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef XP_OS2_VACPP
|
||||
|
||||
#define STUB_ENTRY(n)
|
||||
|
||||
#else
|
||||
|
||||
#define STUB_ENTRY(n) \
|
||||
nsresult nsXPTCStubBase::Stub##n() \
|
||||
{ \
|
||||
register nsresult (*method) (nsXPTCStubBase *, PRUint32, PRUint32 *) = PrepareAndDispatch; \
|
||||
int temp0, temp1; \
|
||||
register nsresult result; \
|
||||
__asm__ __volatile__( \
|
||||
"leal 0x0c(%%ebp), %%ecx\n\t" /* args */ \
|
||||
"pushl %%ecx\n\t" \
|
||||
"pushl $"#n"\n\t" /* method index */ \
|
||||
"movl 0x08(%%ebp), %%ecx\n\t" /* this */ \
|
||||
"pushl %%ecx\n\t" \
|
||||
"call *%%edx\n\t" /* PrepareAndDispatch */ \
|
||||
"addl $12, %%esp" \
|
||||
: "=a" (result), /* %0 */ \
|
||||
"=&c" (temp0), /* %1 */ \
|
||||
"=d" (temp1) /* %2 */ \
|
||||
: "2" (method) /* %2 */ \
|
||||
: "memory" ); \
|
||||
return result; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define SENTINEL_ENTRY(n) \
|
||||
nsresult nsXPTCStubBase::Sentinel##n() \
|
||||
{ \
|
||||
NS_ASSERTION(0,"nsXPCWrappedJS::Sentinel called"); \
|
||||
return NS_ERROR_NOT_IMPLEMENTED; \
|
||||
}
|
||||
|
||||
#include "xptcstubsdef.inc"
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user