Changeset 14135 for trunk/FACT++/src/InterpreterV8.cc
- Timestamp:
- 06/08/12 22:01:56 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/InterpreterV8.cc
r14125 r14135 257 257 } 258 258 259 Handle<Value> InterpreterV8::FuncOut(const Arguments& args) 260 { 261 for (int i=0; i<args.Length(); i++) 262 { 263 const HandleScope handle_scope; 264 265 const String::Utf8Value str(args[i]); 266 if (*str) 267 JsOut(*str); 268 } 269 return Undefined(); 270 } 271 259 272 // The callback that is invoked by v8 whenever the JavaScript 'load' 260 273 // function is called. Loads, compiles and executes its argument … … 283 296 Handle<Value> Convert(char type, const char* &ptr) 284 297 { 298 // Dim values are always unsigned per (FACT++) definition 285 299 switch (type) 286 300 { 287 case 'F': { Handle<Value> v=Number::New(*reinterpret_cast<const float*>(ptr)); ptr+=4; return v; } 288 case 'D': { Handle<Value> v=Number::New(*reinterpret_cast<const double*>(ptr)); ptr+=8; return v; } 289 case 'I': { 290 case 'L': Handle<Value> v=Integer::New(*reinterpret_cast<const uint32_t*>(ptr)); ptr += 4; return v; } 291 case 'X': { Handle<Value> v=Integer::New(*reinterpret_cast<const uint64_t*>(ptr)); ptr += 8; return v; } 292 case 'S': { Handle<Value> v=Integer::New(*reinterpret_cast<const uint16_t*>(ptr)); ptr += 2; return v; } 293 case 'C': { Handle<Value> v=Integer::New((uint16_t)*reinterpret_cast<const uint8_t*>(ptr)); ptr += 1; return v; } 301 case 'F': 302 { 303 // Remove the "imprecision" effect coming from casting a float to 304 // a double and then showing it with double precision 305 ostringstream val; 306 val << setprecision(7) << *reinterpret_cast<const float*>(ptr); 307 Handle<Value> v=Number::New(stod(val.str())); 308 ptr+=4; 309 return v; 310 } 311 case 'D': { Handle<Value> v=Number::New(*reinterpret_cast<const double*>(ptr)); ptr+=8; return v; } 312 case 'I': 313 case 'L': { Handle<Value> v=Integer::NewFromUnsigned(*reinterpret_cast<const uint32_t*>(ptr)); ptr += 4; return v; } 314 case 'X': 315 { 316 const uint64_t val = *reinterpret_cast<const uint64_t*>(ptr); 317 ptr += 8; 318 if (val>UINT32_MAX) 319 return Number::New(val); 320 return Integer::NewFromUnsigned(val); 321 } 322 case 'S': { Handle<Value> v=Integer::NewFromUnsigned(*reinterpret_cast<const uint16_t*>(ptr)); ptr += 2; return v; } 323 case 'C': { Handle<Value> v=Integer::NewFromUnsigned((uint16_t)*reinterpret_cast<const uint8_t*>(ptr)); ptr += 1; return v; } 294 324 case ':': { Handle<Value> v=String::New(ptr); return v; } 295 325 } … … 448 478 Handle<ObjectTemplate> dim = ObjectTemplate::New(); 449 479 dim->Set(String::New("print"), FunctionTemplate::New(WrapPrint), ReadOnly); 480 dim->Set(String::New("out"), FunctionTemplate::New(WrapOut), ReadOnly); 450 481 dim->Set(String::New("wait"), FunctionTemplate::New(WrapWait), ReadOnly); 451 482 dim->Set(String::New("send"), FunctionTemplate::New(WrapSend), ReadOnly); … … 486 517 //context.Dispose(); 487 518 488 cout << "JsEnd" << endl;489 519 JsEnd(filename); 490 520
Note:
See TracChangeset
for help on using the changeset viewer.