Changeset 14655
- Timestamp:
- 11/19/12 00:04:52 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/InterpreterV8.cc
r14643 r14655 1146 1146 Handle<Value> InterpreterV8::FuncSubscription(const Arguments &args) 1147 1147 { 1148 if (args.Length()!=1 )1149 return ThrowException(String::New("Number of arguments must be exactly 1."));1148 if (args.Length()!=1 && args.Length()!=2) 1149 return ThrowException(String::New("Number of arguments must be one or two.")); 1150 1150 1151 1151 if (!args[0]->IsString()) 1152 1152 return ThrowException(String::New("Argument 1 must be a string.")); 1153 1154 if (args.Length()==2 && !args[1]->IsFunction()) 1155 return ThrowException(String::New("Argument 2 must be a function.")); 1153 1156 1154 1157 const String::AsciiValue str(args[0]); … … 1163 1166 } 1164 1167 1165 void *ptr = JsSubscribe(*str); 1166 if (ptr==0) 1167 return ThrowException(String::New(("Subscription to '"+string(*str)+"' already exists.").c_str())); 1168 1169 HandleScope handle_scope; 1168 const HandleScope handle_scope; 1170 1169 1171 1170 Handle<Object> This = args.This(); … … 1174 1173 This->Set(String::New("name"), String::New(*str), ReadOnly); 1175 1174 This->Set(String::New("isOpen"), Boolean::New(true)); 1175 1176 if (args.Length()==2) 1177 This->Set(String::New("onchange"), args[1]); 1178 1179 fReverseMap[*str] = Persistent<Object>::New(This); 1180 1181 void *ptr = JsSubscribe(*str); 1182 if (ptr==0) 1183 return ThrowException(String::New(("Subscription to '"+string(*str)+"' already exists.").c_str())); 1184 1176 1185 This->SetInternalField(0, External::New(ptr)); 1177 1178 fReverseMap[*str] = Persistent<Object>::New(This);1179 1186 1180 1187 return Undefined(); … … 1621 1628 // CORE 1622 1629 // ========================================================================== 1630 1631 InterpreterV8::InterpreterV8() : fThreadId(-1) 1632 { 1633 const string ver(V8::GetVersion()); 1634 1635 typedef boost::char_separator<char> separator; 1636 const boost::tokenizer<separator> tokenizer(ver, separator(".")); 1637 1638 const vector<string> tok(tokenizer.begin(), tokenizer.end()); 1639 1640 const int major = tok.size()>0 ? stol(tok[0]) : -1; 1641 const int minor = tok.size()>1 ? stol(tok[1]) : -1; 1642 const int build = tok.size()>2 ? stol(tok[2]) : -1; 1643 1644 if (major>3 || (major==3 && minor>9) || (major==3 && minor==9 && build>10)) 1645 { 1646 const string argv = "--use_strict"; 1647 V8::SetFlagsFromString(argv.c_str(), argv.size()); 1648 } 1649 1650 This = this; 1651 } 1623 1652 1624 1653 Handle<Value> InterpreterV8::Constructor(/*Handle<FunctionTemplate> T,*/ const Arguments &args) … … 1697 1726 bool InterpreterV8::JsRun(const string &filename, const map<string, string> &map) 1698 1727 { 1699 //const string argv = "--prof";1700 //V8::SetFlagsFromString(argv.c_str(), argv.size());1701 1702 1728 const Locker locker; 1703 1729 fThreadId = V8::GetCurrentThreadId();
Note:
See TracChangeset
for help on using the changeset viewer.