Ignore:
Timestamp:
06/05/12 17:28:10 (12 years ago)
Author:
tbretz
Message:
Removed 'name' function and return a state-object instead.
File:
1 edited

Legend:

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

    r14068 r14084  
    204204        return ThrowException(String::New("Argument 1 must be a string."));
    205205
    206     const HandleScope handle_scope;
     206    // Return state.name/state.index
     207
     208    HandleScope handle_scope;
    207209
    208210    const String::Utf8Value str(args[0]);
    209     return Integer::New(JsState(*str));
    210 }
    211 
    212 Handle<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());
     211
     212    const pair<int32_t, string> rc = JsState(*str);
     213
     214    Handle<ObjectTemplate> obj = ObjectTemplate::New();
     215    obj->Set(String::New("index"), rc.first <=-256?Undefined():Integer::New(rc.first),          ReadOnly);
     216    obj->Set(String::New("name"),  rc.first <=-256?Undefined():String::New (rc.second.c_str()), ReadOnly);
     217 
     218    return handle_scope.Close(obj->NewInstance());
    224219}
    225220
     
    281276    return String::New(V8::GetVersion());
    282277}
    283 
    284 #include <iostream>
    285278
    286279bool InterpreterV8::JsRun(const string &filename, const map<string, string> &map)
     
    299292    dim->Set(String::New("send"),    FunctionTemplate::New(WrapSend),    ReadOnly);
    300293    dim->Set(String::New("state"),   FunctionTemplate::New(WrapState),   ReadOnly);
    301     dim->Set(String::New("name"),    FunctionTemplate::New(WrapName),    ReadOnly);
    302294    dim->Set(String::New("sleep"),   FunctionTemplate::New(WrapSleep),   ReadOnly);
    303295
     
    331323    v8::Locker::StopPreemption();
    332324    //context->Exit();
     325
     326    //context.Dispose();
    333327
    334328    JsEnd(filename);
     
    348342
    349343#endif
     344
Note: See TracChangeset for help on using the changeset viewer.