Ignore:
Timestamp:
06/03/12 22:50:55 (12 years ago)
Author:
tbretz
Message:
Added special '$' array as arguments; moved sleep to dim-space; added state and name function template
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/InterpreterV8.cc

    r14055 r14059  
    191191        return ThrowException(String::New("Argument 1 must be an uint32."));
    192192
    193     const HandleScope handle_scope;
    194 
    195193    JsSleep(args[0]->Int32Value());
    196194
    197195    return Undefined();
     196}
     197
     198Handle<Value> InterpreterV8::FuncState(const Arguments& args)
     199{
     200    if (args.Length()!=1)
     201        return ThrowException(String::New("Number of arguments must be exactly 1."));
     202
     203    if (!args[0]->IsString())
     204        return ThrowException(String::New("Argument 1 must be a string."));
     205
     206    const HandleScope handle_scope;
     207
     208    const String::Utf8Value str(args[0]);
     209    return Integer::New(JsState(*str));
     210}
     211
     212Handle<Value> InterpreterV8::FuncName(const Arguments& args)
     213{
     214    if (args.Length()!=1)
     215        return ThrowException(String::New("Number of arguments must be exactly 1."));
     216
     217    if (!args[0]->IsString())
     218        return ThrowException(String::New("Argument 1 must be a string."));
     219
     220    const HandleScope handle_scope;
     221
     222    const String::Utf8Value str(args[0]);
     223    return String::New(JsName(*str).c_str());
    198224}
    199225
     
    272298    dim->Set(String::New("wait"),    FunctionTemplate::New(WrapWait),    ReadOnly);
    273299    dim->Set(String::New("send"),    FunctionTemplate::New(WrapSend),    ReadOnly);
     300    dim->Set(String::New("state"),   FunctionTemplate::New(WrapState),   ReadOnly);
     301    dim->Set(String::New("name"),    FunctionTemplate::New(WrapName),    ReadOnly);
     302    dim->Set(String::New("sleep"),   FunctionTemplate::New(WrapSleep),   ReadOnly);
    274303
    275304    Handle<ObjectTemplate> global = ObjectTemplate::New();
    276305    global->Set(String::New("dim"), dim, ReadOnly);
    277306    global->Set(String::New("include"), FunctionTemplate::New(WrapInclude),                ReadOnly);
    278     global->Set(String::New("sleep"),   FunctionTemplate::New(WrapSleep),                  ReadOnly);
    279307    global->Set(String::New("exit"),    FunctionTemplate::New(WrapExit),                   ReadOnly);
    280308    global->Set(String::New("version"), FunctionTemplate::New(InterpreterV8::FuncVersion), ReadOnly);
     
    293321    for (auto it=map.begin(); it!=map.end(); it++)
    294322        args->Set(String::New(it->first.c_str()), String::New(it->second.c_str()));
     323    context->Global()->Set(String::New("$"),   args);
    295324    context->Global()->Set(String::New("arg"), args);
    296325
Note: See TracChangeset for help on using the changeset viewer.