New.
This commit is contained in:
rogerl%netscape.com 1999-04-08 16:54:17 +00:00
Родитель b89b6e5681
Коммит 20c87baa91
4 изменённых файлов: 408 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,114 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* Platform specific code to invoke XPCOM methods on native objects */
#include "xptcprivate.h"
#ifndef MAC
#error "This code is for Macintosh only"
#endif
extern "C" uint32
invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
{
PRUint32 result = 0;
for(PRUint32 i = 0; i < paramCount; i++, s++)
{
if(s->IsPtrData())
{
result++;
continue;
}
switch(s->type)
{
case nsXPTType::T_I8 :
case nsXPTType::T_I16 :
case nsXPTType::T_I32 :
result++;
break;
case nsXPTType::T_I64 :
result+=2;
break;
case nsXPTType::T_U8 :
case nsXPTType::T_U16 :
case nsXPTType::T_U32 :
result++;
break;
case nsXPTType::T_U64 :
result+=2;
break;
case nsXPTType::T_FLOAT :
result++;
break;
case nsXPTType::T_DOUBLE :
result+=2;
break;
case nsXPTType::T_BOOL :
case nsXPTType::T_CHAR :
case nsXPTType::T_WCHAR :
result++;
break;
default:
// all the others are plain pointer types
result++;
break;
}
}
return result;
}
extern "C" void
invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s, double *fprData)
{
PRUint32 fpCount = 0;
for(PRUint32 i = 0; i < paramCount; i++, d++, s++)
{
if(s->IsPtrData())
{
*((void**)d) = s->ptr;
continue;
}
switch(s->type)
{
case nsXPTType::T_I8 : *((PRInt8*) d) = s->val.i8; break;
case nsXPTType::T_I16 : *((PRInt16*) d) = s->val.i16; break;
case nsXPTType::T_I32 : *((PRInt32*) d) = s->val.i32; break;
case nsXPTType::T_I64 : *((PRInt64*) d) = s->val.i64; d++; break;
case nsXPTType::T_U8 : *((PRUint8*) d) = s->val.u8; break;
case nsXPTType::T_U16 : *((PRUint16*)d) = s->val.u16; break;
case nsXPTType::T_U32 : *((PRUint32*)d) = s->val.u32; break;
case nsXPTType::T_U64 : *((PRUint64*)d) = s->val.u64; d++; break;
case nsXPTType::T_FLOAT : *((float*) d) = s->val.f;
if (fpCount < 13)
fprData[fpCount++] = s->val.f;
break;
case nsXPTType::T_DOUBLE : *((double*) d) = s->val.d; d++;
if (fpCount < 13)
fprData[fpCount++] = s->val.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;
}
}
}

Просмотреть файл

@ -0,0 +1,90 @@
csect CODE{PR}
#
# XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
# PRUint32 paramCount, nsXPTCVariant* params)
#
import .invoke_count_words
import .invoke_copy_to_stack
import .__ptr_glue
.XPTC_InvokeByIndex:
mflr r0
stw r31,-4(sp)
#
# save off the incoming values in the caller's parameter area
#
stw r3,24(sp) # that
stw r4,28(sp) # methodIndex
stw r5,32(sp) # paramCount
stw r6,36(sp) # params
stw r0,8(sp)
stwu sp,-136(sp) # = 24 for linkage area, 8 * 13 for fprData area, 8 for saved registers
# set up for and call 'invoke_count_words' to get new stack size
#
mr r3,r5
bl .invoke_count_words
nop
# prepare args for 'invoke_copy_to_stack' call
#
lwz r4,168(sp) # paramCount
lwz r5,172(sp) # params
addi r6,sp,128 # fprData
slwi r3,r3,2 # number of bytes of stack required
mr r31,sp # save original stack top
sub sp,sp,r3 # bump the stack
addi r3,sp,28 # parameter pointer excludes linkage area size + 'this'
bl .invoke_copy_to_stack
nop
lfd f1,128(r31)
lfd f2,120(r31)
lfd f3,112(r31)
lfd f4,104(r31)
lfd f5,96(r31)
lfd f6,88(r31)
lfd f7,80(r31)
lfd f8,72(r31)
lfd f9,64(r31)
lfd f10,56(r31)
lfd f11,48(r31)
lfd f12,40(r31)
lfd f13,32(r31)
lwz r3,160(r31) # that
lwz r4,0(r3) # get vTable from 'that'
lwz r5,164(r31) # methodIndex
slwi r5,r5,2 # methodIndex * 4
addi r5,r5,8 # step over junk at start of vTable !
lwzx r12,r5,r4 # get function pointer
lwz r4,28(sp)
lwz r5,32(sp)
lwz r6,36(sp)
lwz r7,40(sp)
lwz r8,44(sp)
lwz r9,48(sp)
lwz r10,52(sp)
bl .__ptr_glue
nop
mr sp,r31
lwz r0,144(sp)
addi sp,sp,136
mtlr r0
lwz r31,-4(sp)
blr
csect DATA
import TOC
export .XPTC_InvokeByIndex
dc.l .XPTC_InvokeByIndex
dc.l TOC

Просмотреть файл

@ -0,0 +1,114 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* Platform specific code to invoke XPCOM methods on native objects */
#include "xptcprivate.h"
#ifndef MAC
#error "This code is for Macintosh only"
#endif
extern "C" uint32
invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
{
PRUint32 result = 0;
for(PRUint32 i = 0; i < paramCount; i++, s++)
{
if(s->IsPtrData())
{
result++;
continue;
}
switch(s->type)
{
case nsXPTType::T_I8 :
case nsXPTType::T_I16 :
case nsXPTType::T_I32 :
result++;
break;
case nsXPTType::T_I64 :
result+=2;
break;
case nsXPTType::T_U8 :
case nsXPTType::T_U16 :
case nsXPTType::T_U32 :
result++;
break;
case nsXPTType::T_U64 :
result+=2;
break;
case nsXPTType::T_FLOAT :
result++;
break;
case nsXPTType::T_DOUBLE :
result+=2;
break;
case nsXPTType::T_BOOL :
case nsXPTType::T_CHAR :
case nsXPTType::T_WCHAR :
result++;
break;
default:
// all the others are plain pointer types
result++;
break;
}
}
return result;
}
extern "C" void
invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s, double *fprData)
{
PRUint32 fpCount = 0;
for(PRUint32 i = 0; i < paramCount; i++, d++, s++)
{
if(s->IsPtrData())
{
*((void**)d) = s->ptr;
continue;
}
switch(s->type)
{
case nsXPTType::T_I8 : *((PRInt8*) d) = s->val.i8; break;
case nsXPTType::T_I16 : *((PRInt16*) d) = s->val.i16; break;
case nsXPTType::T_I32 : *((PRInt32*) d) = s->val.i32; break;
case nsXPTType::T_I64 : *((PRInt64*) d) = s->val.i64; d++; break;
case nsXPTType::T_U8 : *((PRUint8*) d) = s->val.u8; break;
case nsXPTType::T_U16 : *((PRUint16*)d) = s->val.u16; break;
case nsXPTType::T_U32 : *((PRUint32*)d) = s->val.u32; break;
case nsXPTType::T_U64 : *((PRUint64*)d) = s->val.u64; d++; break;
case nsXPTType::T_FLOAT : *((float*) d) = s->val.f;
if (fpCount < 13)
fprData[fpCount++] = s->val.f;
break;
case nsXPTType::T_DOUBLE : *((double*) d) = s->val.d; d++;
if (fpCount < 13)
fprData[fpCount++] = s->val.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;
}
}
}

Просмотреть файл

@ -0,0 +1,90 @@
csect CODE{PR}
#
# XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
# PRUint32 paramCount, nsXPTCVariant* params)
#
import .invoke_count_words
import .invoke_copy_to_stack
import .__ptr_glue
.XPTC_InvokeByIndex:
mflr r0
stw r31,-4(sp)
#
# save off the incoming values in the caller's parameter area
#
stw r3,24(sp) # that
stw r4,28(sp) # methodIndex
stw r5,32(sp) # paramCount
stw r6,36(sp) # params
stw r0,8(sp)
stwu sp,-136(sp) # = 24 for linkage area, 8 * 13 for fprData area, 8 for saved registers
# set up for and call 'invoke_count_words' to get new stack size
#
mr r3,r5
bl .invoke_count_words
nop
# prepare args for 'invoke_copy_to_stack' call
#
lwz r4,168(sp) # paramCount
lwz r5,172(sp) # params
addi r6,sp,128 # fprData
slwi r3,r3,2 # number of bytes of stack required
mr r31,sp # save original stack top
sub sp,sp,r3 # bump the stack
addi r3,sp,28 # parameter pointer excludes linkage area size + 'this'
bl .invoke_copy_to_stack
nop
lfd f1,128(r31)
lfd f2,120(r31)
lfd f3,112(r31)
lfd f4,104(r31)
lfd f5,96(r31)
lfd f6,88(r31)
lfd f7,80(r31)
lfd f8,72(r31)
lfd f9,64(r31)
lfd f10,56(r31)
lfd f11,48(r31)
lfd f12,40(r31)
lfd f13,32(r31)
lwz r3,160(r31) # that
lwz r4,0(r3) # get vTable from 'that'
lwz r5,164(r31) # methodIndex
slwi r5,r5,2 # methodIndex * 4
addi r5,r5,8 # step over junk at start of vTable !
lwzx r12,r5,r4 # get function pointer
lwz r4,28(sp)
lwz r5,32(sp)
lwz r6,36(sp)
lwz r7,40(sp)
lwz r8,44(sp)
lwz r9,48(sp)
lwz r10,52(sp)
bl .__ptr_glue
nop
mr sp,r31
lwz r0,144(sp)
addi sp,sp,136
mtlr r0
lwz r31,-4(sp)
blr
csect DATA
import TOC
export .XPTC_InvokeByIndex
dc.l .XPTC_InvokeByIndex
dc.l TOC