Changeset 14741 for trunk/FACT++/src/InterpreterV8.cc
- Timestamp:
- 12/08/12 13:29:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/InterpreterV8.cc
r14709 r14741 433 433 } 434 434 435 Handle<Value> InterpreterV8::FuncGetStates(const Arguments& args) 436 { 437 if (args.Length()>1) 438 return ThrowException(String::New("getStates must not take more than one arguments.")); 439 440 if (args.Length()==1 && !args[0]->IsString()) 441 return ThrowException(String::New("Argument must be an string.")); 442 443 const string server = args.Length()==1 ? *String::AsciiValue(args[0]) : "DIM_CONTROL"; 444 445 const vector<State> states = JsGetStates(server); 446 447 HandleScope handle_scope; 448 449 Handle<Object> list = Object::New(); 450 if (list.IsEmpty()) 451 return Undefined(); 452 453 for (auto it=states.begin(); it!=states.end(); it++) 454 { 455 Handle<Value> entry = StringObject::New(String::New(it->name.c_str())); 456 if (entry.IsEmpty()) 457 return Undefined(); 458 459 StringObject::Cast(*entry)->Set(String::New("description"), String::New(it->comment.c_str()), ReadOnly); 460 list->Set(Integer::New(it->index), entry, ReadOnly); 461 } 462 463 return handle_scope.Close(list); 464 } 465 435 466 // ========================================================================== 436 467 // Internal functions … … 441 472 // function is called. Prints its arguments on stdout separated by 442 473 // spaces and ending with a newline. 443 Handle<Value> InterpreterV8::Func Print(const Arguments& args)474 Handle<Value> InterpreterV8::FuncLog(const Arguments& args) 444 475 { 445 476 for (int i=0; i<args.Length(); i++) … … 1926 1957 // Create a template for the global object. 1927 1958 Handle<ObjectTemplate> dim = ObjectTemplate::New(); 1928 dim->Set(String::New("print"), FunctionTemplate::New(WrapPrint), ReadOnly); 1929 dim->Set(String::New("alarm"), FunctionTemplate::New(WrapAlarm), ReadOnly); 1930 dim->Set(String::New("wait"), FunctionTemplate::New(WrapWait), ReadOnly); 1931 dim->Set(String::New("send"), FunctionTemplate::New(WrapSend), ReadOnly); 1932 dim->Set(String::New("state"), FunctionTemplate::New(WrapState), ReadOnly); 1933 dim->Set(String::New("version"), Integer::New(DIM_VERSION_NUMBER), ReadOnly); 1959 dim->Set(String::New("log"), FunctionTemplate::New(WrapLog), ReadOnly); 1960 dim->Set(String::New("alarm"), FunctionTemplate::New(WrapAlarm), ReadOnly); 1961 dim->Set(String::New("wait"), FunctionTemplate::New(WrapWait), ReadOnly); 1962 dim->Set(String::New("send"), FunctionTemplate::New(WrapSend), ReadOnly); 1963 dim->Set(String::New("state"), FunctionTemplate::New(WrapState), ReadOnly); 1964 dim->Set(String::New("version"), Integer::New(DIM_VERSION_NUMBER), ReadOnly); 1965 dim->Set(String::New("getStates"), FunctionTemplate::New(WrapGetStates), ReadOnly); 1934 1966 1935 1967 Handle<ObjectTemplate> dimctrl = ObjectTemplate::New();
Note:
See TracChangeset
for help on using the changeset viewer.