Changeset 17498


Ignore:
Timestamp:
01/07/14 16:11:13 (11 years ago)
Author:
tbretz
Message:
Implemented that one can wait for 'not a state' to check if a state has been changed away from something.
Location:
trunk/FACT++
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/scripts/doc/dim.js

    r15151 r17498  
    115115 * @param {String} name
    116116 *     The name of the server of which you want to wait for a state.
    117  *     The name must not contain quotation marks.
     117 *     The name must not contain quotation marks. To wait for
     118 *     "not the given state", prefix the server name with an
     119 *     exclamation mark, e.g. "!DIM_CONTROL"
    118120 *
    119121 * @param {String,Integer} state
  • trunk/FACT++/src/InterpreterV8.cc

    r17213 r17498  
    362362    const string state   = args[1]->IsString() ? *String::AsciiValue(args[1]) : "";
    363363    const string arg1    = args[1]->IsString() ? ("\""+state+"\"") : to_string(args[1]->Int32Value());
     364    const bool   isNot   = arg0[0]=='!';
     365    const string name    = isNot ? arg0.substr(1) : arg0;
    364366
    365367    if (arg0.find_first_of("\"'")!=string::npos)
     
    377379                      "{"
    378380                         "var s = dim.state(name);"
    379                          "if(!s)throw new Error('Waiting for state "+arg1+" of server "+arg0+" failed.');"
     381                         "if(!s)throw new Error('Waiting for state "+arg1+" of server "+arg0+" failed.');";
     382    if (isNot)
     383                         "if(state=="+index+")return true;";
     384    else
    380385                         "if(state=="+index+")return true;";
    381386    if (timeout)
     
    387392        code +=    "if(ms>0)throw new Error('Waiting for state "+arg1+" of server "+arg0+" timed out.');";
    388393    code +=        "return false;"
    389                    "})('"+arg0+"',"+arg1;
     394                   "})('"+name+"',"+arg1;
    390395    if (timeout)
    391396        code +=    "," + (args[2]->IsUndefined()?"undefined":to_string(args[2]->Int32Value()));
Note: See TracChangeset for help on using the changeset viewer.