diff options
author | sb <sb@openoffice.org> | 2010-04-16 16:24:56 +0200 |
---|---|---|
committer | sb <sb@openoffice.org> | 2010-04-16 16:24:56 +0200 |
commit | 462d351e9d4038ebad0fa11c8c77106a3b7bd3c9 (patch) | |
tree | b143066a3f6b261c544712c0a3dbb710e058a99a /jurt/source | |
parent | sb120: merged in backout from cws/sb118 (diff) | |
download | core-462d351e9d4038ebad0fa11c8c77106a3b7bd3c9.tar.gz core-462d351e9d4038ebad0fa11c8c77106a3b7bd3c9.zip |
sb120: #i110944# jpipe.dll wrapper around jpipx.dll
Diffstat (limited to 'jurt/source')
-rw-r--r-- | jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c | 47 | ||||
-rw-r--r-- | jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.h | 53 | ||||
-rw-r--r-- | jurt/source/pipe/jpipe.dxp | 5 | ||||
-rw-r--r-- | jurt/source/pipe/makefile.mk | 96 | ||||
-rw-r--r-- | jurt/source/pipe/wrapper/makefile.mk | 52 | ||||
-rw-r--r-- | jurt/source/pipe/wrapper/wrapper.c | 99 |
6 files changed, 249 insertions, 103 deletions
diff --git a/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c b/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c index 255da24c2f86..4d0a5b357604 100644 --- a/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c +++ b/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c @@ -25,10 +25,20 @@ * ************************************************************************/ +#include "jni.h" #include "osl/security.h" #include <osl/pipe.h> -#include "com_sun_star_lib_connections_pipe_PipeConnection.h" +/* On Windows, jpipe.dll must not have dependencies on any other URE DLLs, as + Java System.LoadLibrary could otherwise not load it. Therefore, on Windows, + this code goes into a jpipx.dll that the jpipe.dll wrapper loads with + LoadLibraryEx(LOAD_WITH_ALTERED_SEARCH_PATH). The function names in this + wrapped code are truncated from the long JNICALL names, as JNICALL causes + some "@N" with different numeric values for N (and probably different across + 32 and 64 bit) to be added to the symbol names, which the calls to + GetProcAddress in wrapper/wrapper.c would otheriwse have to take into + account. +*/ /*****************************************************************************/ /* exception macros */ @@ -100,7 +110,12 @@ static rtl_uString * jstring2ustring(JNIEnv * env, jstring jstr) * Method: connect * Signature: (Lcom/sun/star/beans/NativeService;)V */ -JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_createJNI +SAL_DLLPUBLIC_EXPORT void +#if defined WNT +PipeConnection_create +#else +JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_createJNI +#endif (JNIEnv * env, jobject obj_this, jstring name) { enum { @@ -234,7 +249,12 @@ JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_cre * Method: closeJNI * Signature: ()V */ -JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_closeJNI +SAL_DLLPUBLIC_EXPORT void +#if defined WNT +PipeConnection_close +#else +JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_closeJNI +#endif (JNIEnv * env, jobject obj_this) { enum { @@ -315,7 +335,12 @@ JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_clo * Method: readJNI * Signature: ([[BI)I */ -JNIEXPORT jint JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_readJNI +SAL_DLLPUBLIC_EXPORT jint +#if defined WNT +PipeConnection_read +#else +JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_readJNI +#endif (JNIEnv * env, jobject obj_this, jobjectArray buffer, jint len) { enum { @@ -430,7 +455,12 @@ JNIEXPORT jint JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_rea * Method: writeJNI * Signature: ([B)V */ -JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_writeJNI +SAL_DLLPUBLIC_EXPORT void +#if defined WNT +PipeConnection_write +#else +JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_writeJNI +#endif (JNIEnv * env, jobject obj_this, jbyteArray buffer) { enum { @@ -522,7 +552,12 @@ JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_wri * Method: flushJNI * Signature: ()V */ -JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_flushJNI +SAL_DLLPUBLIC_EXPORT void +#if defined WNT +PipeConnection_flush +#else +JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_flushJNI +#endif (JNIEnv * env, jobject obj_this) { (void) env; /* not used */ diff --git a/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.h b/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.h deleted file mode 100644 index a21e8f979348..000000000000 --- a/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.h +++ /dev/null @@ -1,53 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class com_sun_star_connections_pipe_PipeConnection */ - -#ifndef _Included_com_sun_star_lib_connections_pipe_PipeConnection_h -#define _Included_com_sun_star_lib_connections_pipe_PipeConnection_h -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: com_sun_star_lib_connections_pipe_PipeConnection - * Method: connect - * Signature: (Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_createJNI - (JNIEnv *, jobject, jstring); - -/* - * Class: com_sun_star_lib_connections_pipe_PipeConnection - * Method: readJNI - * Signature: ([[BI)I - */ -JNIEXPORT jint JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_readJNI - (JNIEnv *, jobject, jobjectArray, jint); - -/* - * Class: com_sun_star_lib_connections_pipe_PipeConnection - * Method: writeJNI - * Signature: ([B)V - */ -JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_writeJNI - (JNIEnv *, jobject, jbyteArray); - -/* - * Class: com_sun_star_lib_connections_pipe_PipeConnection - * Method: flushJNI - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_flushJNI - (JNIEnv *, jobject); - -/* - * Class: com_sun_star_lib_connections_pipe_PipeConnection - * Method: closeJNI - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_closeJNI - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/jurt/source/pipe/jpipe.dxp b/jurt/source/pipe/jpipe.dxp deleted file mode 100644 index e07ea907470f..000000000000 --- a/jurt/source/pipe/jpipe.dxp +++ /dev/null @@ -1,5 +0,0 @@ -Java_com_sun_star_lib_connections_pipe_PipeConnection_createJNI -Java_com_sun_star_lib_connections_pipe_PipeConnection_closeJNI -Java_com_sun_star_lib_connections_pipe_PipeConnection_readJNI -Java_com_sun_star_lib_connections_pipe_PipeConnection_writeJNI -Java_com_sun_star_lib_connections_pipe_PipeConnection_flushJNI diff --git a/jurt/source/pipe/makefile.mk b/jurt/source/pipe/makefile.mk index e56ece77f5c1..5be6f1ebfd10 100644 --- a/jurt/source/pipe/makefile.mk +++ b/jurt/source/pipe/makefile.mk @@ -1,39 +1,57 @@ -PRJ=..$/.. - -PRJNAME=jurt -TARGET=jpipe -ENABLE_EXCEPTIONS=TRUE - -#? -NO_DEFAULT_STL=TRUE -NO_BSYMBOLIC=TRUE -USE_DEFFILE=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -.IF "$(SOLAR_JAVA)"=="" -nojava: - @echo "Not building jurt because Java is disabled" -.ENDIF - -# --- Files -------------------------------------------------------- - -SLOFILES = \ - $(SLO)$/com_sun_star_lib_connections_pipe_PipeConnection.obj - -SHL1TARGET=$(TARGET) -SHL1LIBS=$(SLB)$/$(TARGET).lib -SHL1STDLIBS=$(SALLIB) -SHL1DEF=$(MISC)$/$(SHL1TARGET).def -SHL1RPATH=URELIB - -DEF1NAME=$(SHL1TARGET) -DEF1EXPORTFILE=$(TARGET).dxp -DEF1DES=jurtpipe - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#***********************************************************************/ + +PRJ = ../.. +PRJNAME = jurt +TARGET = jpipe + +NO_DEFAULT_STL = TRUE +VISIBILITY_HIDDEN = TRUE + +.INCLUDE: settings.mk + +.IF "$(OS)" == "WNT" +SHL1TARGET = jpipx +.ELSE +SHL1TARGET = jpipe +.END + +SHL1CODETYPE = C +SHL1IMPLIB = i$(SHL1TARGET) +SHL1OBJS = $(SLO)/com_sun_star_lib_connections_pipe_PipeConnection.obj +SHL1RPATH = URELIB +SHL1STDLIBS = $(SALLIB) +SHL1USE_EXPORTS = name +DEF1NAME = $(SHL1TARGET) + +SLOFILES = $(SHL1OBJS) + +.IF "$(SOLAR_JAVA)" == "" +nothing .PHONY : +.END + +.INCLUDE: target.mk diff --git a/jurt/source/pipe/wrapper/makefile.mk b/jurt/source/pipe/wrapper/makefile.mk new file mode 100644 index 000000000000..88a3b160da2e --- /dev/null +++ b/jurt/source/pipe/wrapper/makefile.mk @@ -0,0 +1,52 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#***********************************************************************/ + +PRJ = ../../.. +PRJNAME = jurt +TARGET = wrapper + +NO_DEFAULT_STL = TRUE +UWINAPILIB = +VISIBILITY_HIDDEN = TRUE + +.INCLUDE: settings.mk + +SHL1CODETYPE = C +SHL1IMPLIB = i$(SHL1TARGET) +SHL1OBJS = $(SLO)/wrapper.obj +SHL1RPATH = URELIB +SHL1TARGET = jpipe +SHL1USE_EXPORTS = name +DEF1NAME = $(SHL1TARGET) + +SLOFILES = $(SHL1OBJS) + +.IF "$(SOLAR_JAVA)" == "" +nothing .PHONY : +.END + +.INCLUDE: target.mk diff --git a/jurt/source/pipe/wrapper/wrapper.c b/jurt/source/pipe/wrapper/wrapper.c new file mode 100644 index 000000000000..5ef40f009191 --- /dev/null +++ b/jurt/source/pipe/wrapper/wrapper.c @@ -0,0 +1,99 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include <stddef.h> + +#include <Windows.h> + +#include "jni.h" +#include "sal/types.h" + +static HMODULE module; + +static FARPROC getFunction(char const * name) { + return GetProcAddress(module, name); +} + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { + (void) lpvReserved; + if (fdwReason == DLL_PROCESS_ATTACH) { + wchar_t path[32767]; + DWORD size; + size = GetModuleFileNameW(hinstDLL, path, 32767); + if (size == 0) { + return FALSE; + } + path[size - 5] = L'x'; /* ...\jpipe.dll -> ...\jpipx.dll */ + module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + if (module == NULL) { + return FALSE; + } + } + return TRUE; +} + +SAL_DLLPUBLIC_EXPORT void JNICALL +Java_com_sun_star_lib_connections_pipe_PipeConnection_createJNI( + JNIEnv * env, jobject obj_this, jstring name) +{ + (*(void (*)(JNIEnv *, jobject, jstring)) + getFunction("PipeConnection_create"))(env, obj_this, name); +} + +SAL_DLLPUBLIC_EXPORT void JNICALL +Java_com_sun_star_lib_connections_pipe_PipeConnection_closeJNI( + JNIEnv * env, jobject obj_this) +{ + (*(void (*)(JNIEnv *, jobject)) + getFunction("PipeConnection_close"))(env, obj_this); +} + +SAL_DLLPUBLIC_EXPORT jint JNICALL +Java_com_sun_star_lib_connections_pipe_PipeConnection_readJNI( + JNIEnv * env, jobject obj_this, jobjectArray buffer, jint len) +{ + return (*(jint (*)(JNIEnv *, jobject, jobjectArray, jint)) + getFunction("PipeConnection_read"))(env, obj_this, buffer, len); +} + +SAL_DLLPUBLIC_EXPORT void JNICALL +Java_com_sun_star_lib_connections_pipe_PipeConnection_writeJNI( + JNIEnv * env, jobject obj_this, jbyteArray buffer) +{ + (*(void (*)(JNIEnv *, jobject, jbyteArray)) + getFunction("PipeConnection_write"))(env, obj_this, buffer); +} + +SAL_DLLPUBLIC_EXPORT void JNICALL +Java_com_sun_star_lib_connections_pipe_PipeConnection_flushJNI( + JNIEnv * env, jobject obj_this) +{ + (*(void (*)(JNIEnv *, jobject)) + getFunction("PipeConnection_flush"))(env, obj_this); +} |