source: trunk/lang/java/jRpLibrary.cc @ 1723

Last change on this file since 1723 was 1722, checked in by braffert, 12 years ago

Added java bindings

File size: 2.2 KB
Line 
1#include "jRpLibrary.h"
2#include "rappture.h"
3
4// constructor
5JNIEXPORT jlong JNICALL Java_rappture_Library_jRpLibrary
6  (JNIEnv *env, jobject obj, jstring javaPath){
7  const char* nativePath = env->GetStringUTFChars(javaPath, 0);
8  RpLibrary* lib = new RpLibrary(nativePath);
9  env->ReleaseStringUTFChars(javaPath, nativePath);
10  return (jlong)lib;
11}
12
13// Pseudo-destructor
14JNIEXPORT void JNICALL Java_rappture_Library_jRpDeleteLibrary
15  (JNIEnv *env, jobject obj, jlong libPtr){
16  delete (RpLibrary*) libPtr;
17  return;
18}
19
20// getDouble
21JNIEXPORT jdouble JNICALL Java_rappture_Library_jRpGetDouble
22  (JNIEnv *env, jobject obj, jlong libPtr, jstring javaPath){
23  const char* nativePath = env->GetStringUTFChars(javaPath, 0);
24  double retDVal = ((RpLibrary*)libPtr)->getDouble(nativePath);
25  env->ReleaseStringUTFChars(javaPath, nativePath);
26  return (jdouble)retDVal;
27}
28
29// getString
30JNIEXPORT jstring JNICALL Java_rappture_Library_jRpGetString
31  (JNIEnv *env, jobject obj, jlong libPtr, jstring javaPath){
32  const char* nativePath = env->GetStringUTFChars(javaPath, 0);
33  std::string retStr = ((RpLibrary*)libPtr)->getString(nativePath);
34  env->ReleaseStringUTFChars(javaPath, nativePath);
35  return(env->NewStringUTF(retStr.c_str()));
36}
37
38// putDouble
39JNIEXPORT void JNICALL Java_rappture_Library_jRpPutDouble
40  (JNIEnv *env, jobject obj, jlong libPtr, jstring javaPath,
41   jdouble value, jboolean append){
42  const char* nativePath = env->GetStringUTFChars(javaPath, 0);
43  ((RpLibrary*)libPtr)->put(nativePath, value, "", (int)append);
44  env->ReleaseStringUTFChars(javaPath, nativePath);
45}
46
47// put
48JNIEXPORT void JNICALL Java_rappture_Library_jRpPut
49  (JNIEnv *env, jobject obj, jlong libPtr, jstring javaPath, jstring javaValue, jboolean append){
50  const char* nativePath = env->GetStringUTFChars(javaPath, 0);
51  const char* nativeValue = env->GetStringUTFChars(javaValue, 0);
52  ((RpLibrary*)libPtr)->put(nativePath, nativeValue, "", (int)append);
53  env->ReleaseStringUTFChars(javaPath, nativePath);
54  env->ReleaseStringUTFChars(javaValue, nativeValue);
55}
56
57
58// result
59JNIEXPORT void JNICALL Java_rappture_Library_jRpResult
60  (JNIEnv *env, jobject obj, jlong libPtr, jint exitStatus){
61  ((RpLibrary*)libPtr)->result(exitStatus);
62}
63
64
Note: See TracBrowser for help on using the repository browser.