Changeset 15139 for trunk/FACT++
- Timestamp:
- 03/22/13 22:45:30 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/InterpreterV8.cc
r15138 r15139 148 148 TryCatch exception; 149 149 150 //const Handle<Script> sleep = Script::Compile(String::New("v8.sleep();"), String::New("internal"));151 //if (sleep.IsEmpty())152 // return Undefined();153 154 150 Handle<Function> func = Handle<Function>::Cast(args[1]); 155 151 … … 163 159 const Handle<Value> rc = func->Call(func, args.Length()-2, argv); 164 160 if (!rc.IsEmpty() && !rc->IsUndefined()) 165 return rc;161 return handle_scope.Close(rc); 166 162 167 163 if (!null && Time()-t>=boost::posix_time::milliseconds(abs(timeout))) 168 164 break; 169 170 // We cannot sleep directly because we have to give control back to171 // JavaScript ever now and then. This also allows us to catch172 // exceptions, either from the preemption or ConvertEvent173 //sleep->Run();174 165 175 166 // Theoretically, the CPU usage can be reduced by maybe a factor … … 1220 1211 HandleScope handle_scope; 1221 1212 1222 //const Handle<Script> sleep = Script::Compile(String::New("v8.sleep();"), String::New("internal"));1223 //if (sleep.IsEmpty())1224 // return Undefined();1225 1226 1213 const Handle<String> data = String::New("data"); 1227 1214 const Handle<String> object = String::New("obj"); … … 1244 1231 1245 1232 // Protect against the return of an exception 1246 if ( !val.IsEmpty() &&val->IsObject())1233 if (val->IsObject()) 1247 1234 { 1248 if (!named) 1235 const Handle<Object> event = val->ToObject(); 1236 const Handle<Value> obj = event->Get(named?object:data); 1237 if (!obj.IsEmpty()) 1249 1238 { 1250 const Handle<Object> event = val->ToObject(); 1251 const Handle<Value> obj = event->Get(data); 1252 1253 // No names (no 'obj'), but 'data' 1254 if (!obj.IsEmpty() && !obj->IsUndefined()) 1255 return handle_scope.Close(val); 1256 } 1257 else 1258 { 1259 const Handle<Object> event = val->ToObject(); 1260 const Handle<Value> obj = event->Get(object); 1261 1262 if (!obj.IsEmpty() && obj->IsObject()) 1239 if (!named) 1240 { 1241 // No names (no 'obj'), but 'data' 1242 if (!obj->IsUndefined()) 1243 return handle_scope.Close(val); 1244 } 1245 else 1263 1246 { 1264 1247 // Has names and data was received? 1265 if (obj-> ToObject()->GetOwnPropertyNames()->Length()>0)1248 if (obj->IsObject() && obj->ToObject()->GetOwnPropertyNames()->Length()>0) 1266 1249 return handle_scope.Close(val); 1267 1250 } … … 1275 1258 if (!null && Time()-t>=boost::posix_time::milliseconds(abs(timeout))) 1276 1259 break; 1277 1278 // We cannot sleep directly because we have to give control back to1279 // JavaScript ever now and then. This also allows us to catch1280 // exceptions, either from the preemption or ConvertEvent1281 //sleep->Run();1282 1260 1283 1261 // Theoretically, the CPU usage can be reduced by maybe a factor … … 1687 1665 1688 1666 if (!args.IsConstructCall()) 1689 return Constructor(args);1667 return handle_scope.Close(Constructor(args)); 1690 1668 1691 1669 Handle<Function> function = … … 1722 1700 1723 1701 if (!args.IsConstructCall()) 1724 return Constructor(args);1702 return handle_scope.Close(Constructor(args)); 1725 1703 1726 1704 Handle<Function> function = … … 1758 1736 1759 1737 if (!args.IsConstructCall()) 1760 return Constructor(args);1738 return handle_scope.Close(Constructor(args)); 1761 1739 1762 1740 Handle<Function> function =
Note:
See TracChangeset
for help on using the changeset viewer.