Subversion Repositories HomeAutomation

Rev

Rev 1008 | Rev 1011 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1008 Rev 1010
Line 547... Line 547...
547
    vm.sendToSocketThread(args[0]->Uint32Value(), *data);
547
    vm.sendToSocketThread(args[0]->Uint32Value(), *data);
548
 
548
 
549
    return Undefined();
549
    return Undefined();
550
}
550
}
551
 
551
 
552
Handle<Value> VirtualMachine::_uint2hex(const Arguments& args)
552
Handle<Value> VirtualMachine::_getFileContents(const Arguments& args)
-
 
553
{
-
 
554
    String::AsciiValue filename(args[0]);
-
 
555
 
-
 
556
    if (!file_exists(*filename))
553
{
557
    {
-
 
558
        return Undefined();
-
 
559
    }
-
 
560
 
554
    VirtualMachine &vm = VirtualMachine::getInstance();
561
    string content = file_get_contents(*filename);
-
 
562
 
-
 
563
    return String::New(content.c_str());
-
 
564
}
555
 
565
 
-
 
566
Handle<Value> VirtualMachine::_uint2hex(const Arguments& args)
-
 
567
{
556
    string hexId = uint2hex(args[0]->Uint32Value(), args[1]->Uint32Value());
568
    string hex = uint2hex(args[0]->Uint32Value(), args[1]->Uint32Value());
-
 
569
    return String::New(hex.c_str());
-
 
570
}
-
 
571
 
-
 
572
Handle<Value> VirtualMachine::_hex2bin(const Arguments& args)
-
 
573
{
-
 
574
    String::AsciiValue hex(args[0]);
-
 
575
    string bin = hex2bin(*hex);
-
 
576
    return String::New(bin.c_str());
-
 
577
}
557
 
578
 
-
 
579
Handle<Value> VirtualMachine::_bin2hex(const Arguments& args)
-
 
580
{
-
 
581
    String::AsciiValue bin(args[0]);
-
 
582
    string hex = bin2hex(*bin);
558
    return String::New(hexId.c_str());
583
    return String::New(hex.c_str());
-
 
584
}
-
 
585
 
-
 
586
Handle<Value> VirtualMachine::_bin2float(const Arguments& args)
-
 
587
{
-
 
588
    String::AsciiValue bin(args[0]);
-
 
589
    float f = bin2float(*bin);
-
 
590
    return Number::New(f);
-
 
591
}
-
 
592
 
-
 
593
Handle<Value> VirtualMachine::_float2bin(const Arguments& args)
-
 
594
{
-
 
595
    string bin = float2bin(args[0]->NumberValue(), args[1]->Uint32Value());
-
 
596
    return String::New(bin.c_str());
-
 
597
}
-
 
598
 
-
 
599
Handle<Value> VirtualMachine::_bin2uint(const Arguments& args)
-
 
600
{
-
 
601
    String::AsciiValue bin(args[0]);
-
 
602
    unsigned int num = bin2uint(*bin);
-
 
603
    return Uint32::New(num);
559
}
604
}
560
 
605
 
561
Handle<Value> VirtualMachine::_getFileContents(const Arguments& args)
606
Handle<Value> VirtualMachine::_uint2bin(const Arguments& args)
562
{
607
{
563
    String::AsciiValue filename(args[0]);
608
    string bin = uint2bin(args[0]->Uint32Value(), args[1]->Uint32Value());
564
 
-
 
565
    if (!file_exists(*filename))
-
 
566
    {
-
 
567
        return Undefined();
609
    return String::New(bin.c_str());
568
    }
610
}
569
 
611
 
570
    string content = file_get_contents(*filename);
-
 
571
 
-
 
572
    return String::New(content.c_str());
-
 
573
}
-
 
574
 
612