banishing win32 specific stuff to its own directory before adding any analogous code for other platforms

This commit is contained in:
jband%netscape.com 1999-02-24 07:17:27 +00:00
Родитель 07bc99676f
Коммит d14ed6f506
6 изменённых файлов: 340 добавлений и 4 удалений

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

@ -18,6 +18,8 @@
DEPTH=..\..\..
IGNORE_MANIFEST=1
DIRS=md
MAKE_OBJ_TYPE = DLL
DLLNAME = xpc$(MOZ_BITS)$(VERSION_NUMBER)
#PDBFILE = $(DLLNAME).pdb
@ -28,6 +30,8 @@ DLL =.\$(OBJDIR)\$(DLLNAME).dll
MODULE=xpconnect
REQUIRES=xpcom js
MD_LIBRARY = .\md\win32\$(OBJDIR)\xpcmd.lib
DEFINES=-DWIN32_LEAN_AND_MEAN -DEXPORT_XPC_API -DJS_THREADSAFE -DDEBUG
OBJS= \
@ -37,10 +41,8 @@ OBJS= \
.\$(OBJDIR)\xpcarbitrary.obj \
.\$(OBJDIR)\xpccontext.obj \
.\$(OBJDIR)\xpcconvert.obj \
.\$(OBJDIR)\xpcinvoke.obj \
.\$(OBJDIR)\xpcmaps.obj \
.\$(OBJDIR)\xpcnsid.obj \
.\$(OBJDIR)\xpcstubs.obj \
.\$(OBJDIR)\xpcwrappedjs.obj \
.\$(OBJDIR)\xpcwrappedjsclass.obj \
.\$(OBJDIR)\xpcwrappednative.obj \
@ -62,7 +64,8 @@ LCFLAGS = \
$(DEFINES) \
$(NULL)
LLIBS= $(LIBNSPR) \
LLIBS= $(LIBNSPR) \
$(MD_LIBRARY) \
$(DIST)\lib\js$(MOZ_BITS)$(VERSION_NUMBER).lib \
$(DIST)\lib\xpcom$(MOZ_BITS).lib \
@ -76,7 +79,7 @@ include <$(DEPTH)\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
clobber::
rm -f $(DIST)\lib\$(DLLNAME).lib

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

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

@ -0,0 +1,40 @@
#!nmake
#
# 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.
DEPTH=..\..\..\..\..
IGNORE_MANIFEST=1
include <$(DEPTH)\config\config.mak>
DEFINES=-DWIN32_LEAN_AND_MEAN -DEXPORT_XPC_API -DJS_THREADSAFE -DDEBUG
LINCS=-I..\.. -I$(PUBLIC)\xpcom -I$(PUBLIC)\js -I$(PUBLIC)\raptor \
-I$(PUBLIC)\libxpt
LCFLAGS = \
$(LCFLAGS) \
$(DEFINES) \
$(NULL)
LIBRARY_NAME = xpcmd
OBJS= \
.\$(OBJDIR)\xpcinvoke.obj \
.\$(OBJDIR)\xpcstubs.obj \
$(NULL)
include <$(DEPTH)\config\rules.mak>
install:: $(LIBRARY)

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

@ -0,0 +1,146 @@
/* -*- 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 "xpcprivate.h"
#ifdef WIN32
// Remember that on Win32 these 'words' are 32bit DWORDS
static uint32 __stdcall
invoke_count_words(uint32 paramCount, nsXPCVariant* s)
{
uint32 result = 0;
for(uint32 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;
}
static void __stdcall
invoke_copy_to_stack(uint32* d, uint32 paramCount, nsXPCVariant* s)
{
for(uint32 i = 0; i < paramCount; i++, d++, s++)
{
if(s->IsPtrData())
{
*((void**)d) = s->ptr;
continue;
}
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;
}
}
}
#pragma warning(disable : 4035) // OK to have no return value
nsresult
xpc_InvokeNativeMethod(void* that, PRUint32 index,
uint32 paramCount, nsXPCVariant* params)
{
__asm {
push params
push paramCount
call invoke_count_words // stdcall, result in eax
shl eax,2 // *= 4
sub esp,eax // make space for params
mov edx,esp
push params
push paramCount
push edx
call invoke_copy_to_stack // stdcall
mov ecx,that // instance in ecx
push ecx // push this
mov edx,[ecx] // vtable in edx
mov eax,index
shl eax,2 // *= 4
add edx,eax
call [edx] // stdcall, i.e. callee cleans up stack.
}
}
#pragma warning(default : 4035) // restore default
#ifdef DEBUG
nsresult
XPC_TestInvoke(void* that, PRUint32 index,
uint32 paramCount, nsXPCVariant* params)
{
return xpc_InvokeNativeMethod(that, index, paramCount, params);
}
#endif
#endif

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

@ -0,0 +1,147 @@
/* -*- 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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* Implement shared vtbl methods for WrappedJS. */
#include "xpcprivate.h"
#ifdef WIN32
static nsresult __stdcall
PrepareAndDispatch(nsXPCWrappedJS* self, uint32 methodIndex,
uint32* args, uint32* stackBytesToPop)
{
#define PARAM_BUFFER_COUNT 32
nsXPCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
nsXPCMiniVariant* dispatchParams = NULL;
nsXPCWrappedJSClass* clazz;
nsIInterfaceInfo* iface_info;
const nsXPTMethodInfo* info;
uint8 paramCount;
uint8 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");
clazz = self->GetClass();
NS_ASSERTION(clazz,"no class");
iface_info = clazz->GetInterfaceInfo();
NS_ASSERTION(iface_info,"no interface info");
iface_info->GetMethodInfo(uint16(methodIndex), &info);
NS_ASSERTION(info,"no interface info");
paramCount = info->GetParamCount();
// setup variant array pointer
if(paramCount > PARAM_BUFFER_COUNT)
dispatchParams = new nsXPCMiniVariant[paramCount];
else
dispatchParams = paramBuffer;
NS_ASSERTION(dispatchParams,"no place for params");
uint32* ap = args;
for(i = 0; i < paramCount; i++, ap++)
{
const nsXPTParamInfo& param = info->GetParam(i);
const nsXPTType& type = param.GetType();
nsXPCMiniVariant* dp = &dispatchParams[i];
if(param.IsOut() || !type.IsArithmetic())
{
dp->val.p = (void*) *ap;
continue;
}
// else
switch(type)
{
case nsXPTType::T_I8 : dp->val.i8 = *((int8*) ap); break;
case nsXPTType::T_I16 : dp->val.i16 = *((int16*) ap); break;
case nsXPTType::T_I32 : dp->val.i32 = *((int32*) ap); break;
case nsXPTType::T_I64 : dp->val.i64 = *((int64*) ap); ap++; break;
case nsXPTType::T_U8 : dp->val.u8 = *((uint8*) ap); break;
case nsXPTType::T_U16 : dp->val.u16 = *((uint16*) ap); break;
case nsXPTType::T_U32 : dp->val.u32 = *((uint32*) ap); break;
case nsXPTType::T_U64 : dp->val.u64 = *((uint64*) 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;
}
}
*stackBytesToPop = ((uint32)ap) - ((uint32)args);
result = clazz->CallMethod(self, (uint16)methodIndex, info, dispatchParams);
if(dispatchParams != paramBuffer)
delete [] dispatchParams;
return result;
}
static __declspec(naked) void SharedStub(void)
{
__asm {
push ebp // set up simple stack frame
mov ebp, esp // stack has: ebp/vtbl_index/retaddr/this/args
push ecx // make room for a ptr
lea eax, [ebp-4] // pointer to stackBytesToPop
push eax
lea ebx, [ebp+16] // pointer to args
push ebx
mov edx, [ebp+4] // vtbl_index
push edx
mov eax, [ebp+12] // this
push eax
call PrepareAndDispatch
mov edx, [ebp+8] // return address
mov ecx, [ebp-4] // stackBytesToPop
add ecx, 12 // for this, the index, and ret address
mov esp, ebp
pop ebp
add esp, ecx // fix up stack pointer
jmp edx // simulate __stdcall return
}
}
// these macros get expanded (many times) in the file #included below
#define STUB_ENTRY(n) \
__declspec(naked) nsresult __stdcall nsXPCWrappedJS::Stub##n() \
{ __asm push n __asm jmp SharedStub }
#define SENTINEL_ENTRY(n) \
nsresult __stdcall nsXPCWrappedJS::Sentinel##n() \
{ \
NS_ASSERTION(0,"nsXPCWrappedJS::Sentinel called"); \
return NS_ERROR_NOT_IMPLEMENTED; \
}
#pragma warning(disable : 4035) // OK to have no return value
#include "xpcstubsdef.inc"
#pragma warning(default : 4035) // restore default
#endif

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