Changeset 962


Ignore:
Timestamp:
Mar 25, 2008 12:19:50 PM (16 years ago)
Author:
dkearney
Message:

code cleanups.
adjusted gague.tcl to check the length of the string it receives for integers and reals.
modified c, matlab, and octave's lib function to handle empty string for creation of empty library.
modified matlab and octave's lib result function to handle status as a parameter.
fixed core library code to deal with incorrect order of translating xml entity references.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/gauge.tcl

    r738 r962  
    234234        switch -- $itk_option(-type) {
    235235            integer {
    236                 if {![string is integer $nv]} {
     236                if {[string length $nv] <= 0
     237                      || ![string is integer $nv] } {
    237238                    error "Should be an integer value"
    238239                }
    239240            }
    240241            real {
    241                 if {![string is double $nv]
     242                if {[string length $nv] <= 0
     243                      || ![string is double $nv]
    242244                      || [regexp -nocase {^(inf|nan)$} $nv]} {
    243245                    error "Should be a real number"
  • trunk/python/Rappture/PyRpEncode.cc

    r671 r962  
    2727    int dlen = 0;
    2828    PyObject* rv = NULL;
    29     int result = 0;
    3029
    3130    static char *kwlist[] = {"data", NULL};
  • trunk/src/cee/RpLibraryCInterface.cc

    r789 r962  
    2323rpLibrary (const char* path)
    2424{
     25    if (path == NULL) {
     26        return (new RpLibrary());
     27    }
     28
    2529    return (new RpLibrary(path));
    2630}
  • trunk/src/core/RpDict.h

    r568 r962  
    11/*
    22 * ======================================================================
     3 *  RpDict
     4 *
     5 *  AUTHOR:  Derrick Kearney, Purdue University
    36 *  Copyright (c) 2004-2005  Purdue Research Foundation
    47 *
  • trunk/src/core/RpLibrary.cc

    r872 r962  
    17501750        // library doesn't exist, do nothing;
    17511751        status.error("invalid library object");
    1752         status.addContext("RpLibrary::put()");
     1752        status.addContext("RpLibrary::put() - putString");
    17531753        return *this;
    17541754    }
     
    17631763    retNode = _find(path,CREATE_PATH);
    17641764
    1765     if (retNode) {
    1766 
    1767         if (append == RPLIB_APPEND) {
    1768             if ( (contents = scew_element_contents(retNode)) ) {
    1769                 tmpVal = std::string(contents);
    1770             }
    1771             value = tmpVal + value;
    1772         }
    1773 
    1774         if (translateFlag == RPLIB_TRANSLATE) {
    1775             translatedContents = ERTranslator.encode(value.c_str(),0);
    1776         }
    1777         else {
    1778             translatedContents = value.c_str();
    1779         }
    1780 
     1765    if (retNode == NULL) {
     1766        // node not found, set error
     1767        status.error("Error while searching for node: node not found");
     1768        status.addContext("RpLibrary::put() - putString");
     1769        return *this;
     1770    }
     1771
     1772    if (translateFlag == RPLIB_TRANSLATE) {
     1773        translatedContents = ERTranslator.encode(value.c_str(),0);
    17811774        if (translatedContents == NULL) {
    17821775            // entity referene translation failed
     
    17861779        }
    17871780        else {
    1788             scew_element_set_contents(retNode,translatedContents);
     1781            value = std::string(translatedContents);
    17891782            translatedContents = NULL;
    17901783        }
    17911784    }
    1792     else {
    1793         // node not found, set error
    1794         if (!status) {
    1795             status.error("Error while searching for node: node not found");
    1796         }
    1797     }
     1785
     1786    if (append == RPLIB_APPEND) {
     1787        contents = scew_element_contents(retNode);
     1788        if (contents != NULL) {
     1789            tmpVal = std::string(contents);
     1790            value = tmpVal + value;
     1791        }
     1792    }
     1793
     1794    scew_element_set_contents(retNode,value.c_str());
    17981795
    17991796    status.addContext("RpLibrary::put() - putString");
     
    22122209    std::string hostname = "";
    22132210    char *user = NULL;
    2214     char *host = NULL;
    22152211
    22162212    if (this->root) {
  • trunk/src/matlab/rpLib.cc

    r162 r962  
    4040
    4141    /* Call the C++ subroutine. */
    42     if (!path.empty()) {
    43         lib = new RpLibrary(path);
    44         if (lib) {
    45             // store the library and return a dictionary key
    46             libIndex = storeObject_Lib(lib);
    47             if (libIndex) {
    48                 err = 0;
    49             }
     42    lib = new RpLibrary(path);
     43    if (lib) {
     44        // store the library and return a dictionary key
     45        libIndex = storeObject_Lib(lib);
     46        if (libIndex) {
     47            err = 0;
    5048        }
    5149    }
  • trunk/src/matlab/rpLibResult.cc

    r789 r962  
    1717
    1818/**********************************************************************/
    19 // METHOD: [err] = rpLibResult (libHandle)
     19// METHOD: [err] = rpLibResult (libHandle,status)
    2020/// Write Rappture Library to run.xml and signal end of processing.
    2121/**
     
    3030    int libIndex = 0;
    3131    int err = 1;
     32    int status = 0;
    3233    RpLibrary* lib = NULL;
    3334
    3435    /* Check for proper number of arguments. */
    35     if (nrhs != 1) {
     36    if (nrhs > 2) {
     37        mexErrMsgTxt("At most two input allowed.");
     38    }
     39
     40    if (nrhs < 1) {
    3641        mexErrMsgTxt("One input required.");
    3742    }
     
    4045    libIndex = getIntInput(prhs[0]);
    4146
     47    if (nrhs == 2) {
     48        status = getIntInput(prhs[1]);
     49    }
     50
    4251    /* Call the C subroutine. */
    4352    if (libIndex > 0) {
     
    4554        if (lib) {
    4655            lib->put("tool.version.rappture.language", "matlab");
    47             lib->result();
     56            lib->result(status);
    4857            err = 0;
    4958            // cleanLibDict();
  • trunk/src/octave/rpLib.cc

    r156 r962  
    4747        if (args(0).is_string ()) {
    4848            path = args(0).string_value ();
    49             if (!path.empty()) {
    50                 lib = new RpLibrary(path);
     49            lib = new RpLibrary(path);
     50            if (lib != NULL) {
    5151                err = 0;
    5252            }
  • trunk/src/octave/rpLibResult.cc

    r789 r962  
    66 *
    77 * ======================================================================
    8  *  AUTHOR:  Derrick Kearney, Purdue University
    9  *  Copyright (c) 2005
     8 *  AUTHOR:  Derrick S. Kearney, Purdue University
     9 *  Copyright (c) 2005-2008
    1010 *  Purdue Research Foundation, West Lafayette, IN
    1111 * ======================================================================
     
    1515
    1616/**********************************************************************/
    17 // METHOD: [err] = rpLibResult (libHandle)
     17// METHOD: [err] = rpLibResult (libHandle,status)
    1818/// Write Rappture Library to run.xml and signal end of processing.
    1919/**
     
    2525DEFUN_DLD (rpLibResult, args, ,
    2626"-*- texinfo -*-\n\
    27 [err] = rpLibResult (@var{libHandle})\n\
     27[err] = rpLibResult (@var{libHandle},@var{status})\n\
    2828\n\
    2929Usually the last call of the program, this function signals to the gui\n\
     
    3737    octave_value_list retval;
    3838
    39     int nargin = args.length ();
     39    int nargin = args.length();
    4040    RpLibrary* lib = NULL;
    4141    int libHandle = 0;
     42    int status = 0;
    4243    int err = 0;
    4344
    44     if (nargin == 1) {
    45         if (args(0).is_real_scalar ()) {
    46             libHandle= args(0).int_value ();
    47             /* Call the C subroutine. */
    48             if (libHandle > 0) {
    49                 lib = getObject_Lib(libHandle);
    50                 if (lib) {
    51                     lib->put("tool.version.rappture.language", "octave");
    52                     lib->result();
    53                     // cleanLibDict();
    54                     err = 0;
    55                 }
    56             }
     45    if ((nargin < 1) || (nargin > 2)) {
     46        // wrong number of arguments
     47        print_usage ("rpLibResult");
     48        goto done;
     49    }
     50
     51    if (! args(0).is_real_scalar()) {
     52        // wrong argument type
     53        print_usage ("rpLibResult");
     54        goto done;
     55    }
     56
     57    libHandle = args(0).int_value();
     58
     59    if (nargin == 2) {
     60        if (! args(1).is_real_scalar()) {
     61            // wrong argument type
     62            print_usage ("rpLibResult");
     63            goto done;
    5764        }
    58         else {
    59             // wrong argument type
    60             print_usage ("rpLib");
     65
     66        status = args(1).int_value();
     67    }
     68
     69    /* Call the C subroutine. */
     70    if (libHandle > 0) {
     71        lib = getObject_Lib(libHandle);
     72        if (lib) {
     73            lib->put("tool.version.rappture.language", "octave");
     74            lib->result(status);
     75            // cleanLibDict();
     76            err = 0;
    6177        }
    6278    }
    63     else {
    64         // wrong number of arguments
    65         print_usage ("rpLib");
    66     }
    6779
     80done:
    6881    retval(0) = err;
    69 
    70   return retval;
     82    return retval;
    7183}
Note: See TracChangeset for help on using the changeset viewer.