Gegeben sei folgende Javaklasse.
package name.panitz.cf;
public class ConnectFour {
private long cRef;
static {
System.loadLibrary("cf");
}
public ConnectFour(){
cRef = newGame();
}
protected void finalize() throws Throwable {
try {
deleteGame(cRef);
} finally {
super.finalize();
}
}
boolean mkMove( int column){return mkMove(cRef,column);}
int mkAIMove(){return mkAIMove(cRef);}
boolean isFinished(){return isFinished(cRef);}
boolean hasWinner(){return hasWinner(cRef);}
byte get(int c,int r){return get(cRef,c,r);}
native private long newGame();
native private void deleteGame(long game);
native private boolean mkMove(long game, int column);
native private int mkAIMove(long game);
native private boolean isFinished(long game);
native private boolean hasWinner(long game);
native private byte get(long game,int c,int r);
native private void printToFile(long game,String fileName);
}
Implementieren Sie in C die nativen Methoden der Klasse.
#include "name_panitz_cf_ConnectFour.h"
#include "CF.h"
#include <stdlib.h>
JNIEXPORT jlong JNICALL Java_name_panitz_cf_ConnectFour_newGame
(JNIEnv * env, jobject o){
}
JNIEXPORT jboolean JNICALL Java_name_panitz_cf_ConnectFour_mkMove
(JNIEnv * env, jobject o, jlong game, jint column){
}
JNIEXPORT jint JNICALL Java_name_panitz_cf_ConnectFour_mkAIMove
(JNIEnv * env, jobject o, jlong game){
}
JNIEXPORT jboolean JNICALL Java_name_panitz_cf_ConnectFour_isFinished
(JNIEnv * env, jobject o , jlong game){
}
JNIEXPORT jboolean JNICALL Java_name_panitz_cf_ConnectFour_hasWinner
(JNIEnv * env , jobject o, jlong game){
}
JNIEXPORT jbyte JNICALL Java_name_panitz_cf_ConnectFour_get
(JNIEnv * env, jobject o, jlong game, jint c, jint r){
}
JNIEXPORT void JNICALL Java_name_panitz_cf_ConnectFour_deleteGame
(JNIEnv * env, jobject o, jlong game){
}
JNIEXPORT void JNICALL Java_name_panitz_cf_ConnectFour_printToFile
(JNIEnv *, jobject, jlong, jstring){
}