Changeset 17498 for trunk/FACT++/src


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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.