Rev 1007 | Rev 1010 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1007 | Rev 1008 | ||
|---|---|---|---|
| Line 86... | Line 86... | ||
| 86 | myGlobal->Set(String::New("startSocketThread"), FunctionTemplate::New(VirtualMachine::_startSocketThread)); |
86 | myGlobal->Set(String::New("startSocketThread"), FunctionTemplate::New(VirtualMachine::_startSocketThread)); |
| 87 | myGlobal->Set(String::New("stopSocketThread"), FunctionTemplate::New(VirtualMachine::_stopSocketThread)); |
87 | myGlobal->Set(String::New("stopSocketThread"), FunctionTemplate::New(VirtualMachine::_stopSocketThread)); |
| 88 | myGlobal->Set(String::New("sendToSocketThread"), FunctionTemplate::New(VirtualMachine::_sendToSocketThread)); |
88 | myGlobal->Set(String::New("sendToSocketThread"), FunctionTemplate::New(VirtualMachine::_sendToSocketThread)); |
| 89 | myGlobal->Set(String::New("uint2hex"), FunctionTemplate::New(VirtualMachine::_uint2hex)); |
89 | myGlobal->Set(String::New("uint2hex"), FunctionTemplate::New(VirtualMachine::_uint2hex)); |
| 90 | myGlobal->Set(String::New("loadDataStore"), FunctionTemplate::New(VirtualMachine::_loadDataStore)); |
90 | myGlobal->Set(String::New("loadDataStore"), FunctionTemplate::New(VirtualMachine::_loadDataStore)); |
| - | 91 | myGlobal->Set(String::New("getFileContents"), FunctionTemplate::New(VirtualMachine::_getFileContents)); |
|
| 91 | myContext = Context::New(NULL, myGlobal); |
92 | myContext = Context::New(NULL, myGlobal); |
| 92 | 93 | ||
| 93 | 94 | ||
| 94 | if (loadScript("System/Base.js")) |
95 | if (loadScript("System/Base.js")) |
| 95 | { |
96 | { |
| Line 352... | Line 353... | ||
| 352 | { |
353 | { |
| 353 | string scriptName = "runExpression"; |
354 | string scriptName = "runExpression"; |
| 354 | 355 | ||
| 355 | string scriptData = expression.getScript(); |
356 | string scriptData = expression.getScript(); |
| 356 | 357 | ||
| 357 | scriptData = "setClientId(" + itos(expression.getTargetId()) + ");\n" + scriptData; |
358 | scriptData = "setClientId(" + itos(expression.getTargetId()) + ");\n" + scriptData + "\n"; |
| 358 | 359 | ||
| 359 | Handle<String> source = String::New(scriptData.c_str(), scriptData.length()); |
360 | Handle<String> source = String::New(scriptData.c_str(), scriptData.length()); |
| 360 | Handle<String> name = String::New(scriptName.c_str(), scriptName.length()); |
361 | Handle<String> name = String::New(scriptName.c_str(), scriptName.length()); |
| 361 | 362 | ||
| 362 | Context::Scope contextScope(myContext); |
363 | Context::Scope contextScope(myContext); |
| Line 554... | Line 555... | ||
| 554 | 555 | ||
| 555 | string hexId = uint2hex(args[0]->Uint32Value(), args[1]->Uint32Value()); |
556 | string hexId = uint2hex(args[0]->Uint32Value(), args[1]->Uint32Value()); |
| 556 | 557 | ||
| 557 | return String::New(hexId.c_str()); |
558 | return String::New(hexId.c_str()); |
| 558 | } |
559 | } |
| - | 560 | ||
| - | 561 | Handle<Value> VirtualMachine::_getFileContents(const Arguments& args) |
|
| - | 562 | { |
|
| - | 563 | String::AsciiValue filename(args[0]); |
|
| - | 564 | ||
| - | 565 | if (!file_exists(*filename)) |
|
| - | 566 | { |
|
| - | 567 | return Undefined(); |
|
| - | 568 | } |
|
| - | 569 | ||
| - | 570 | string content = file_get_contents(*filename); |
|
| - | 571 | ||
| - | 572 | return String::New(content.c_str()); |
|
| - | 573 | } |
|
| - | 574 | ||