- Timestamp:
- 06/03/12 22:50:55 (12 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/InterpreterV8.cc
r14055 r14059 191 191 return ThrowException(String::New("Argument 1 must be an uint32.")); 192 192 193 const HandleScope handle_scope;194 195 193 JsSleep(args[0]->Int32Value()); 196 194 197 195 return Undefined(); 196 } 197 198 Handle<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 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()); 198 224 } 199 225 … … 272 298 dim->Set(String::New("wait"), FunctionTemplate::New(WrapWait), ReadOnly); 273 299 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); 274 303 275 304 Handle<ObjectTemplate> global = ObjectTemplate::New(); 276 305 global->Set(String::New("dim"), dim, ReadOnly); 277 306 global->Set(String::New("include"), FunctionTemplate::New(WrapInclude), ReadOnly); 278 global->Set(String::New("sleep"), FunctionTemplate::New(WrapSleep), ReadOnly);279 307 global->Set(String::New("exit"), FunctionTemplate::New(WrapExit), ReadOnly); 280 308 global->Set(String::New("version"), FunctionTemplate::New(InterpreterV8::FuncVersion), ReadOnly); … … 293 321 for (auto it=map.begin(); it!=map.end(); it++) 294 322 args->Set(String::New(it->first.c_str()), String::New(it->second.c_str())); 323 context->Global()->Set(String::New("$"), args); 295 324 context->Global()->Set(String::New("arg"), args); 296 325 -
trunk/FACT++/src/InterpreterV8.h
r14055 r14059 28 28 v8::Handle<v8::Value> FuncInclude(const v8::Arguments& args); 29 29 v8::Handle<v8::Value> FuncExit(const v8::Arguments& args); 30 v8::Handle<v8::Value> FuncState(const v8::Arguments& args); 31 v8::Handle<v8::Value> FuncName(const v8::Arguments& args); 30 32 31 33 static v8::Handle<v8::Value> FuncVersion(const v8::Arguments&); … … 36 38 static v8::Handle<v8::Value> WrapSleep(const v8::Arguments &args) { if (This) return This->FuncSleep(args); else return v8::Undefined(); } 37 39 static v8::Handle<v8::Value> WrapExit(const v8::Arguments &args) { if (This) return This->FuncExit(args); else return v8::Undefined(); } 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> WrapName(const v8::Arguments &args) { if (This) return This->FuncName(args); else return v8::Undefined(); } 38 42 #endif 39 43 … … 58 62 virtual void JsSleep(uint32_t) { } 59 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 ""; }; 60 66 61 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.