/****  Callbacks.java  ************************************************
**
**  This is an example of JNI on the Macintosh it implements the
**  classic "Callbacks" example.
**
**  The problem of mixing the SIOUX console with the MRJ console was
**  describe in the file "HelloWorld.java".  In order to eliminate both
**  the problem of having two consoles as well as having to include the
**  SIOUX environment in the shared library I extended the example to 
**  also use a callback method for printing to the MRJ console.  That
**  method is called "print".
**
**
**  Will Gilbert, Informagen, Inc., 1999
**  Gilbert@Informagen.com
*/

class Callbacks {


	private native void nativeMethod(int depth);
	
	private void callback(int depth) {
	
		if ( depth < 5 ) {	
		
			print("Java", depth , ", about to enter C.");
			                   
			nativeMethod(depth + 1);
		
			print("Java", depth , ", back from C.");
			
		} else 
			System.out.println("In Java, depth = " + depth +
			                    ", limit exceeded.");
			                   	
	}


	private void print(String in, int inDepth, String from) {
	
		System.out.println("In " + in + ", depth = " + inDepth + from);
	}


	public static void main(String[] args) {
	
	
		try {
			System.loadLibrary("Callbacks");
		} catch ( UnsatisfiedLinkError e) {
			System.out.println("Error: " + e.getMessage());
			return;
		}
	
		Callbacks c = new Callbacks();
		c.nativeMethod(0);
		
	}
	

}