|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjni.JNIUtilities
A collection of utilities for generating Java Native Interface (JNI) classes.
For information about JNI, see
http://java.sun.com/docs/books/tutorial/native1.1/concepts/index.html
For information about how to create shared libraries under Windows using
Cygwin, see
http://cygwin.com/cygwin-ug-net/dll.html
For information about using JNI with Cygwin, see
http://www.inonit.com/cygwin/jni/helloWorld/c.html
meaningOfLife()
that returns a double.
meaningOfLife.c that contains
// Return the answer to "the meaning of life, the universe, and everything"
double meaningOfLife() {
return 42.0;
}
meaningOfLife.h that contains
extern "C" double meaningOfLife();
.dll
gcc -shared -o meaningOfLife.dll meaningOfLife.c
CLASSPATH=. export CLASSPATH
$PTII/bin/vergil -jniNote that the
-jni option may go away in the future
if we merge the jni facility into the main tree
Name:
output
C or C++ type:
double
Kind:
return
libraryDirectory
""
nativeFunction:
"meaningOfLife"
nativeLibrary
"meaningOfLife"
cp meaningOfLife.dll $PTII/bin cp jni/jnimeaningOfLife/JnijnimeaningOfLife.dll $PTII/bin
/cygdrive/c/Program Files/j2sdk1.4.1_01/include/win32/jni_md.h:16: syntax error before `;'Then see
http://www.xraylith.wisc.edu/~khan/software/gnu-win32/README.jni.txt
GCC doesn't have a __int64 built-in, and this patch basically uses "long long" instead.
- Edit the file
/include/win32/jni_md.h, Where is the installation root (eg., c:/jdk1.1.7A). - Replace the segment:
typedef long jint; typedef __int64 jlong;with:typedef long jint; #ifdef __GNUC__ typedef long long jlong; #else typedef __int64 jlong; #endif typedef signed char jbyte;
- Since:
- Ptolemy II 2.3
- Version:
- $Id: JNIUtilities.java,v 1.49 2004/04/21 03:04:25 cxh Exp $
- Author:
- Vincent Arnould (vincent.arnould@thalesgroup.com), contributor Christopher Hylands
- Accepted Rating:
Red (vincent.arnould) - Proposed Rating:
Red (vincent.arnould)
Method Summary protected static java.io.File_exportCInterfaceFile(GenericJNIActor actor, java.lang.String destinationDirectory)
Create the JNI C file.protected static void_exportDSP(GenericJNIActor actor, java.lang.String destinationDirectory)
Export the Visual Studio project.protected static java.io.File_exportJavaInterfaceFile(GenericJNIActor actor, java.lang.String destinationDirectory)
Create the JNI Java file.protected static void_exportMakefile(GenericJNIActor actor, java.lang.String destinationDirectory)
Export a makefileprotected static java.util.Vector_getArguments(GenericJNIActor actor, boolean isInput, boolean isOutput, boolean isReturn)
Get the args belonging to this entity.protected static java.lang.String_getArguments(GenericJNIActor actor, boolean isInput, boolean isOutput, boolean isReturn, java.lang.String separator)
Get the args belonging to this entity.protected static java.util.Vector_getArgumentsIn(GenericJNIActor actor)
Get the args In belonging to this entity.protected static java.lang.String_getArgumentsIn(GenericJNIActor actor, java.lang.String separator)
Get the args In name belonging to this entity.protected static java.util.Vector_getArgumentsInOut(GenericJNIActor actor)
Get the args InOut belonging to this entity.protected static java.lang.String_getArgumentsInOut(GenericJNIActor actor, java.lang.String separator)
Get the args InOut belonging to this entity.protected static java.lang.String_getArgumentsInOutWithCType(GenericJNIActor actor, java.lang.String separator)
Get the args In belonging to this entity with their c type.protected static java.lang.String_getArgumentsInOutWithJNIType(GenericJNIActor actor, java.lang.String separator)
Get the args In belonging to this entity with their JNI type, excluding the out arguments.protected static java.lang.String_getArgumentsInOutWithJType(GenericJNIActor actor, java.lang.String separator)
Get the args Out belonging to this entity with their java type.protected static java.lang.String_getArgumentsInWithCType(GenericJNIActor actor, java.lang.String separator)
Get the args In belonging to this entity with their c type.protected static java.lang.String_getArgumentsInWithJNIType(GenericJNIActor actor, java.lang.String separator)
Get the args In belonging to this entity with their JNI type, excluding the out arguments.protected static java.lang.String_getArgumentsInWithJType(GenericJNIActor actor, java.lang.String separator)
Get the args In belonging to this entity with their java type.protected static java.util.Vector_getArgumentsOut(GenericJNIActor actor)
Get the args Out belonging to this entity.protected static java.lang.String_getArgumentsOut(GenericJNIActor actor, java.lang.String separator)
Get the args out name belonging to this entity.protected static java.lang.String_getArgumentsOutWithCType(GenericJNIActor actor, java.lang.String separator)
Get the args Out belonging to this entity with their c type.protected static java.lang.String_getArgumentsOutWithJNIType(GenericJNIActor actor, java.lang.String separator)
Get the args In belonging to this entity with their JNI type, excluding the out arguments.protected static java.lang.String_getArgumentsOutWithJType(GenericJNIActor actor, java.lang.String separator)
Get the args Out belonging to this entity with their java type.protected static java.lang.String_getArgumentsWithCType(GenericJNIActor actor, boolean isInput, boolean isOutput, boolean isReturn, java.lang.String separator)
Get the args belonging to this entity with their c type.protected static java.lang.String_getArgumentsWithCTypeCast(GenericJNIActor actor, boolean isInput, boolean isOutput, boolean isReturn, java.lang.String separator)
Get the arguments belonging to this entity with their c type.protected static java.lang.String_getArgumentsWithJNIType(GenericJNIActor actor, boolean isInput, boolean isOutput, boolean isReturn, java.lang.String separator)
Get the arguments In belonging to this entity with their JNI type, excluding the out arguments.protected static java.lang.String_getArgumentsWithJType(GenericJNIActor actor, boolean isInput, boolean isOutput, boolean isReturn, java.lang.String separator)
Get the arguments belonging to this entity with their java type.protected static java.lang.String_signature(java.lang.String typ)
protected static java.lang.String_signatureSendResults(GenericJNIActor actor)
static booleangenerateJNI(CompositeEntity model)
Given a model, generate JNI files for all GenericJNIActors.static voidgenerateJNI(CompositeEntity model, GenericJNIActor actor)
Generate JNI files for one actor in a modelstatic java.lang.StringgetNativeLibrary(GenericJNIActor actor)
Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Method Detail generateJNI
public static boolean generateJNI(CompositeEntity model) throws java.lang.Exception
- Given a model, generate JNI files for all GenericJNIActors.
- Parameters:
model- The model to generate JNI files for any contained GenericJNIActors.- Returns:
- true if a GenericJNIActor was found.
- Throws:
java.lang.Exception- If there was a problem creating the JNI files.
generateJNI
public static void generateJNI(CompositeEntity model, GenericJNIActor actor) throws java.lang.Exception
- Generate JNI files for one actor in a model
- Throws:
java.lang.Exception
getNativeLibrary
public static java.lang.String getNativeLibrary(GenericJNIActor actor) throws IllegalActionException
- Throws:
IllegalActionException
_exportCInterfaceFile
protected static java.io.File _exportCInterfaceFile(GenericJNIActor actor, java.lang.String destinationDirectory) throws IllegalActionException, java.io.IOException
- Create the JNI C file.
- Parameters:
actor- Actor to generate a JNI C file for.destinationDirectory- Directory to create the file in.- Throws:
IllegalActionExceptionjava.io.IOException
_exportDSP
protected static void _exportDSP(GenericJNIActor actor, java.lang.String destinationDirectory) throws IllegalActionException, java.io.IOException
- Export the Visual Studio project.
- Parameters:
actor- Actor to generate a JNI Java file for.destinationDirectory- Directory to create the file in.- Throws:
IllegalActionExceptionjava.io.IOException
_exportJavaInterfaceFile
protected static java.io.File _exportJavaInterfaceFile(GenericJNIActor actor, java.lang.String destinationDirectory) throws IllegalActionException, java.io.IOException
- Create the JNI Java file.
- Parameters:
actor- Actor to generate a JNI Java file for.destinationDirectory- Directory to create the file in.- Throws:
IllegalActionExceptionjava.io.IOException
_exportMakefile
protected static void _exportMakefile(GenericJNIActor actor, java.lang.String destinationDirectory) throws IllegalActionException, java.io.IOException
- Export a makefile
- Parameters:
actor- Actor to generate a makefile fordestinationDirectory- Directory to create the file in.- Throws:
IllegalActionExceptionjava.io.IOException
_getArguments
protected static java.util.Vector _getArguments(GenericJNIActor actor, boolean isInput, boolean isOutput, boolean isReturn)
- Get the args belonging to this entity.
- Returns:
- a vector of in arguments.
_getArguments
protected static java.lang.String _getArguments(GenericJNIActor actor, boolean isInput, boolean isOutput, boolean isReturn, java.lang.String separator)
- Get the args belonging to this entity.
- Returns:
- the name of each in arguments.
_getArgumentsIn
protected static java.util.Vector _getArgumentsIn(GenericJNIActor actor)
- Get the args In belonging to this entity.
- Returns:
- a vector of out arguments, excluding the in arguments.
_getArgumentsIn
protected static java.lang.String _getArgumentsIn(GenericJNIActor actor, java.lang.String separator)
- Get the args In name belonging to this entity.
- Returns:
- the name of the out arguments, excluding the in arguments.
_getArgumentsInOut
protected static java.util.Vector _getArgumentsInOut(GenericJNIActor actor)
- Get the args InOut belonging to this entity.
- Returns:
- a vector of inout arguments.
_getArgumentsInOut
protected static java.lang.String _getArgumentsInOut(GenericJNIActor actor, java.lang.String separator)
- Get the args InOut belonging to this entity.
- Returns:
- a vector of inout arguments.
_getArgumentsInOutWithCType
protected static java.lang.String _getArgumentsInOutWithCType(GenericJNIActor actor, java.lang.String separator)
- Get the args In belonging to this entity with their c type.
- Returns:
- the c type and name of each in arguments.
_getArgumentsInOutWithJNIType
protected static java.lang.String _getArgumentsInOutWithJNIType(GenericJNIActor actor, java.lang.String separator)
- Get the args In belonging to this entity with their JNI type, excluding the out arguments.
- Returns:
- the JNI type and name of each in arguments.
_getArgumentsInOutWithJType
protected static java.lang.String _getArgumentsInOutWithJType(GenericJNIActor actor, java.lang.String separator)
- Get the args Out belonging to this entity with their java type.
- Returns:
- the name and the java type of the out arguments, excluding the in arguments.
_getArgumentsInWithCType
protected static java.lang.String _getArgumentsInWithCType(GenericJNIActor actor, java.lang.String separator)
- Get the args In belonging to this entity with their c type.
- Returns:
- the c type of the out arguments.
_getArgumentsInWithJNIType
protected static java.lang.String _getArgumentsInWithJNIType(GenericJNIActor actor, java.lang.String separator)
- Get the args In belonging to this entity with their JNI type, excluding the out arguments.
- Returns:
- the JNI type and name of each in arguments, excluding the in arguments.
_getArgumentsInWithJType
protected static java.lang.String _getArgumentsInWithJType(GenericJNIActor actor, java.lang.String separator)
- Get the args In belonging to this entity with their java type.
- Returns:
- the name and the java type of the out arguments, excluding the in arguments.
_getArgumentsOut
protected static java.util.Vector _getArgumentsOut(GenericJNIActor actor)
- Get the args Out belonging to this entity.
- Returns:
- a vector of out arguments, excluding the in arguments.
_getArgumentsOut
protected static java.lang.String _getArgumentsOut(GenericJNIActor actor, java.lang.String separator)
- Get the args out name belonging to this entity.
- Returns:
- the name of the out arguments, excluding the in arguments.
_getArgumentsOutWithCType
protected static java.lang.String _getArgumentsOutWithCType(GenericJNIActor actor, java.lang.String separator)
- Get the args Out belonging to this entity with their c type.
- Returns:
- the c type of the out arguments.
_getArgumentsOutWithJNIType
protected static java.lang.String _getArgumentsOutWithJNIType(GenericJNIActor actor, java.lang.String separator)
- Get the args In belonging to this entity with their JNI type, excluding the out arguments.
- Returns:
- the JNI type and name of each in arguments, excluding the in arguments.
_getArgumentsOutWithJType
protected static java.lang.String _getArgumentsOutWithJType(GenericJNIActor actor, java.lang.String separator)
- Get the args Out belonging to this entity with their java type.
- Returns:
- the name and the java type of the out arguments, excluding the in arguments.
_getArgumentsWithCType
protected static java.lang.String _getArgumentsWithCType(GenericJNIActor actor, boolean isInput, boolean isOutput, boolean isReturn, java.lang.String separator)
- Get the args belonging to this entity with their c type.
- Returns:
- the c type and name of each in arguments.
_getArgumentsWithCTypeCast
protected static java.lang.String _getArgumentsWithCTypeCast(GenericJNIActor actor, boolean isInput, boolean isOutput, boolean isReturn, java.lang.String separator)
- Get the arguments belonging to this entity with their c type.
- Returns:
- the c type and name of each in arguments.
_getArgumentsWithJNIType
protected static java.lang.String _getArgumentsWithJNIType(GenericJNIActor actor, boolean isInput, boolean isOutput, boolean isReturn, java.lang.String separator)
- Get the arguments In belonging to this entity with their JNI type, excluding the out arguments.
- Returns:
- the JNI type and name of each in arguments.
_getArgumentsWithJType
protected static java.lang.String _getArgumentsWithJType(GenericJNIActor actor, boolean isInput, boolean isOutput, boolean isReturn, java.lang.String separator)
- Get the arguments belonging to this entity with their java type.
- Returns:
- the java type and name of each in arguments
_signature
protected static java.lang.String _signature(java.lang.String typ)
- Returns:
- the signature of the interface function.
_signatureSendResults
protected static java.lang.String _signatureSendResults(GenericJNIActor actor)
- Returns:
- the signature of the interface function.
Overview Package Class Tree Deprecated Index Help PREV CLASS NEXT CLASS FRAMES NO FRAMES SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD