зеркало из https://github.com/mozilla/gecko-dev.git
r=ashuk
a=edburns bug=32011 This change enables the current webclient API to be called from native code. It adds makefile and conditional compilation logic. If the user defines BAL_INTERFACE in their environment before building webclient, -DBAL_INTERFACE is added to LCFLAGS. This causes code in jni_util_export.cpp to behave differently due to the conditional compilation logic. I've broken out the 8 functions that are necessary to call into the Webclient JNI methods into jni_util_export.{h,cpp}. I've created a new pair of files, bal_util.{h,cpp} that contain function declarations and definitions that are used when src_moz is built with BAL_INTERFACE. bal_util.obj is not built, nor added to webclient.dll if building without BAL_INTERFACE. See the page http://www.mozilla.org/projects/blackwood/webclient/design/uno-transition.html for a design document description of these changes.
This commit is contained in:
Родитель
c49fc801bc
Коммит
aa3d2d50d7
|
@ -37,13 +37,20 @@ DEPTH = ..\..
|
|||
|
||||
!if defined(WEBCLIENT_SPEC)
|
||||
DIRS = classes_spec \
|
||||
src_moz
|
||||
src_moz \
|
||||
$(NULL)
|
||||
!else
|
||||
DIRS = classes \
|
||||
src
|
||||
$(NULL)
|
||||
!endif
|
||||
|
||||
|
||||
!if defined(BAL_INTERFACE)
|
||||
DIRS = classes_spec \
|
||||
src_moz \
|
||||
bal_test \
|
||||
$(NULL)
|
||||
!endif
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
This directory contains the redefined jni.h for using webclient without
|
||||
using java. This directory should only be refferenced when building the
|
||||
code in ../src_moz with BAL_INTERFACE=1.
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* @(#)jni_md.h 1.11 00/02/02
|
||||
*
|
||||
* Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* This software is the proprietary information of Sun Microsystems, Inc.
|
||||
* Use is subject to license terms.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _JAVASOFT_JNI_MD_H_
|
||||
#define _JAVASOFT_JNI_MD_H_
|
||||
|
||||
#define JNIEXPORT __declspec(dllexport)
|
||||
#define JNIIMPORT __declspec(dllimport)
|
||||
#define JNICALL __stdcall
|
||||
|
||||
typedef long jint;
|
||||
typedef __int64 jlong;
|
||||
typedef signed char jbyte;
|
||||
|
||||
#endif /* !_JAVASOFT_JNI_MD_H_ */
|
|
@ -0,0 +1,62 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
|
||||
|
||||
DEFINES=-DWIN32_LEAN_AND_MEAN
|
||||
MODULE=bal_test
|
||||
|
||||
CPPSRCS= \
|
||||
bal_test.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\bal_test.obj \
|
||||
$(NULL)
|
||||
|
||||
MAKE_OBJ_TYPE = EXE
|
||||
PROGRAM = .\$(OBJDIR)\bal_test.exe
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
LLIBS = \
|
||||
$(DIST)\lib\webclient.lib \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
INCS = \
|
||||
-I..\src_moz \
|
||||
-I..\bal \
|
||||
-I..\bal\win32 \
|
||||
$(NULL)
|
||||
|
||||
install:: $(PROGRAM)
|
||||
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\mozilla.exe
|
|
@ -0,0 +1,57 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "WrapperFactoryImpl.h"
|
||||
|
||||
#include "jni_util_export.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
jstring result = NULL;
|
||||
jboolean doesImplement;
|
||||
|
||||
if (2 > argc) {
|
||||
printf("usage: bal_test <absolute path to mozilla bin dir>\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = util_NewStringUTF(NULL, argv[1]);
|
||||
|
||||
Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeAppInitialize(NULL, NULL, result);
|
||||
|
||||
util_DeleteStringUTF(NULL, result);
|
||||
|
||||
result = util_NewStringUTF(NULL, "webclient.WindowControl");
|
||||
|
||||
doesImplement =
|
||||
Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeDoesImplement(NULL, NULL, result);
|
||||
|
||||
printf("doesImplement: %d\n", doesImplement);
|
||||
|
||||
util_DeleteStringUTF(NULL, result);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -30,6 +30,7 @@ MODULE=webclient
|
|||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\jni_util.obj \
|
||||
.\$(OBJDIR)\jni_util_export.obj \
|
||||
.\$(OBJDIR)\rdf_util.obj \
|
||||
.\$(OBJDIR)\nsActions.obj \
|
||||
.\$(OBJDIR)\BookmarksImpl.obj \
|
||||
|
@ -47,16 +48,25 @@ OBJS = \
|
|||
.\$(OBJDIR)\nsSetupRegistry.obj \
|
||||
$(NULL)
|
||||
|
||||
INCS = \
|
||||
-I$(JDKHOME)\include \
|
||||
-I$(JDKHOME)\include\win32 \
|
||||
$(INCS) \
|
||||
!ifdef BAL_INTERFACE
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\bal_util.obj \
|
||||
$(OBJS) \
|
||||
$(NULL)
|
||||
!endif
|
||||
|
||||
|
||||
LCFLAGS = \
|
||||
-DDEBUG_RAPTOR_CANVAS \
|
||||
$(NULL)
|
||||
|
||||
!ifdef BAL_INTERFACE
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
-DBAL_INTERFACE \
|
||||
$(NULL)
|
||||
!endif
|
||||
|
||||
LLIBS = \
|
||||
$(DIST)\lib\gkweb.lib \
|
||||
$(DIST)\lib\raptorbasewidget_s.lib \
|
||||
|
@ -76,6 +86,21 @@ include <$(DEPTH)\config\rules.mak>
|
|||
|
||||
include <$(DEPTH)\java\config\localdefs.mak>
|
||||
|
||||
!ifdef BAL_INTERFACE
|
||||
INCS = \
|
||||
-I..\bal\ \
|
||||
-I..\bal\win32 \
|
||||
$(INCS) \
|
||||
$(NULL)
|
||||
!else
|
||||
INCS = \
|
||||
-I$(JDKHOME)\include \
|
||||
-I$(JDKHOME)\include\win32 \
|
||||
$(INCS) \
|
||||
$(NULL)
|
||||
!endif
|
||||
|
||||
|
||||
!CMDSWITCHES -S
|
||||
|
||||
# generate the jni header
|
||||
|
@ -125,12 +150,15 @@ nsSetupRegistry.cpp:
|
|||
copy $(MOZ_SRC)\mozilla\xpfe\bootstrap\nsSetupRegistry.cpp
|
||||
|
||||
buildRunems:
|
||||
!ifdef BAL_INTERFACE
|
||||
!else
|
||||
@echo +++ Creating $(MOZ_SRC)\mozilla\java\webclient\src\$(OBJDIR)\runem.bat. Use this to run the test browser.
|
||||
@echo set PATH=$(MOZ_SRC)\mozilla\dist\$(OBJDIR)\bin;$(PATH) > .\$(OBJDIR)\runem.bat
|
||||
@echo $(JAVA) -Djava.library.path=$(MOZ_SRC)\mozilla\dist\$(OBJDIR)\bin -classpath $(JAVAC_CLASSPATH) org.mozilla.webclient.test.EmbeddedMozilla $(MOZ_SRC)\mozilla\dist\$(OBJDIR)\bin %1% >> .\$(OBJDIR)\runem.bat
|
||||
@echo +++ Creating $(MOZ_SRC)\mozilla\java\webclient\src\$(OBJDIR)\swingem.bat. Use this to run the swing based test browser.
|
||||
@echo set PATH=$(MOZ_SRC)\mozilla\dist\$(OBJDIR)\bin;$(PATH) > .\$(OBJDIR)\swingem.bat
|
||||
@echo $(JAVA) -Djava.library.path=$(MOZ_SRC)\mozilla\dist\$(OBJDIR)\bin -classpath $(JAVAC_CLASSPATH) org.mozilla.webclient.test.swing.SwingEmbeddedMozilla $(MOZ_SRC)\mozilla\dist\$(OBJDIR)\bin %1% >> .\$(OBJDIR)\swingem.bat
|
||||
!endif
|
||||
|
||||
install:: $(DLL) buildRunems
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* Implementation for bal_util functions.
|
||||
|
||||
*/
|
||||
|
||||
#include "malloc.h"
|
||||
#include "string.h"
|
||||
|
||||
#include "bal_util.h"
|
||||
|
||||
void JNICALL bal_jstring_newFromAscii(jstring *newStr, const char *value)
|
||||
{
|
||||
jint length;
|
||||
jint i;
|
||||
jstring p;
|
||||
|
||||
if (bnull == newStr) {
|
||||
return;
|
||||
}
|
||||
|
||||
length = bal_str_getLength(value);
|
||||
|
||||
*newStr = (jstring)bal_allocateMemory(sizeof(jchar) +
|
||||
(length * sizeof(jchar)));
|
||||
|
||||
if (!(*newStr)) return;
|
||||
|
||||
p = *newStr;
|
||||
for (i = 0; i < length; i++) {
|
||||
/* Check ASCII range */
|
||||
// OSL_ENSHURE( (*value & 0x80) == 0, "Found ASCII char > 127");
|
||||
|
||||
*(p++) = (jchar)*(value++);
|
||||
}
|
||||
*p = 0;
|
||||
}
|
||||
|
||||
void JNICALL bal_str_newFromJstring(char **newStr, const jstring inValue)
|
||||
{
|
||||
jint length;
|
||||
jint i;
|
||||
char *p;
|
||||
jstring value = inValue;
|
||||
|
||||
if (bnull == newStr) {
|
||||
return;
|
||||
}
|
||||
|
||||
length = bal_jstring_getLength(value);
|
||||
|
||||
*newStr = (char *)bal_allocateMemory(sizeof(char *) +
|
||||
(length * sizeof(char *)));
|
||||
|
||||
if (!(*newStr)) return;
|
||||
|
||||
p = *newStr;
|
||||
for (i = 0; i < length; i++) {
|
||||
/* Check ASCII range */
|
||||
// OSL_ENSHURE( (*value & 0x80) == 0, "Found ASCII char > 127");
|
||||
|
||||
*(p++) = (char)*(value++);
|
||||
}
|
||||
*p = 0;
|
||||
}
|
||||
|
||||
jint JNICALL bal_str_getLength(const char *str)
|
||||
{
|
||||
jint result = -1;
|
||||
|
||||
const char * pTempStr = (char *)bal_findInMemory(str, '\0',
|
||||
0x80000000);
|
||||
result = pTempStr - str;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
jint JNICALL bal_jstring_getLength(const jstring str)
|
||||
{
|
||||
jint result = -1;
|
||||
|
||||
const jstring pTempStr = bal_findInJstring(str, '\0');
|
||||
result = pTempStr - str;
|
||||
return result;
|
||||
}
|
||||
|
||||
void JNICALL bal_jstring_release(jstring value)
|
||||
{
|
||||
bal_freeMemory(value);
|
||||
}
|
||||
|
||||
void JNICALL bal_str_release(const char *str)
|
||||
{
|
||||
bal_freeMemory((void *)str);
|
||||
}
|
||||
|
||||
void * JNICALL bal_allocateMemory(jint bytes)
|
||||
{
|
||||
void *result = bnull;
|
||||
|
||||
if (0 < bytes) {
|
||||
result = malloc(bytes);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void JNICALL bal_freeMemory(void *MemA)
|
||||
{
|
||||
free(MemA);
|
||||
MemA = bnull;
|
||||
}
|
||||
|
||||
void * JNICALL bal_findInMemory(const void *MemA,
|
||||
jchar ch,
|
||||
jint bytes)
|
||||
{
|
||||
void *result = bnull;
|
||||
|
||||
result = memchr(MemA, ch, bytes);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
jstring JNICALL bal_findInJstring(const jstring MemA,
|
||||
jchar ch)
|
||||
{
|
||||
jstring result = bnull;
|
||||
|
||||
result = wcschr(MemA, ch);
|
||||
|
||||
return result;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Methods used in the jni_util_export implementation, but not exported
|
||||
* from webclient.dll.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef bal_util_h
|
||||
#define bal_util_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#define bnull 0
|
||||
|
||||
void JNICALL bal_jstring_newFromAscii(jstring *newStr, const char *value);
|
||||
|
||||
jint JNICALL bal_str_getLength(const char *str);
|
||||
|
||||
jint JNICALL bal_jstring_getLength(const jstring str);
|
||||
|
||||
void JNICALL bal_str_newFromJstring(char **newStr, const jstring value);
|
||||
|
||||
void JNICALL bal_jstring_release(jstring value);
|
||||
|
||||
void JNICALL bal_str_release(const char *str);
|
||||
|
||||
void * JNICALL bal_allocateMemory(jint bytes);
|
||||
|
||||
void JNICALL bal_freeMemory(void *MemA);
|
||||
|
||||
void * JNICALL bal_findInMemory(const void *MemA,
|
||||
jchar ch,
|
||||
jint bytes);
|
||||
|
||||
jstring JNICALL bal_findInJstring(const jstring MemA,
|
||||
jchar ch);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // bal_util_h
|
|
@ -165,74 +165,6 @@ void util_DumpJavaStack(JNIEnv *env)
|
|||
}
|
||||
}
|
||||
|
||||
const char * util_GetStringUTFChars(JNIEnv *env, jstring inString)
|
||||
{
|
||||
const char *result = nsnull;
|
||||
|
||||
#ifdef BAL_INTERFACE
|
||||
#else
|
||||
result = (const char *) env->GetStringUTFChars(inString, 0);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void util_ReleaseStringUTFChars(JNIEnv *env, jstring inString,
|
||||
const char *stringFromGet)
|
||||
{
|
||||
|
||||
#ifdef BAL_INTERFACE
|
||||
#else
|
||||
env->ReleaseStringUTFChars(inString, stringFromGet);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
const jchar * util_GetStringChars(JNIEnv *env, jstring inString)
|
||||
{
|
||||
const jchar *result = nsnull;
|
||||
|
||||
#ifdef BAL_INTERFACE
|
||||
#else
|
||||
result = (const jchar *) env->GetStringChars(inString, 0);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void util_ReleaseStringChars(JNIEnv *env, jstring inString,
|
||||
const jchar *stringFromGet)
|
||||
{
|
||||
|
||||
#ifdef BAL_INTERFACE
|
||||
#else
|
||||
env->ReleaseStringChars(inString, stringFromGet);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
jstring util_NewStringUTF(JNIEnv *env, const char *inString)
|
||||
{
|
||||
jstring result;
|
||||
#ifdef BAL_INTERFACE
|
||||
#else
|
||||
result = env->NewStringUTF(inString);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
jstring util_NewString(JNIEnv *env, const jchar *inString, jsize len)
|
||||
{
|
||||
jstring result;
|
||||
#ifdef BAL_INTERFACE
|
||||
#else
|
||||
result = env->NewString(inString, len);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
jobject util_NewGlobalRef(JNIEnv *env, jobject obj)
|
||||
{
|
||||
jobject result = nsnull;
|
||||
|
|
|
@ -148,19 +148,7 @@ void util_DumpJavaStack(JNIEnv *env);
|
|||
// Functions to wrap JNIEnv functions.
|
||||
//
|
||||
|
||||
const char *util_GetStringUTFChars(JNIEnv *env, jstring inString);
|
||||
|
||||
void util_ReleaseStringUTFChars(JNIEnv *env, jstring inString,
|
||||
const char *stringFromGet);
|
||||
|
||||
const jchar *util_GetStringChars(JNIEnv *env, jstring inString);
|
||||
|
||||
void util_ReleaseStringChars(JNIEnv *env, jstring inString,
|
||||
const jchar *stringFromGet);
|
||||
|
||||
jstring util_NewStringUTF(JNIEnv *env, const char * inString);
|
||||
|
||||
jstring util_NewString(JNIEnv *env, const jchar *inString, jsize len);
|
||||
#include "jni_util_export.h"
|
||||
|
||||
jobject util_NewGlobalRef(JNIEnv *env, jobject toAddRef);
|
||||
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "jni_util_export.h"
|
||||
|
||||
#include "bal_util.h"
|
||||
|
||||
#include "nscore.h" // for nsnull
|
||||
|
||||
JNIEXPORT const char * JNICALL util_GetStringUTFChars(JNIEnv *env,
|
||||
jstring inString)
|
||||
{
|
||||
const char *result = nsnull;
|
||||
|
||||
#ifdef BAL_INTERFACE
|
||||
char *nonConstResult;
|
||||
bal_str_newFromJstring(&nonConstResult, inString);
|
||||
result = (const char *)nonConstResult;
|
||||
#else
|
||||
result = (const char *) env->GetStringUTFChars(inString, 0);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL util_ReleaseStringUTFChars(JNIEnv *env,
|
||||
jstring inString,
|
||||
const char *stringFromGet)
|
||||
{
|
||||
|
||||
#ifdef BAL_INTERFACE
|
||||
bal_str_release(stringFromGet);
|
||||
#else
|
||||
env->ReleaseStringUTFChars(inString, stringFromGet);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT const jchar * JNICALL util_GetStringChars(JNIEnv *env,
|
||||
jstring inString)
|
||||
{
|
||||
const jchar *result = nsnull;
|
||||
|
||||
#ifdef BAL_INTERFACE
|
||||
// ASSUMES typedef wchar_t jchar;
|
||||
// ASSUMES typedef wchar_t *jstring;
|
||||
result = (const jchar *) inString;
|
||||
#else
|
||||
result = (const jchar *) env->GetStringChars(inString, 0);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL util_ReleaseStringChars(JNIEnv *env, jstring inString,
|
||||
const jchar *stringFromGet)
|
||||
{
|
||||
|
||||
#ifdef BAL_INTERFACE
|
||||
// NO action necessary, see NewStringChars
|
||||
#else
|
||||
env->ReleaseStringChars(inString, stringFromGet);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL util_NewStringUTF(JNIEnv *env, const char *inString)
|
||||
{
|
||||
jstring result = nsnull;
|
||||
#ifdef BAL_INTERFACE
|
||||
bal_jstring_newFromAscii(&result, inString);
|
||||
#else
|
||||
result = env->NewStringUTF(inString);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL util_DeleteStringUTF(JNIEnv *env, jstring toDelete)
|
||||
{
|
||||
#ifdef BAL_INTERFACE
|
||||
util_DeleteString(env, toDelete);
|
||||
#else
|
||||
printf("This shouldn't get called in a non-BAL context!\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL util_NewString(JNIEnv *env, const jchar *inString,
|
||||
jsize len)
|
||||
{
|
||||
jstring result = nsnull;
|
||||
#ifdef BAL_INTERFACE
|
||||
#else
|
||||
result = env->NewString(inString, len);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL util_DeleteString(JNIEnv *env, jstring toDelete)
|
||||
{
|
||||
#ifdef BAL_INTERFACE
|
||||
bal_jstring_release(toDelete);
|
||||
#else
|
||||
printf("This shouldn't get called in a non-BAL context!\n");
|
||||
#endif
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Exported Util methods, called from webclient uno.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef jni_util_export_h
|
||||
#define jni_util_export_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
|
||||
JNIEXPORT const char * JNICALL util_GetStringUTFChars(JNIEnv *env,
|
||||
jstring inString);
|
||||
|
||||
JNIEXPORT void JNICALL util_ReleaseStringUTFChars(JNIEnv *env,
|
||||
jstring inString,
|
||||
const char *stringFromGet);
|
||||
|
||||
JNIEXPORT const jchar * JNICALL util_GetStringChars(JNIEnv *env,
|
||||
jstring inString);
|
||||
|
||||
JNIEXPORT void JNICALL util_ReleaseStringChars(JNIEnv *env, jstring inString,
|
||||
const jchar *stringFromGet);
|
||||
|
||||
JNIEXPORT jstring JNICALL util_NewStringUTF(JNIEnv *env,
|
||||
const char * inString);
|
||||
|
||||
JNIEXPORT void JNICALL util_DeleteStringUTF(JNIEnv *env, jstring toDelete);
|
||||
|
||||
JNIEXPORT jstring JNICALL util_NewString(JNIEnv *env, const jchar *inString,
|
||||
jsize len);
|
||||
|
||||
JNIEXPORT void JNICALL util_DeleteString(JNIEnv *env, jstring toDelete);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // jni_util_export_h
|
Загрузка…
Ссылка в новой задаче