Changeset 14084 for trunk/FACT++/src/InterpreterV8.cc
- Timestamp:
- 06/05/12 17:28:10 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/InterpreterV8.cc
r14068 r14084 204 204 return ThrowException(String::New("Argument 1 must be a string.")); 205 205 206 const HandleScope handle_scope; 206 // Return state.name/state.index 207 208 HandleScope handle_scope; 207 209 208 210 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()); 224 219 } 225 220 … … 281 276 return String::New(V8::GetVersion()); 282 277 } 283 284 #include <iostream>285 278 286 279 bool InterpreterV8::JsRun(const string &filename, const map<string, string> &map) … … 299 292 dim->Set(String::New("send"), FunctionTemplate::New(WrapSend), ReadOnly); 300 293 dim->Set(String::New("state"), FunctionTemplate::New(WrapState), ReadOnly); 301 dim->Set(String::New("name"), FunctionTemplate::New(WrapName), ReadOnly);302 294 dim->Set(String::New("sleep"), FunctionTemplate::New(WrapSleep), ReadOnly); 303 295 … … 331 323 v8::Locker::StopPreemption(); 332 324 //context->Exit(); 325 326 //context.Dispose(); 333 327 334 328 JsEnd(filename); … … 348 342 349 343 #endif 344
Note:
See TracChangeset
for help on using the changeset viewer.