IdeaWin32 sources

This commit is contained in:
Dmitry Avdeev
2010-01-22 13:06:30 +03:00
parent 120060be58
commit bce7f8b69b
10 changed files with 2843 additions and 0 deletions
+128
View File
@@ -0,0 +1,128 @@
#include "stdafx.h"
#include "IdeaWin32.h"
#include "jni_util.h"
#include "windows.h"
jfieldID nameId;
HANDLE FindFileInner(JNIEnv *env, jstring path, LPWIN32_FIND_DATA lpData) {
const jchar* str = env->GetStringChars(path, 0);
HANDLE h = FindFirstFile((LPCWSTR)str, lpData);
env->ReleaseStringChars(path, str);
return h;
}
bool CopyObjectArray(JNIEnv *env, jobjectArray dst, jobjectArray src,
jint count)
{
int i;
for (i=0; i<count; i++) {
jobject p = env->GetObjectArrayElement(src, i);
env->SetObjectArrayElement(dst, i, p);
env->DeleteLocalRef(p);
}
return true;
}
static LONGLONG
fileTimeToInt64 (const FILETIME * time)
{
ULARGE_INTEGER _time;
_time.LowPart = time->dwLowDateTime;
_time.HighPart = time->dwHighDateTime;
return _time.QuadPart;
}
jfieldID nameID;
jfieldID attributesID;
jfieldID timestampID;
jobject CreateFileInfo(JNIEnv *env, LPWIN32_FIND_DATA lpData, jclass cls) {
jobject o = env->AllocObject(cls);
if (o == NULL) {
return NULL;
}
jstring fileName = env->NewString((jchar*)lpData->cFileName, (jsize)wcslen(lpData->cFileName));
if (fileName == NULL) {
return NULL;
}
env->SetObjectField(o, nameID, fileName);
env->SetIntField(o, attributesID, lpData->dwFileAttributes);
env->SetLongField(o, timestampID, fileTimeToInt64(&lpData->ftLastWriteTime));
return o;
}
JNIEXPORT void JNICALL Java_com_intellij_openapi_vfs_impl_win32_FileInfo_initIDs(JNIEnv *env, jclass cls) {
nameID = env->GetFieldID(cls, "name", "Ljava/lang/String;");
attributesID = env->GetFieldID(cls, "attributes", "I");
timestampID = env->GetFieldID(cls, "timestamp", "J");
}
JNIEXPORT jobject JNICALL Java_com_intellij_openapi_vfs_impl_win32_IdeaWin32_getInfo(JNIEnv *env, jobject method, jstring path) {
WIN32_FIND_DATA data;
HANDLE h = FindFileInner(env, path, &data);
if (h == INVALID_HANDLE_VALUE) {
return NULL;
}
FindClose(h);
jclass infoClass = env->FindClass("com/intellij/openapi/vfs/impl/win32/FileInfo");
return CreateFileInfo(env, &data, infoClass);
}
JNIEXPORT jobjectArray JNICALL Java_com_intellij_openapi_vfs_impl_win32_IdeaWin32_listChildren(JNIEnv *env, jobject method, jstring path)
{
WIN32_FIND_DATA data;
HANDLE h = FindFileInner(env, path, &data);
if (h == INVALID_HANDLE_VALUE) {
return NULL;
}
jobjectArray rv, old;
int len, maxlen;
len = 0;
maxlen = 16;
jclass infoClass = env->FindClass("com/intellij/openapi/vfs/impl/win32/FileInfo");
rv = env->NewObjectArray(maxlen, infoClass, NULL);
if (rv == NULL) goto error;
do {
if (len == maxlen) {
old = rv;
rv = env->NewObjectArray(maxlen <<= 1,
infoClass, NULL);
if (rv == NULL) goto error;
if (!CopyObjectArray(env, rv, old, len)) goto error;
env->DeleteLocalRef(old);
}
jobject o = CreateFileInfo(env, &data, infoClass);
env->SetObjectArrayElement(rv, len++, o);
env->DeleteLocalRef(o);
}
while (FindNextFile(h, &data));
FindClose(h);
old = rv;
rv = env->NewObjectArray(len, infoClass, NULL);
if (rv == NULL) goto error;
if (!CopyObjectArray(env, rv, old, len)) goto error;
return rv;
error:
FindClose(h);
return NULL;
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
+15
View File
@@ -0,0 +1,15 @@
#include "jni.h"
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void JNICALL Java_com_intellij_openapi_vfs_impl_win32_FileInfo_initIDs(JNIEnv *env, jclass cls);
JNIEXPORT jobject JNICALL Java_com_intellij_openapi_vfs_impl_win32_IdeaWin32_getInfo(JNIEnv *env, jobject method, jstring path);
JNIEXPORT jobjectArray JNICALL Java_com_intellij_openapi_vfs_impl_win32_IdeaWin32_listChildren(JNIEnv *env, jobject method, jstring path);
#ifdef __cplusplus
}
#endif
+230
View File
@@ -0,0 +1,230 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="IdeaWin32"
ProjectGUID="{D1A0CC4B-C100-46E4-918A-958626AE1ACF}"
RootNamespace="IdeaWin32"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;IDEAWIN32_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
DisableLanguageExtensions="false"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IDEAWIN32_EXPORTS"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\IdeaWin32.cpp"
>
</File>
<File
RelativePath=".\IdeaWin32.h"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\stdafx.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
+31
View File
@@ -0,0 +1,31 @@
/*
* Copyright 1997 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#ifndef _JLONG_H_
#define _JLONG_H_
#include "jlong_md.h"
#endif
+93
View File
@@ -0,0 +1,93 @@
/*
* Copyright 1997-2002 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#ifndef _WIN32_JLONG_MD_H_
#define _WIN32_JLONG_MD_H_
/* Make sure ptrdiff_t is defined */
#include <stddef.h>
#define jlong_high(a) ((jint)((a)>>32))
#define jlong_low(a) ((jint)(a))
#define jlong_add(a, b) ((a) + (b))
#define jlong_and(a, b) ((a) & (b))
#define jlong_div(a, b) ((a) / (b))
#define jlong_mul(a, b) ((a) * (b))
#define jlong_neg(a) (-(a))
#define jlong_not(a) (~(a))
#define jlong_or(a, b) ((a) | (b))
#define jlong_shl(a, n) ((a) << (n))
#define jlong_shr(a, n) ((a) >> (n))
#define jlong_sub(a, b) ((a) - (b))
#define jlong_xor(a, b) ((a) ^ (b))
#define jlong_rem(a,b) ((a) % (b))
/* comparison operators */
#define jlong_ltz(ll) ((ll) < 0)
#define jlong_gez(ll) ((ll) >= 0)
#define jlong_gtz(ll) ((ll) > 0)
#define jlong_eqz(a) ((a) == 0)
#define jlong_eq(a, b) ((a) == (b))
#define jlong_ne(a,b) ((a) != (b))
#define jlong_ge(a,b) ((a) >= (b))
#define jlong_le(a,b) ((a) <= (b))
#define jlong_lt(a,b) ((a) < (b))
#define jlong_gt(a,b) ((a) > (b))
#define jlong_zero ((jlong) 0)
#define jlong_one ((jlong) 1)
#define jlong_minus_one ((jlong) -1)
/* For static variables initialized to zero */
#define jlong_zero_init ((jlong) 0)
#ifdef _WIN64
#define jlong_to_ptr(a) ((void*)(a))
#define ptr_to_jlong(a) ((jlong)(a))
#else
/* Double casting to avoid warning messages looking for casting of */
/* smaller sizes into pointers */
#define jlong_to_ptr(a) ((void*)(int)(a))
#define ptr_to_jlong(a) ((jlong)(int)(a))
#endif
#define jint_to_jlong(a) ((jlong)(a))
#define jlong_to_jint(a) ((jint)(a))
/* Useful on machines where jlong and jdouble have different endianness. */
#define jlong_to_jdouble_bits(a)
#define jdouble_to_jlong_bits(a)
#define jlong_to_int(a) ((int)(a))
#define int_to_jlong(a) ((jlong)(a))
#define jlong_to_uint(a) ((unsigned int)(a))
#define uint_to_jlong(a) ((jlong)(a))
#define jlong_to_ptrdiff(a) ((ptrdiff_t)(a))
#define ptrdiff_to_jlong(a) ((jlong)(a))
#define jlong_to_size(a) ((size_t)(a))
#define size_to_jlong(a) ((jlong)(a))
#define long_to_jlong(a) ((jlong)(a))
#endif
File diff suppressed because it is too large Load Diff
+19
View File
@@ -0,0 +1,19 @@
/*
* @(#)jni_md.h 1.15 05/11/17
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. 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_ */
+347
View File
@@ -0,0 +1,347 @@
/*
* Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#ifndef JNI_UTIL_H
#define JNI_UTIL_H
#include "jni.h"
#include "jlong.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* This file contains utility functions that can be implemented in pure JNI.
*
* Caution: Callers of functions declared in this file should be
* particularly aware of the fact that these functions are convenience
* functions, and as such are often compound operations, each one of
* which may throw an exception. Therefore, the functions this file
* will often return silently if an exception has occured, and callers
* must check for exception themselves.
*/
/* Throw a Java exception by name. Similar to SignalError. */
JNIEXPORT void JNICALL
JNU_ThrowByName(JNIEnv *env, const char *name, const char *msg);
/* Throw common exceptions */
JNIEXPORT void JNICALL
JNU_ThrowNullPointerException(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowArrayIndexOutOfBoundsException(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowOutOfMemoryError(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowIllegalArgumentException(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowIllegalAccessError(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowIllegalAccessException(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowInternalError(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowIOException(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowNoSuchFieldException(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowNoSuchMethodException(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowClassNotFoundException(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowNumberFormatException(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowNoSuchFieldError(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowNoSuchMethodError(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowStringIndexOutOfBoundsException(JNIEnv *env, const char *msg);
JNIEXPORT void JNICALL
JNU_ThrowInstantiationException(JNIEnv *env, const char *msg);
/* Throw an exception by name, using the string returned by
* JVM_LastErrorString for the detail string. If the last-error
* string is NULL, use the given default detail string.
*/
JNIEXPORT void JNICALL
JNU_ThrowByNameWithLastError(JNIEnv *env, const char *name,
const char *defaultMessage);
/* Throw an IOException, using the last-error string for the detail
* string. If the last-error string is NULL, use the given default
* detail string.
*/
JNIEXPORT void JNICALL
JNU_ThrowIOExceptionWithLastError(JNIEnv *env, const char *defaultDetail);
/* Convert between Java strings and i18n C strings */
JNIEXPORT jstring
NewStringPlatform(JNIEnv *env, const char *str);
JNIEXPORT const char *
GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
JNIEXPORT jstring JNICALL
JNU_NewStringPlatform(JNIEnv *env, const char *str);
JNIEXPORT const char * JNICALL
JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
JNIEXPORT void JNICALL
JNU_ReleaseStringPlatformChars(JNIEnv *env, jstring jstr, const char *str);
/* Class constants */
JNIEXPORT jclass JNICALL
JNU_ClassString(JNIEnv *env);
JNIEXPORT jclass JNICALL
JNU_ClassClass(JNIEnv *env);
JNIEXPORT jclass JNICALL
JNU_ClassObject(JNIEnv *env);
JNIEXPORT jclass JNICALL
JNU_ClassThrowable(JNIEnv *env);
/* Copy count number of arguments from src to dst. Array bounds
* and ArrayStoreException are checked.
*/
JNIEXPORT jint JNICALL
JNU_CopyObjectArray(JNIEnv *env, jobjectArray dst, jobjectArray src,
jint count);
/* Invoke a object-returning static method, based on class name,
* method name, and signature string.
*
* The caller should check for exceptions by setting hasException
* argument. If the caller is not interested in whether an exception
* has occurred, pass in NULL.
*/
JNIEXPORT jvalue JNICALL
JNU_CallStaticMethodByName(JNIEnv *env,
jboolean *hasException,
const char *class_name,
const char *name,
const char *signature,
...);
/* Invoke an instance method by name.
*/
JNIEXPORT jvalue JNICALL
JNU_CallMethodByName(JNIEnv *env,
jboolean *hasException,
jobject obj,
const char *name,
const char *signature,
...);
JNIEXPORT jvalue JNICALL
JNU_CallMethodByNameV(JNIEnv *env,
jboolean *hasException,
jobject obj,
const char *name,
const char *signature,
va_list args);
/* Construct a new object of class, specifying the class by name,
* and specififying which constructor to run and what arguments to
* pass to it.
*
* The method will return an initialized instance if successful.
* It will return NULL if an error has occured (for example if
* it ran out of memory) and the appropriate Java exception will
* have been thrown.
*/
JNIEXPORT jobject JNICALL
JNU_NewObjectByName(JNIEnv *env, const char *class_name,
const char *constructor_sig, ...);
/* returns:
* 0: object is not an instance of the class named by classname.
* 1: object is an instance of the class named by classname.
* -1: the class named by classname cannot be found. An exception
* has been thrown.
*/
JNIEXPORT jint JNICALL
JNU_IsInstanceOfByName(JNIEnv *env, jobject object, char *classname);
/* Get or set class and instance fields.
* Note that set functions take a variable number of arguments,
* but only one argument of the appropriate type can be passed.
* For example, to set an integer field i to 100:
*
* JNU_SetFieldByName(env, &exc, obj, "i", "I", 100);
*
* To set a float field f to 12.3:
*
* JNU_SetFieldByName(env, &exc, obj, "f", "F", 12.3);
*
* The caller should check for exceptions by setting hasException
* argument. If the caller is not interested in whether an exception
* has occurred, pass in NULL.
*/
JNIEXPORT jvalue JNICALL
JNU_GetFieldByName(JNIEnv *env,
jboolean *hasException,
jobject obj,
const char *name,
const char *sig);
JNIEXPORT void JNICALL
JNU_SetFieldByName(JNIEnv *env,
jboolean *hasException,
jobject obj,
const char *name,
const char *sig,
...);
JNIEXPORT jvalue JNICALL
JNU_GetStaticFieldByName(JNIEnv *env,
jboolean *hasException,
const char *classname,
const char *name,
const char *sig);
JNIEXPORT void JNICALL
JNU_SetStaticFieldByName(JNIEnv *env,
jboolean *hasException,
const char *classname,
const char *name,
const char *sig,
...);
/*
* Calls the .equals method.
*/
JNIEXPORT jboolean JNICALL
JNU_Equals(JNIEnv *env, jobject object1, jobject object2);
/************************************************************************
* Thread calls
*
* Convenience thread-related calls on the java.lang.Object class.
*/
JNIEXPORT void JNICALL
JNU_MonitorWait(JNIEnv *env, jobject object, jlong timeout);
JNIEXPORT void JNICALL
JNU_Notify(JNIEnv *env, jobject object);
JNIEXPORT void JNICALL
JNU_NotifyAll(JNIEnv *env, jobject object);
/************************************************************************
* Miscellaneous utilities used by the class libraries
*/
#define IS_NULL(obj) ((obj) == NULL)
#define JNU_IsNull(env,obj) ((obj) == NULL)
/************************************************************************
* Debugging utilities
*/
JNIEXPORT void JNICALL
JNU_PrintString(JNIEnv *env, char *hdr, jstring string);
JNIEXPORT void JNICALL
JNU_PrintClass(JNIEnv *env, char *hdr, jobject object);
JNIEXPORT jstring JNICALL
JNU_ToString(JNIEnv *env, jobject object);
/*
* Package shorthand for use by native libraries
*/
#define JNU_JAVAPKG "java/lang/"
#define JNU_JAVAIOPKG "java/io/"
#define JNU_JAVANETPKG "java/net/"
/*
* Check if the current thread is attached to the VM, and returns
* the JNIEnv of the specified version if the thread is attached.
*
* If the current thread is not attached, this function returns 0.
*
* If the current thread is attached, this function returns the
* JNI environment, or returns (void *)JNI_ERR if the specified
* version is not supported.
*/
JNIEXPORT void * JNICALL
JNU_GetEnv(JavaVM *vm, jint version);
/*
* Warning free access to pointers stored in Java long fields.
*/
#define JNU_GetLongFieldAsPtr(env,obj,id) \
(jlong_to_ptr((*(env))->GetLongField((env),(obj),(id))))
#define JNU_SetLongFieldFromPtr(env,obj,id,val) \
(*(env))->SetLongField((env),(obj),(id),ptr_to_jlong(val))
/*
* Internal use only.
*/
enum {
NO_ENCODING_YET = 0, /* "sun.jnu.encoding" not yet set */
NO_FAST_ENCODING, /* Platform encoding is not fast */
FAST_8859_1, /* ISO-8859-1 */
FAST_CP1252, /* MS-DOS Cp1252 */
FAST_646_US /* US-ASCII : ISO646-US */
};
jstring nativeNewStringPlatform(JNIEnv *env, const char *str);
char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
int getFastEncoding();
void initializeEncoding();
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* JNI_UTIL_H */
+8
View File
@@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// IdeaWin32.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
+28
View File
@@ -0,0 +1,28 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows XP or later.
#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
#endif
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>