Mercurial > hg > audiodb
changeset 722:56e97aa9d0ae
Switched over to using build.xml - much simpler, and keeps generated code separate.
author | mas01mj |
---|---|
date | Wed, 14 Jul 2010 15:54:58 +0000 |
parents | 70542745f473 |
children | ca11b72f92b6 |
files | bindings/java/AudioDB.h bindings/java/AudioDB.java bindings/java/AudioDB_Mode.h bindings/java/build.xml bindings/java/ext/libAudioDB_JNI.c bindings/java/lib/cpptasks.jar bindings/java/libAudioDB_JNI.c bindings/java/src/org/omras2/AudioDB.java |
diffstat | 8 files changed, 143 insertions(+), 155 deletions(-) [+] |
line wrap: on
line diff
--- a/bindings/java/AudioDB.h Fri Jul 02 11:23:26 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class AudioDB */ - -#ifndef _Included_AudioDB -#define _Included_AudioDB -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: AudioDB - * Method: audiodb_create - * Signature: (Ljava/lang/String;III)Z - */ -JNIEXPORT jboolean JNICALL Java_AudioDB_audiodb_1create - (JNIEnv *, jobject, jstring, jint, jint, jint); - -/* - * Class: AudioDB - * Method: audiodb_open - * Signature: (Ljava/lang/String;LAudioDB/Mode;)Z - */ -JNIEXPORT jboolean JNICALL Java_AudioDB_audiodb_1open - (JNIEnv *, jobject, jstring, jobject); - -/* - * Class: AudioDB - * Method: insert - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_AudioDB_insert - (JNIEnv *, jobject); - -/* - * Class: AudioDB - * Method: query - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_AudioDB_query - (JNIEnv *, jobject); - -/* - * Class: AudioDB - * Method: status - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_AudioDB_status - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif
--- a/bindings/java/AudioDB.java Fri Jul 02 11:23:26 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -import java.io.File; - -public class AudioDB -{ - public native boolean audiodb_create(String path, int datasize, int ntracks, int datadim); - public native boolean audiodb_open(String path, Mode mode); - - public native void insert(); - public native void query(); - public native void status(); - - public enum Mode { O_RDONLY, O_RDRW } - - private File path; - - public AudioDB(File path) - { - this.path = path; - } - - public boolean create(int datasize, int ntracks, int datadim) - { - return audiodb_create(path.toString(), datasize, ntracks, datadim); - } - - public boolean open(Mode mode) - { - return audiodb_open(path.toString(), mode); - } - - static { - System.loadLibrary("AudioDB_JNI"); - } - - - public static void main(String args[]) - { - AudioDB testDB = new AudioDB(new File("test.adb")); - testDB.create(5, 5, 12); - testDB.open(Mode.O_RDRW); - } -} - -
--- a/bindings/java/AudioDB_Mode.h Fri Jul 02 11:23:26 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class AudioDB_Mode */ - -#ifndef _Included_AudioDB_Mode -#define _Included_AudioDB_Mode -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __cplusplus -} -#endif -#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bindings/java/build.xml Wed Jul 14 15:54:58 2010 +0000 @@ -0,0 +1,45 @@ +<project name="AudioDB" default="dist" basedir="." xmlns:cpptasks="antlib:net.sf.antcontrib.cpptasks"> + <cpptasks:cc /> + <cpptasks:compiler /> + <cpptasks:linker /> + + <property name="src" location="src" /> + <property name="ext" location="ext" /> + <property name="gen" location="gen" /> + <property name="build" location="build" /> + <property name="dist" location="dist" /> + + <target name="init"> + <tstamp /> + <mkdir dir="${build}" /> + <mkdir dir="${gen}" /> + </target> + + <target name="compile" depends="init"> + <javac srcdir="${src}" destdir="${build}"/> + <javah destdir="${gen}" force="yes" classpath="${build}"> + <class name="org.omras2.AudioDB" /> + </javah> + <cpptasks:cc link="shared" outtype="shared" objdir="${build}" outfile="${build}/AudioDB_JNI"> + <compilerarg value="-shared" /> + <compilerarg value="-fPIC" /> + <compilerarg value="-g" /> + <linker name="ld"> + <linkerarg value="-fPIC" /> + <linkerarg value="-G" /> + <linkerarg value="-laudioDB" /> + <linkerarg value="-o AudioDB_JNI.so" /> + </linker> + <fileset dir="${ext}" includes="libAudioDB_JNI.c" /> + <includepath> + <path path="${os.JAVA_HOME}/include" /> + <path path="${os.JAVA_HOME}/include/linux/" /> + <path path="/usr/local/include/" /> + <path path="${gen}" /> + </includepath> + </cpptasks:cc> + <!--ld -fPIC -G $(OBJS) -laudioDB -o $@ + CFLAGS += -shared -fPIC -g -I$(JDK)/include -I$(JDK)/include/linux -I/usr/local/include/ --> + </target> +</project> +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bindings/java/ext/libAudioDB_JNI.c Wed Jul 14 15:54:58 2010 +0000 @@ -0,0 +1,45 @@ +#include "org_omras2_AudioDB.h" +#include "org_omras2_AudioDB_Mode.h" +#include <jni.h> +#include "audioDB_API.h" + + +JNIEXPORT jboolean JNICALL Java_org_omras2_AudioDB_audiodb_1create (JNIEnv *env, jobject obj, jstring path, jint datasize, jint ntracks, jint datadim) +{ + char buf[256]; + const char *str; + str = (*env)->GetStringUTFChars(env, path, NULL); + if (str == NULL) + return; + + adb_t *handle; + handle = audiodb_create(str, datasize, ntracks, datadim); + if(!handle) + return JNI_FALSE; + + (*env)->ReleaseStringUTFChars(env, path, str); + return JNI_TRUE; +} + +JNIEXPORT jboolean JNICALL Java_org_omras2_AudioDB_audiodb_1open (JNIEnv *env, jobject obj, jstring path, jobject mode) +{ + jclass modeClass = (*env)->FindClass(env, "org/omras2/AudioDB$Mode"); + jmethodID getNameMethod = (*env)->GetMethodID(env, modeClass, "name", "()Ljava/lang/String;"); + jstring value = (jstring)(*env)->CallObjectMethod(env, mode, getNameMethod); + const char* openMode = (*env)->GetStringUTFChars(env, value, 0); + + return JNI_TRUE; +} + +JNIEXPORT void JNICALL Java_org_omras2_AudioDB_insert(JNIEnv *env, jobject obj) +{ +} + +JNIEXPORT void JNICALL Java_org_omras2_AudioDB_query(JNIEnv *env, jobject obj) +{ +} + +JNIEXPORT void JNICALL Java_org_omras2_AudioDB_audiodb_1status(JNIEnv *env, jobject obj) +{ +} +
--- a/bindings/java/libAudioDB_JNI.c Fri Jul 02 11:23:26 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -#include "AudioDB.h" - -#include <jni.h> -#include "audioDB_API.h" - - -JNIEXPORT jboolean JNICALL Java_AudioDB_audiodb_1create (JNIEnv *env, jobject obj, jstring path, jint datasize, jint ntracks, jint datadim) -{ - char buf[256]; - const char *str; - str = (*env)->GetStringUTFChars(env, path, NULL); - if (str == NULL) - return; - - adb_t *handle; - handle = audiodb_create(str, datasize, ntracks, datadim); - if(!handle) - return JNI_FALSE; - - (*env)->ReleaseStringUTFChars(env, path, str); - return JNI_TRUE; -} - -JNIEXPORT jboolean JNICALL Java_AudioDB_audiodb_1open (JNIEnv *env, jobject obj, jstring path, jobject mode) -{ - jclass modeClass = (*env)->FindClass(env, "AudioDB$Mode"); - jmethodID getNameMethod = (*env)->GetMethodID(env, modeClass, "name", "()Ljava/lang/String;"); - jstring value = (jstring)(*env)->CallObjectMethod(env, mode, getNameMethod); - const char* openMode = (*env)->GetStringUTFChars(env, value, 0); - - return JNI_TRUE; -} - -JNIEXPORT void JNICALL Java_AudioDB_insert(JNIEnv *env, jobject obj) -{ -} - -JNIEXPORT void JNICALL Java_AudioDB_query(JNIEnv *env, jobject obj) -{ -} - -JNIEXPORT void JNICALL Java_AudioDB_status(JNIEnv *env, jobject obj) -{ -} -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bindings/java/src/org/omras2/AudioDB.java Wed Jul 14 15:54:58 2010 +0000 @@ -0,0 +1,53 @@ +package org.omras2; + +import java.io.File; + +public class AudioDB +{ + public native boolean audiodb_create(String path, int datasize, int ntracks, int datadim); + public native boolean audiodb_open(String path, Mode mode); + public native void audiodb_status(); + + public native void insert(); + public native void query(); + public native void status(); + + public enum Mode { O_RDONLY, O_RDRW } + + private File path; + + public AudioDB(File path) + { + this.path = path; + } + + public boolean create(int datasize, int ntracks, int datadim) + { + return audiodb_create(path.toString(), datasize, ntracks, datadim); + } + + public boolean open(Mode mode) + { + return audiodb_open(path.toString(), mode); + } + + public void getStatus() + { + audiodb_status(); + } + + static { + System.loadLibrary("AudioDB_JNI"); + } + + + public static void main(String args[]) + { + AudioDB testDB = new AudioDB(new File("test.adb")); + testDB.create(5, 5, 12); + testDB.open(Mode.O_RDRW); +// testDB.getStatus(); + } +} + +