added unix makesfiles, fixed two bad static casts, invoke code working on Linux, working on stubs code for Linux

This commit is contained in:
jband%netscape.com 1999-02-25 18:14:51 +00:00
Родитель 5f4ea1bab4
Коммит ff1c1ab2a7
10 изменённых файлов: 387 добавлений и 10 удалений

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

@ -26,23 +26,40 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
DIRS = md
LIBRARY_NAME=xpconnect
MODULE=xpconnect
CFLAGS += -DJSFILE -DEXPORT_XPC_API -DJS_THREADSAFE
CPPSRCS= \
xpt_cpp.cpp \
nsXPConnect.cpp \
xpcarbitrary.cpp \
xpccontext.cpp \
xpcconvert.cpp \
xpcinvoke.cpp \
xpclog.cpp \
xpcmaps.cpp \
xpcnsid.cpp \
xpcstubs.cpp \
xpcwrappedjs.cpp \
xpcwrappedjsclass.cpp \
xpcwrappednative.cpp \
xpcwrappednativeclass.cpp \
$(NULL)
LIBRARY_NAME=xpconnect
EXPORTS = \
nsIXPCScriptable.h \
nsIInterfaceInfo.h \
nsIInterfaceInfoManager.h \
nsIXPConnect.h \
xpclog.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir)
# MD_LIBRARY = md/unix/libxpcmd.a

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

@ -0,0 +1,31 @@
#!gmake
#
# 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=../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
DIRS = unix
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,44 @@
#!gmake
#
# 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=../../../../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
CFLAGS += -DJSFILE -DEXPORT_XPC_API -DJS_THREADSAFE
LIBRARY_NAME = xpcmd
MODULE = xpconnect
ifeq ($(OS_ARCH), Linux)
CPPSRCS= \
xpcinvoke_linux_x86.cpp \
xpcstubs_linux_x86.cpp \
$(NULL)
endif
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir)/../..

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

@ -23,7 +23,7 @@
// Remember that these 'words' are 32bit DWORDS
#if !defined(LINUX)
#error "This code is for Linux x86 only
#error "This code is for Linux x86 only"
#endif
static uint32

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

@ -0,0 +1,212 @@
/* -*- 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"
#if !defined(LINUX)
#error "This code is for Linux x86 only"
#endif
// XXX quick to get it compiling - but not working
#if 0
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
// XXX quick to get it compiling - but not working
nsresult nsXPCWrappedJS::Stub##n() \
{ \
return NS_ERROR_NOT_IMPLEMENTED; \
}
#endif
static nsresult
PrepareAndDispatch(nsXPCWrappedJS* self, uint32 methodIndex, uint32* args)
{
printf("PrepareAndDispatch called with methodIndex = %d\n", (int)methodIndex);
return NS_ERROR_FAILURE;
}
static nsresult SharedStub(void)
{
void* method = PrepareAndDispatch;
nsresult result;
__asm__ __volatile__(
"leal 0x14(%%ebp), %%edx\n\t" /* args */
"pushl %%edx\n\t"
"movl 0x08(%%ebp), %%ecx\n\t" /* vtbl index */
"pushl %%ecx\n\t"
"movl 0x10(%%ebp), %%edx\n\t" /* this */
"pushl %%edx\n\t"
"movl %1, %%eax\n\t" /* PrepareAndDispatch */
"call *%%eax\n\t"
"addl $0x0c, %%esp\n\t"
"movl %%eax, %0"
: "=g" (result) /* %0 */
: "g" (method) /* %1 */
: "ax", "dx", "cx", "memory" );
return result;
}
// these macros get expanded (many times) in the file #included below
#define STUB_ENTRY(n) \
nsresult nsXPCWrappedJS::Stub##n() \
{ \
void* stub = SharedStub; \
__asm__ __volatile__( \
"popl %%ebp\n\t" \
"pushl $"#n"\n\t" \
"call *%%edx\n\t" \
"addl $8, %%esp\n\t" \
"leave\n\t" \
"ret\n\t" \
: \
: "d" (stub) \
: "ax", "memory" ); \
return 0; /* just to avoid warning */ \
}
#define SENTINEL_ENTRY(n) \
nsresult nsXPCWrappedJS::Sentinel##n() \
{ \
NS_ASSERTION(0,"nsXPCWrappedJS::Sentinel called"); \
return NS_ERROR_NOT_IMPLEMENTED; \
}
#include "xpcstubsdef.inc"

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

@ -21,7 +21,7 @@
#include "xpcprivate.h"
#ifndef WIN32
#error "This code is for Win32 only
#error "This code is for Win32 only"
#endif
// Remember that on Win32 these 'words' are 32bit DWORDS

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

@ -21,7 +21,7 @@
#include "xpcprivate.h"
#ifndef WIN32
#error "This code is for Win32 only
#error "This code is for Win32 only"
#endif
static nsresult __stdcall

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

@ -0,0 +1,69 @@
#!gmake
#
# 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 = ../../../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = TestXPC
CPPSRCS = \
TestXPC.cpp \
$(NULL)
include $(topsrcdir)/config/config.mk
CFLAGS += -DJS_THREADSAFE -DJSFILE
LDFLAGS = \
-L$(DIST)/bin \
-ljs \
-lxpcom \
-lxpconnect \
-lxpcmd \
-lreg \
-lmozutil \
$(NSPR_LIBS) \
$(NULL)
PROGS = $(OBJDIR)/TestXPC
TEST_FILES = testxpc.js
TARGETS= $(PROGS)
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(PUBLIC)/xpcom -I$(PUBLIC)/js -I$(PUBLIC)/xpconnect \
-I$(PUBLIC)/raptor -I../../../../xpcom/src
#$(PROGS): $(OBJS)
# @$(MAKE_OBJDIR)
# $(CC) -o $@ $(OBJS) $(LD_FLAGS) -L$(DIST)/lib $(LIBS) $(OS_LIBS)
export:: $(TARGETS)
$(INSTALL) $(PROGS) $(DIST)/bin
$(INSTALL) $(TEST_FILES) $(DIST)/bin
clobber::
rm -f $(DIST)/bin/TestXPC
rm -f $(PROGS) $(OBJS)

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

@ -152,7 +152,8 @@ MyScriptable::MyScriptable()
NS_ADDREF_THIS();
}
NS_IMPL_ISUPPORTS(MyScriptable,NS_IXPCSCRIPTABLE_IID);
static NS_DEFINE_IID(kMyScriptableIID, NS_IXPCSCRIPTABLE_IID);
NS_IMPL_ISUPPORTS(MyScriptable, kMyScriptableIID);
// XPC_IMPLEMENT_FORWARD_IXPCSCRIPTABLE(MyScriptable);
XPC_IMPLEMENT_FORWARD_CREATE(MyScriptable);
@ -297,7 +298,8 @@ private:
nsIAllocator* mAllocator;
};
NS_IMPL_ISUPPORTS(MyEcho, NS_IECHO_IID);
static NS_DEFINE_IID(kMyEchoIID, NS_IECHO_IID);
NS_IMPL_ISUPPORTS(MyEcho, kMyEchoIID);
MyEcho::MyEcho()
: mReciever(NULL)

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

@ -569,7 +569,8 @@ InterfaceInfoImpl::GetMethodInfo(uint16 index, const nsXPTMethodInfo** info)
}
// else...
*info = NS_STATIC_CAST(nsXPTMethodInfo*, &mEntry->interface_descriptor->method_descriptors[index-mMethodBaseIndex]);
*info = NS_REINTERPRET_CAST(nsXPTMethodInfo*,
&mEntry->interface_descriptor->method_descriptors[index-mMethodBaseIndex]);
return NS_OK;
}
@ -589,6 +590,7 @@ InterfaceInfoImpl::GetConstant(uint16 index, const nsXPTConstant** constant)
}
// else...
*constant = NS_STATIC_CAST(nsXPTConstant*,&mEntry->interface_descriptor->const_descriptors[index-mConstantBaseIndex]);
*constant = NS_REINTERPRET_CAST(nsXPTConstant*,
&mEntry->interface_descriptor->const_descriptors[index-mConstantBaseIndex]);
return NS_OK;
}