Changeset 1749 for trunk/lang/java


Ignore:
Timestamp:
Jun 7, 2010 11:16:27 AM (10 years ago)
Author:
braffert
Message:

added getData to java bindings

Location:
trunk/lang/java
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lang/java/Library.java

    r1748 r1749  
    3737
    3838  // Public Methods------------------------------------------------------------
     39 
     40  public byte[] getData(String path){
     41    return jRpGetData(libPtr, path);
     42  }
     43
    3944  public double getDouble(String path){
    4045    return jRpGetDouble(libPtr, path);
     
    9297  private native void jRpDeleteLibrary(long libPtr);
    9398
     99  private native byte[] jRpGetData(long libPtr, String path);
    94100  private native double jRpGetDouble(long libPtr, String path);
    95101  private native String jRpGetString(long libPtr, String path);
  • trunk/lang/java/jRpLibrary.cc

    r1748 r1749  
    3838  return;
    3939}
     40
     41// getData
     42JNIEXPORT jbyteArray JNICALL Java_rappture_Library_jRpGetData
     43  (JNIEnv *env, jobject obj, jlong libPtr, jstring javaPath){
     44  const char* nativePath = env->GetStringUTFChars(javaPath, 0);
     45  Rappture::Buffer buf = ((RpLibrary*)libPtr)->getData(nativePath);
     46  size_t size = buf.size();
     47  _jbyteArray* jbuf = env->NewByteArray(size);
     48  env->SetByteArrayRegion(jbuf, 0, size, (const jbyte*)buf.bytes());
     49  env->ReleaseStringUTFChars(javaPath, nativePath);
     50  return jbuf;
     51}
     52
    4053
    4154// getDouble
     
    8295  const char* nativePath = env->GetStringUTFChars(javaPath, 0);
    8396  jbyte* b = env->GetByteArrayElements(jb, NULL);
    84   ((RpLibrary*)libPtr)->putData(nativePath, (const char*)b, nbytes, append);
     97  ((RpLibrary*)libPtr)->putData(nativePath, (const char*)b,
     98                                nbytes, (int)append);
    8599  env->ReleaseByteArrayElements(jb, b, 0);
    86100  env->ReleaseStringUTFChars(javaPath, nativePath);
     
    93107  const char* nativePath = env->GetStringUTFChars(javaPath, 0);
    94108  const char* nativeFileName = env->GetStringUTFChars(javaFileName, 0);
    95   ((RpLibrary*)libPtr)->putFile(nativePath, nativeFileName, compress, append);
     109  ((RpLibrary*)libPtr)->putFile(nativePath, nativeFileName,
     110                                (int)compress, (int)append);
    96111  env->ReleaseStringUTFChars(javaPath, nativePath);
    97112  env->ReleaseStringUTFChars(javaFileName, nativeFileName);
Note: See TracChangeset for help on using the changeset viewer.