Changeset 1824 for branches


Ignore:
Timestamp:
Jul 14, 2010, 8:04:01 PM (14 years ago)
Author:
gah
Message:
 
Location:
branches/blt4
Files:
10 added
17 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/examples/app-fermi/Makefile.in

    r1744 r1824  
    2323MEX =           @MEX@
    2424MKOCTFILE =     @MKOCTFILE@
    25 JAVA =          @JAVA@
     25JAVA_HOME =     @JAVA_HOME@
    2626
    2727.PHONY: tcl cee fortran octave matlab perl python ruby java 2.0 wrapper
     
    4646    LANGS += ruby
    4747endif
    48 ifneq ($(JAVA),)
     48ifneq ($(JAVA_HOME),)
    4949    LANGS += java
    5050endif
  • branches/blt4/examples/zoo/binary/tardir.tcl

    r702 r1824  
    2121close $fid
    2222
    23 catch {exec tar tvzf $file} dir
     23set status [catch {exec tar tvzf $file} result]
    2424file delete -force $file
    2525
     26if {$status != 0} {
     27    puts stderr "ERROR: $result"
     28    exit 1
     29}
     30
    2631$driver put output.string(dir).about.label "Contents"
    27 $driver put output.string(dir).current $dir
     32$driver put output.string(dir).current $result
    2833
    2934$driver put output.string(tarball).about.label "Original Tar File"
  • branches/blt4/examples/zoo/binary/tool.xml

    r684 r1824  
    1919      <description>Upload a gzipped tar file (Unix-style archive file).</description>
    2020    </about>
    21     <size>60x10</size>
     21    <size>binary</size>
    2222    <default></default>
    2323  </string>
  • branches/blt4/examples/zoo/image/tool.xml

    r1587 r1824  
    2323  </loader>
    2424  <image>
    25     <about><diffs>ignore</diffs></about>
     25    <about>
     26      <label>Image</label>
     27      <description>Input image that gets rotated.</description>
     28      <diffs>ignore</diffs>
     29    </about>
     30    <convert>bmp</convert>
    2631  </image>
    2732  <number id="angle">
  • branches/blt4/lang/Makefile.in

    r1744 r1824  
    2121MEX             = @MEX@
    2222MKOCTFILE       = @MKOCTFILE@
    23 JAVA            = @JAVA@
     23JAVA_HOME       = @JAVA_HOME@
    2424
    2525# Rappture requires it. We always build a Tcl language API.
     
    4141  LANGS += octave
    4242endif
    43 ifneq ($(JAVA),)
     43ifneq ($(JAVA_HOME),)
    4444  LANGS += java
    4545endif
  • branches/blt4/lang/java/Library.java

    r1744 r1824  
    2727  }
    2828
     29  public Library(){
     30    libPtr = jRpLibrary(null);
     31  }
     32
    2933  // Pseudo-Destructor.  Called when the object is garbage collected.----------
    3034  protected void finalize() throws Throwable {
     
    3741
    3842  // Public Methods------------------------------------------------------------
     43 
     44  public byte[] getData(String path){
     45    return jRpGetData(libPtr, path);
     46  }
     47
    3948  public double getDouble(String path){
    4049    return jRpGetDouble(libPtr, path);
     
    4352  public String getString(String path){
    4453    return jRpGetString(libPtr, path);
     54  }
     55
     56  public int getInt(String path){
     57    return jRpGetInt(libPtr, path);
    4558  }
    4659
     
    5871  }
    5972
     73  public void putData(String path, byte[] b, boolean append){
     74    jRpPutData(libPtr, path, b, b.length, append);
     75  }
     76
     77  public void putData(String path, byte[] b){
     78    jRpPutData(libPtr, path, b, b.length, false);
     79  }
     80
     81  public void putFile(String path, String fileName,
     82                      boolean compress, boolean append){
     83    jRpPutFile(libPtr, path, fileName, compress, append);
     84  }
     85
     86  public void putFile(String path, String fileName, boolean compress){
     87    jRpPutFile(libPtr, path, fileName, compress, false);
     88  }
     89
     90  public void putFile(String path, String fileName){
     91    jRpPutFile(libPtr, path, fileName, true, false);
     92  }
     93
    6094  public void result(int exitStatus){
    6195    jRpResult(libPtr, exitStatus);
     
    71105  private native void jRpDeleteLibrary(long libPtr);
    72106
     107  private native byte[] jRpGetData(long libPtr, String path);
    73108  private native double jRpGetDouble(long libPtr, String path);
     109  private native int jRpGetInt(long libPtr, String path);
    74110  private native String jRpGetString(long libPtr, String path);
    75111
    76112  private native void jRpPut(long libPtr, String path,
    77113                             String value, boolean append);
     114  private native void jRpPutData(long libPtr, String path,
     115                                 byte[] b, int nbytes, boolean append);
     116  private native void jRpPutFile(long libPtr, String path, String fileName,
     117                                 boolean compress, boolean append);
    78118
    79119  private native void jRpResult(long libPtr, int exitStatus); 
  • branches/blt4/lang/java/Units.java

    r1744 r1824  
    2727  }
    2828
     29  public static String convert(String fromVal, String to){
     30    return jRpUnitsConvert(fromVal, to, true);
     31  }
     32
    2933  private static native String jRpUnitsConvert(String fromVal, String to, boolean units);
    3034}
  • branches/blt4/lang/java/jRpLibrary.cc

    r1744 r1824  
    1 /*
    2  * ======================================================================
     1/* * ======================================================================
    32 *  AUTHOR:  Ben Rafferty, Purdue University
    43 *  Copyright (c) 2010  Purdue Research Foundation
     
    1817
    1918/*
    20  * Constructor.  Returns the address of the newly created RpLibrary object to
     19 * Constructor.  Creates a C++ RpLibrary object and returns its address to
    2120 * java as a long int.
    2221 */
    2322JNIEXPORT jlong JNICALL Java_rappture_Library_jRpLibrary
    2423  (JNIEnv *env, jobject obj, jstring javaPath){
    25   const char* nativePath = env->GetStringUTFChars(javaPath, 0);
    26   RpLibrary* lib = new RpLibrary(nativePath);
    27   env->ReleaseStringUTFChars(javaPath, nativePath);
     24  RpLibrary* lib = NULL;
     25  const char* nativePath;
     26  jclass ex;
     27 
     28  if (javaPath == NULL){
     29    lib = new RpLibrary();
     30  }
     31  else{
     32    nativePath = env->GetStringUTFChars(javaPath, 0);
     33    lib = new RpLibrary(nativePath);
     34    env->ReleaseStringUTFChars(javaPath, nativePath);
     35  }
     36
     37  if (lib == NULL){
     38    ex = env->FindClass("java/lang/NullPointerException");
     39    if (ex){
     40      env->ThrowNew(ex, "Could not create rappture library.");
     41    }
     42    env->DeleteLocalRef(ex);
     43  }
     44
    2845  return (jlong)lib;
    2946}
    3047
    3148/*
    32  * Pseudo-destructor.  This function is called by the java Library class's
    33  * finalizer.
     49 * Destructor.  This function is called by the java Library class's
     50 * finalizer.  Deletes the C++ RpLibrary object when the java Library
     51 * is garbage collected.
    3452 */
    3553JNIEXPORT void JNICALL Java_rappture_Library_jRpDeleteLibrary
     
    3755  delete (RpLibrary*) libPtr;
    3856  return;
     57}
     58
     59// getData
     60JNIEXPORT jbyteArray JNICALL Java_rappture_Library_jRpGetData
     61  (JNIEnv *env, jobject obj, jlong libPtr, jstring javaPath){
     62  const char* nativePath = env->GetStringUTFChars(javaPath, 0);
     63  Rappture::Buffer buf = ((RpLibrary*)libPtr)->getData(nativePath);
     64  size_t size = buf.size();
     65  _jbyteArray* jbuf = env->NewByteArray(size);
     66  env->SetByteArrayRegion(jbuf, 0, size, (const jbyte*)buf.bytes());
     67  env->ReleaseStringUTFChars(javaPath, nativePath);
     68  return jbuf;
    3969}
    4070
     
    4676  env->ReleaseStringUTFChars(javaPath, nativePath);
    4777  return (jdouble)retDVal;
     78}
     79
     80// getInt
     81JNIEXPORT jint JNICALL Java_rappture_Library_jRpGetInt
     82  (JNIEnv *env, jobject obj, jlong libPtr, jstring javaPath){
     83  const char* nativePath = env->GetStringUTFChars(javaPath, 0);
     84  int retIVal = ((RpLibrary*)libPtr)->getInt(nativePath);
     85  env->ReleaseStringUTFChars(javaPath, nativePath);
     86  return (jint)retIVal;
    4887}
    4988
     
    76115}
    77116
     117// putData
     118JNIEXPORT void JNICALL Java_rappture_Library_jRpPutData
     119  (JNIEnv *env, jobject obj, jlong libPtr, jstring javaPath,
     120    jbyteArray jb, jint nbytes, jboolean append){
     121  const char* nativePath = env->GetStringUTFChars(javaPath, 0);
     122  jbyte* b = env->GetByteArrayElements(jb, NULL);
     123  ((RpLibrary*)libPtr)->putData(nativePath, (const char*)b,
     124                                nbytes, (int)append);
     125  env->ReleaseByteArrayElements(jb, b, 0);
     126  env->ReleaseStringUTFChars(javaPath, nativePath);
     127}
     128
     129// putFile
     130JNIEXPORT void JNICALL Java_rappture_Library_jRpPutFile
     131  (JNIEnv *env, jobject obj, jlong libPtr, jstring javaPath,
     132   jstring javaFileName, jboolean compress, jboolean append){
     133  const char* nativePath = env->GetStringUTFChars(javaPath, 0);
     134  const char* nativeFileName = env->GetStringUTFChars(javaFileName, 0);
     135  ((RpLibrary*)libPtr)->putFile(nativePath, nativeFileName,
     136                                (int)compress, (int)append);
     137  env->ReleaseStringUTFChars(javaPath, nativePath);
     138  env->ReleaseStringUTFChars(javaFileName, nativeFileName);
     139}
    78140
    79141// result
     
    83145}
    84146
    85 
  • branches/blt4/lang/java/jRpUnits.cc

    r1744 r1824  
    2222  const char* nativeFromVal = env->GetStringUTFChars(javaFromVal, 0);
    2323  const char* nativeTo = env->GetStringUTFChars(javaTo, 0);
    24   std::string retStr = RpUnits::convert(nativeFromVal, nativeTo, (int)units);
     24  int err;
     25  jclass ex;
     26  std::string errorMsg;
     27
     28  // perform conversion
     29  std::string retStr = RpUnits::convert(nativeFromVal, nativeTo,
     30                                       (int)units, &err);
     31
     32  // raise a runtime exception on error
     33  if (err){
     34    ex = env->FindClass("java/lang/RuntimeException");
     35    if (ex){
     36      errorMsg = "Connot convert ";
     37      errorMsg += nativeFromVal;
     38      errorMsg += " to ";
     39      errorMsg += nativeTo;
     40      env->ThrowNew(ex, errorMsg.c_str());
     41    }
     42    env->DeleteLocalRef(ex);
     43  }
     44
    2545  env->ReleaseStringUTFChars(javaFromVal, nativeFromVal);
    2646  env->ReleaseStringUTFChars(javaTo, nativeTo);
     47
     48  // create new java string and return
    2749  return (env->NewStringUTF(retStr.c_str()));
    2850}
  • branches/blt4/lang/java/jRpUtils.cc

    r1744 r1824  
    2020JNIEXPORT void JNICALL Java_rappture_Utils_jRpUtilsProgress
    2121  (JNIEnv *env, jclass cls, jint percent, jstring javaText){
    22           const char* nativeText = env->GetStringUTFChars(javaText, 0);
    23   Rappture::Utils::progress(percent, nativeText);
     22  const char* nativeText = env->GetStringUTFChars(javaText, 0);
     23  int err = Rappture::Utils::progress(percent, nativeText);
     24  jclass ex;
     25  if (err){
     26    ex = env->FindClass("java/lang/RuntimeException");
     27    if (ex){
     28      env->ThrowNew(ex, "rappture.Utils.progress failed.");
     29    }
     30    env->DeleteLocalRef(ex);
     31  }
    2432  env->ReleaseStringUTFChars(javaText, nativeText);
    2533  return;
  • branches/blt4/lang/matlab/RpMatlabInterface.cc

    r737 r1824  
    5555
    5656    /* Input must be a row vector. */
    57     if ( (mxGetM(prhs)) != 1)
     57    if ( (mxGetM(prhs) == 0) && (mxGetN(prhs) == 0)) {
     58        // do nothin, accept empty strings
     59    } else if ( (mxGetM(prhs)) != 1) {
    5860        mexErrMsgTxt("Input must be a row vector.");
     61    }
    5962
    6063    /* Get the length of the input string. */
  • branches/blt4/lang/perl/Rappture.xs

    r1095 r1824  
    3838        RETVAL = 0;
    3939
    40 const char *
     40SV *
    4141RpLibrary::get( path )
    4242const char *path
     
    4444        string result;
    4545        result = THIS->get(path);
    46         RETVAL = result.c_str();
     46        RETVAL = newSVpvn(result.data(),result.length());
    4747    OUTPUT:
    4848        RETVAL
  • branches/blt4/lang/python/Rappture/result.py

    r787 r1824  
    2020    """
    2121
    22     lib.put("tool.version.rappture.language", "python");
    23     runfile = 'run%d.xml' % time.time()
    24     fp = open(runfile,'w')
    25     fp.write(lib.xml())
    26     fp.close()
    27 
    28     # pass the name of the run file back to Rappture
    29     print '=RAPPTURE-RUN=>%s' % runfile
     22    lib.put("tool.version.rappture.language", "python")
     23    lib.result()
  • branches/blt4/lang/tcl/tests/units.test

    r1427 r1824  
    659659} {0 538.47R}
    660660
     661test convert_units-5.4.6.12 {Rappture::Units::convert, K->mK} {
     662    list [catch {Rappture::Units::convert 299.15K -to mK} msg] $msg
     663} {0 299150mK}
     664
     665test convert_units-5.4.6.13 {Rappture::Units::convert, K->mk} {
     666    list [catch {Rappture::Units::convert 299.15K -to mk} msg] $msg
     667} {0 299150mK}
     668
     669test convert_units-5.4.6.14 {Rappture::Units::convert, C->mC} {
     670    list [catch {Rappture::Units::convert 100C -to mC} msg] $msg
     671} {0 100000mC}
     672
     673test convert_units-5.4.6.15 {Rappture::Units::convert, C->mc} {
     674    list [catch {Rappture::Units::convert 100C -to mc} msg] $msg
     675} {0 100000mC}
     676
     677
    661678#--------------------------------------------------------------------
    662679# Energy Conversions
     
    10311048} {0 sK 0 time*temperature}
    10321049
     1050#--------------------------------------------------------------------
     1051# Allow isspace whitespace in Rappture::Units
     1052#--------------------------------------------------------------------
     1053
     1054test space-7.0.0.1 {check for spaces before value unit string} {
     1055    list [catch {Rappture::Units::Search::for " 300K"} msg] $msg
     1056} {0 K}
     1057
     1058test space-7.0.0.2 {check for spaces after value unit string} {
     1059    list [catch {Rappture::Units::Search::for "300K "} msg] $msg
     1060} {0 K}
     1061
     1062test space-7.0.0.3 {check for spaces before and after value unit string} {
     1063    list [catch {Rappture::Units::Search::for " 300K "} msg] $msg
     1064} {0 K}
     1065
     1066test space-7.0.0.4 {check for spaces between value and unit string} {
     1067    list [catch {Rappture::Units::Search::for " 300 K "} msg] $msg
     1068} {0 K}
     1069
     1070test space-7.0.0.5 {check for spaces between value and single unit string} {
     1071    list [catch {Rappture::Units::Search::for "300 K"} msg] $msg
     1072} {0 K}
     1073
     1074test space-7.0.0.6 {check for spaces between value and multiple unit string} {
     1075    list [catch {Rappture::Units::Search::for "300 Kft"} msg] $msg
     1076} {0 Kft}
     1077
     1078test space-7.0.0.7 {check for spaces around and between value and multiple unit string} {
     1079    list [catch {Rappture::Units::Search::for " 300 Kft "} msg] $msg
     1080} {0 Kft}
     1081
     1082test space-7.0.0.8 {check for spaces between multiple unit string} {
     1083    list [catch {Rappture::Units::Search::for "300 K ft"} msg] $msg
     1084} {0 Kft}
     1085
     1086test space-7.0.0.9 {check for spaces around and between multiple unit string} {
     1087    list [catch {Rappture::Units::Search::for " 300 K ft "} msg] $msg
     1088} {0 Kft}
     1089
     1090test space-7.0.0.10 {check for spaces between multiple unit string with division} {
     1091    list [catch {Rappture::Units::Search::for "300 K / ft"} msg] $msg
     1092} {0 K/ft}
     1093
     1094test space-7.0.0.11 {check for spaces between multiple unit string with multiplication} {
     1095    list [catch {Rappture::Units::Search::for "300 K * ft"} msg] $msg
     1096} {0 Kft}
     1097
     1098test space-7.0.1.1 {check for tabs before value unit string} {
     1099    list [catch {Rappture::Units::Search::for "\t300K"} msg] $msg
     1100} {0 K}
     1101
     1102test space-7.0.1.2 {check for tabs after value unit string} {
     1103    list [catch {Rappture::Units::Search::for "300K\t"} msg] $msg
     1104} {0 K}
     1105
     1106test space-7.0.1.3 {check for tabs before and after value unit string} {
     1107    list [catch {Rappture::Units::Search::for "\t300K\t"} msg] $msg
     1108} {0 K}
     1109
     1110test space-7.0.1.4 {check for tabs between value and unit string} {
     1111    list [catch {Rappture::Units::Search::for "\t300\tK\t"} msg] $msg
     1112} {0 K}
     1113
     1114test space-7.0.1.5 {check for tabs between value and single unit string} {
     1115    list [catch {Rappture::Units::Search::for "300\tK"} msg] $msg
     1116} {0 K}
     1117
     1118test space-7.0.1.6 {check for tabs between value and multiple unit string} {
     1119    list [catch {Rappture::Units::Search::for "300\tKft"} msg] $msg
     1120} {0 Kft}
     1121
     1122test space-7.0.1.7 {check for tabs around and between value and multiple unit string} {
     1123    list [catch {Rappture::Units::Search::for "\t300\tKft\t"} msg] $msg
     1124} {0 Kft}
     1125
     1126test space-7.0.1.8 {check for tabs between multiple unit string} {
     1127    list [catch {Rappture::Units::Search::for "300\tK\tft"} msg] $msg
     1128} {0 Kft}
     1129
     1130test space-7.0.1.9 {check for tabs around and between multiple unit string} {
     1131    list [catch {Rappture::Units::Search::for "\t300\tK\tft\t"} msg] $msg
     1132} {0 Kft}
     1133
     1134test space-7.0.1.10 {check for tabs between multiple unit string with division} {
     1135    list [catch {Rappture::Units::Search::for "300\tK\t/\tft"} msg] $msg
     1136} {0 K/ft}
     1137
     1138test space-7.0.1.11 {check for tabs between multiple unit string with multiplication} {
     1139    list [catch {Rappture::Units::Search::for "300\tK\t*\tft"} msg] $msg
     1140} {0 Kft}
     1141
     1142test space-7.0.2.1 {check for newlines before value unit string} {
     1143    list [catch {Rappture::Units::Search::for "\n300K"} msg] $msg
     1144} {0 K}
     1145
     1146test space-7.0.2.2 {check for newlines after value unit string} {
     1147    list [catch {Rappture::Units::Search::for "300K\n"} msg] $msg
     1148} {0 K}
     1149
     1150test space-7.0.2.3 {check for newlines before and after value unit string} {
     1151    list [catch {Rappture::Units::Search::for "\n300K\n"} msg] $msg
     1152} {0 K}
     1153
     1154test space-7.0.2.4 {check for newlines between value and unit string} {
     1155    list [catch {Rappture::Units::Search::for "\n300\nK\n"} msg] $msg
     1156} {0 K}
     1157
     1158test space-7.0.2.5 {check for newlines between value and single unit string} {
     1159    list [catch {Rappture::Units::Search::for "300\nK"} msg] $msg
     1160} {0 K}
     1161
     1162test space-7.0.2.6 {check for newlines between value and multiple unit string} {
     1163    list [catch {Rappture::Units::Search::for "300\nKft"} msg] $msg
     1164} {0 Kft}
     1165
     1166test space-7.0.2.7 {check for newlines around and between value and multiple unit string} {
     1167    list [catch {Rappture::Units::Search::for "\n300\nKft\n"} msg] $msg
     1168} {0 Kft}
     1169
     1170test space-7.0.2.8 {check for newlines between multiple unit string} {
     1171    list [catch {Rappture::Units::Search::for "300\nK\nft"} msg] $msg
     1172} {0 Kft}
     1173
     1174test space-7.0.2.9 {check for newlines around and between multiple unit string} {
     1175    list [catch {Rappture::Units::Search::for "\n300\nK\nft\n"} msg] $msg
     1176} {0 Kft}
     1177
     1178test space-7.0.2.10 {check for newlines between multiple unit string with division} {
     1179    list [catch {Rappture::Units::Search::for "300\nK\n/\nft"} msg] $msg
     1180} {0 K/ft}
     1181
     1182test space-7.0.2.11 {check for newlines between multiple unit string with multiplication} {
     1183    list [catch {Rappture::Units::Search::for "300\nK\n*\nft"} msg] $msg
     1184} {0 Kft}
     1185
     1186# TODO:
     1187# add tests for space and tab, space and newline, tab and newline
     1188# add tests for bad characters &^%$#@!)(~`{}[]:;"'?><,.-_=+\ or |
     1189
    10331190::tcltest::cleanupTests
    10341191return
  • branches/blt4/src/core/RpLibrary.cc

    r1527 r1824  
    2727#include <iterator>
    2828#include <cctype>
     29
     30#ifdef _POSIX_SOURCE
     31    #include <sys/time.h>
     32#endif /* _POSIX_SOURCE */
    2933
    3034// no arg constructor
     
    22002204
    22012205    if (this->root) {
     2206#ifdef _POSIX_SOURCE
     2207        // if the posix function gettimeofday is available,
     2208        // we can get more precision on the time and more
     2209        // unique filenames.
     2210        struct timeval tv;
     2211        gettimeofday(&tv,NULL);
     2212        outputFile << "run" << tv.tv_sec << tv.tv_usec << ".xml";
     2213#else
    22022214        outputFile << "run" << (int)time(&t) << ".xml";
     2215#endif
    22032216        file.open(outputFile.str().c_str(),std::ios::out);
    22042217
  • branches/blt4/src/core/RpUnits.cc

    r1571 r1824  
    10251025    const RpUnits* prefix   = NULL;
    10261026
    1027 
    10281027    while ( !myInUnits.empty() ) {
    10291028
     
    10441043            // type = myInUnits[last] + type;
    10451044            // ignore * because we assume everything is multiplied together
     1045            myInUnits.erase(last);
     1046            continue;
     1047        }
     1048
     1049        // ignore whitespace characters
     1050        if (isspace(myInUnits[last])) {
     1051            // ignore whitespace characters, they represent multiplication
    10461052            myInUnits.erase(last);
    10471053            continue;
     
    25902596
    25912597    fahrenheit = RpUnits::define("F", NULL, RP_TYPE_TEMP);
    2592     celcius    = RpUnits::define("C", NULL, RP_TYPE_TEMP);
    2593     kelvin     = RpUnits::define("K", NULL, RP_TYPE_TEMP);
     2598    celcius    = RpUnits::define("C", NULL, RP_TYPE_TEMP, RPUNITS_METRIC);
     2599    kelvin     = RpUnits::define("K", NULL, RP_TYPE_TEMP,RPUNITS_METRIC);
    25942600    rankine    = RpUnits::define("R", NULL, RP_TYPE_TEMP);
    25952601
     
    32883294        retVal = 1;
    32893295    }
    3290     else {
    3291     }
    32923296
    32933297    outUnits = std::string(endptr);
  • branches/blt4/src/core/scew_extras.c

    r1018 r1824  
    128128
    129129    assert(element != NULL);
    130     assert(bytes != NULL);
    131130    assert(nbytes != NULL);
    132 
    133131    if (*nbytes == 0) {
    134132        return element->contents;
    135133    }
     134    assert(bytes != NULL);
    136135
    137136    free(element->contents);
Note: See TracChangeset for help on using the changeset viewer.