Changeset 14084
- Timestamp:
- 06/05/12 17:28:10 (12 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 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 -
trunk/FACT++/src/InterpreterV8.h
r14068 r14084 29 29 v8::Handle<v8::Value> FuncExit(const v8::Arguments& args); 30 30 v8::Handle<v8::Value> FuncState(const v8::Arguments& args); 31 v8::Handle<v8::Value> Func Name(const v8::Arguments& args);31 v8::Handle<v8::Value> FuncInfo(const v8::Arguments& args); 32 32 33 33 static v8::Handle<v8::Value> FuncVersion(const v8::Arguments&); … … 39 39 static v8::Handle<v8::Value> WrapExit(const v8::Arguments &args) { if (This) return This->FuncExit(args); else return v8::Undefined(); } 40 40 static v8::Handle<v8::Value> WrapState(const v8::Arguments &args) { if (This) return This->FuncState(args); else return v8::Undefined(); } 41 static v8::Handle<v8::Value> Wrap Name(const v8::Arguments &args) { if (This) return This->FuncName(args);else return v8::Undefined(); }41 static v8::Handle<v8::Value> WrapInfo(const v8::Arguments &args) { if (This) return This->FuncInfo(args); else return v8::Undefined(); } 42 42 #endif 43 43 … … 53 53 } 54 54 55 virtual void JsLoad(const std::string &) { }56 virtual void JsStart(const std::string &) { }57 virtual void JsEnd(const std::string &) { }58 virtual void JsPrint(const std::string &) { }59 virtual void JsResult(const std::string &) { }60 virtual void JsException(const std::string &) { }61 virtual bool JsSend(const std::string &) { return true; }62 virtual void JsSleep(uint32_t) { }63 virtual int JsWait(const std::string &, int32_t, uint32_t) { return -1; };64 virtual int JsState(const std::string &) { return -3; };65 virtual std::string JsName(const std::string &) { return ""; };55 virtual void JsLoad(const std::string &) { } 56 virtual void JsStart(const std::string &) { } 57 virtual void JsEnd(const std::string &) { } 58 virtual void JsPrint(const std::string &) { } 59 virtual void JsResult(const std::string &) { } 60 virtual void JsException(const std::string &) { } 61 virtual bool JsSend(const std::string &) { return true; } 62 virtual void JsSleep(uint32_t) { } 63 virtual int JsWait(const std::string &, int32_t, uint32_t) { return -1; }; 64 virtual std::pair<int32_t, std::string> JsState(const std::string &) { return std::make_pair(-256, ""); }; 65 virtual void *JsSubscribe(const std::string &) { return 0; }; 66 66 67 67 bool JsRun(const std::string &, const std::map<std::string,std::string> & = std::map<std::string,std::string>());
Note:
See TracChangeset
for help on using the changeset viewer.