Main Page Cookbook/Overview ImageMeister the jcprops file Licensing Please Vote! Binary Installation & Configuration [ Win · Mac · Nix ] Changes Public API Source Code Main Page Java [ Common · Win · Mac · Nix ] Native Code [ Common · Win · Mac · Nix ] Manifest Native Code Overviews [ Common · Win · Mac · Nix · Strings ] Macros [ General · Native Macros ] Walkthroughs [ Java only · Java and native ] Building [ Win · Mac · Nix ] Distribution Issues

# Native Macros

This file describes the native macros.

This file describes the macros and defines which are used to minimize the differences between the three native architectures supported by JConfig: JNI, JRI, and RNI. Except as noted, these macros are not platform specific.

As an example:

- In JNI, a Java String is represented in native code using the jstring type.
- In JRI, a Java String is represented in native code using the JRIStringID type.
- In RNI, a Java String is represented in native code using the struct Hjava_lang_String* type.

However, in the JConfig source code, a Java String is represented in native code using JSTRING, which is defined to be one of those values, depending upon which native architecture the native code is being built for.

These macros are divided into two categories:

- The general macros, which deal with variables in Java format (such as JSTRING), are defined in 'jni_macros.h', 'jri_macros.h', and 'rni_macros.h'. For example, 'jni_macros.h' defines these macros for all platforms which use JNI. These files are in the 'common' folder.
- The stub macros, which deal with method signatures (such as SFUNC), are defined in 'stub_macros.h'. This file is in the 'common' folder, and defines these macros for all platforms and native archtecture (JNI,etc.)

The evaluation of each of these macros depends on several factors:

- the platform
- the native architecture (JNI, JRI, RNI1, or RNI2)
- whether DO_SEH is defined

See macros.html for more information on these defines.

These macros are generally used in two places: in the stub files (AppUtilsMSVM.cpp, etc.) and in some of the common files (CStrA.cpp, etc.)

## General Macros

    JSTRING
    JINT
    JBYTEARRAY
    JINTARRAY
    JLONGARRAY
    JOBJECTARRAY
    	java's basic types

    CHECKNULL(a)
    	if 'a' is null, sets 'theErr' and jumps to 'bail'

    CHECKSIZE( a, b )
    	if the array 'a' is null, or has less than 'b' elements, sets 'theErr' and jumps to 'bail'

    SETINTARRAYREGION(a,b,c,d)
    SETLONGARRAYREGION(a,b,c,d)
    	sets elements of the array 'a' from the buffer 'd'
    	'b' is the start index of 'a'
    	'c' is the number of elements to set

    GETBYTEARRAYLEN(a)
    GETINTARRAYLEN(a)
    GETOBJECTARRAYLEN(a)
    	returns the length of 'a'

    LOCKBYTEARRAY(a)
    LOCKINTARRAY(a)
    	returns a pointer to the elements of the 'a' array.
    	Must be followed by a call to the corresponding
    	'UNLOCK...' routine

    UNLOCKBYTEARRAY(a,b)
    UNLOCKINTARRAY(a,b)
    	call these after calling the 'LOCK...' routines.
    	a is the Java array
    	b is the value returned from the 'LOCK...' routine
    	NOTE: don't change 'b' itself, only what it points to:
    		b = LOCK...(a);
    		++b;		//	BAD
    		UNLOCK...(a,b)

    GETSTRARRAYELEMENT( a, b )
    GETOBJECTARRAYELEMENT( a, b )
    	'a' is an object array
    	returns the object/JSTRING at index 'b'

    SETSTRARRAYELEMENT(a,b,c)
    SETOBJECTARRAYELEMENT( a, b, c )
    	'a' is an object array
    	'b' is the index to set
    	'c' is the object/JSTRING to put at 'b'

    SETJINT1(a,b)
    SETJINT2(a,b,c)
    SETJINT4(a,b,c,d,e)
    GETJINT2(a,b,c)
    SETJLONG1(a,b)
    SETJLONG2(a,b,c)
    	'a' is a JINT or JLONG array
    	the remaining arguments will be stored starting at index 0 in this array
    	for example, SETJINT2( jintArray, xx, yy ) will store xx at jintArray[ 0 ] and yy at jintArray[ 1 ]

## Stub Macros

    EXP
    FUNC(pkg,clz,mth)
    SFUNC(pkg,clz,mth)
    	represents the header of each native stub. 'SFUNC' is used if the native routine is
    	declared in Java as a static method, 'FUNC' otherwise.

    SEH_EXP
    SEH_FUNC(pkg,clz,mth)
    SEH_SFUNC(pkg,clz,mth)
    SEH_TRY
    SEH_EXCEPT(a)
    CALL_INNER(a)
    INNER_PREFIX
    	used only on Windows, these allow each native stub to be wrapped by an SEH handler.

Main Page · JConfig · ImageMeister · System Properties Repository · WordMeister · Free Samples · Java Freeware · Contact Us · FAQ · Links

Copyright (c) 1997,1998,1999,2000 Samizdat Productions. All Rights Reserved.
WarpMovie, TileMovie, JConfig, ImageMeister and MovieShredder are Trademarks of Samizdat Productions.