bool CJson:: matchHier1(const ValueP &value, int /*ind*/, const std::string &lhs, const std::string &rhs, const std::vector<std::string> &keys, Values &ivalues, Values &values) { if (! value->isObject()) { if (! isQuiet()) std::cerr << value->typeName() << " is not an object" << std::endl; return false; } Object *obj = value->cast<Object>(); // name ValueP lvalue; if (obj->getNamedValue(lhs, lvalue)) ivalues.push_back(lvalue); // hier object ValueP rvalue; if (obj->getNamedValue(rhs, rvalue)) { if (! rvalue->isArray()) { if (! isQuiet()) std::cerr << rvalue->typeName() << " is not an object" << std::endl; return false; } Array *array = rvalue->cast<Array>(); int i = 0; for (auto &v : array->values()) { Values ivalues1 = ivalues; matchHier1(v, i, lhs, rhs, keys, ivalues1, values); ++i; } } else { Values kvalues; for (const auto &k : keys) { ValueP kvalue; if (obj->getNamedValue(k, kvalue)) kvalues.push_back(kvalue); } String *str = hierValuesToKey(ivalues, kvalues); values.push_back(ValueP(str)); } return true; }
bool CJson:: matchObject(const ValueP &value, const std::string &match, ValueP &value1) { if (isDebug()) std::cerr << "matchObject \'" << match << "\'" << std::endl; if (! value->isObject()) { if (! isQuiet()) std::cerr << value->typeName() << " is not an object" << std::endl; return false; } Object *obj = value->cast<Object>(); if (match == "?" || match == "?keys") { std::vector<std::string> names; obj->getNames(names); Array *array = createArray(); for (const auto &n : names) { String *str = createString(n); array->addValue(ValueP(str)); } value1 = ValueP(array); } else if (match == "?type") { String *str = createString(obj->typeName()); value1 = ValueP(str); } else if (match == "?values") { Values values; obj->getValues(values); Array *array = createArray(); for (const auto &v : values) array->addValue(v); value1 = ValueP(array); } else { if (! obj->getNamedValue(match, value1)) { if (! isQuiet()) std::cerr << "no value \'" << match << "\'" << std::endl; return false; } } return true; }
void printJSError(JSContext *cx, const char *message, JSErrorReport *report) {// begin printJSError int quiet=isQuiet(); char buf[4]; FILE *fd = fopen(report->filename,"rb"); if(quiet) GUI_Verbose(); if( fd ){ fread(buf,1,4,fd); fclose(fd); } if( strncmp(buf,"//AD",4) ){ GUI_Error_HIG("Spidermonkey ECMAScript Error", "Not an ECMAScript file. Try open it with 'File' -> 'Open...'"); }else{ GUI_Error_HIG("Spidermonkey ECMAScript Error", "file: %s: line %d:\n Msg:%s\n", report->filename, report->lineno, message); } if(quiet) GUI_Quiet(); }// end printJSError
void Grammar::process( void ) { RuleTable::get()->findPrecedences(); /// Compute the lambda-nonterminals and the first-sets for every /// nonterminal findFirstSets(); // Compute all LR(0) states. Also record follow-set propagation // links so that the follow-set can be computed later findStates(); // Tie up loose ends on the propagation links findLinks(); // Compute the follow set of every reducible configuration findFollowSets(); // Compute the action tables findActions(); // Compress the action tables if ( isCompressActions() ) compressTables(); // Generate a report of the parser generated. (the "y.output" file) */ if ( ! isQuiet() ) reportOutput(); // Generate the source code for the parser outputFiles(); }
void Logging::init(const char* programName, const Configuration& conf) { // Set glog's parameters through Google Flags variables string logDir = getLogDir(conf); if (logDir == "") { FLAGS_logtostderr = true; } else { if (mkdir(logDir.c_str(), 0755) < 0 && errno != EEXIST) { fatalerror("Failed to create log directory %s", logDir.c_str()); } FLAGS_log_dir = logDir; } FLAGS_logbufsecs = conf.get<int>("log_buf_secs", 0); google::InitGoogleLogging(programName); if (!isQuiet(conf)) { google::SetStderrLogging(google::INFO); } LOG(INFO) << "Logging to " << (FLAGS_logtostderr ? "<stderr>" : FLAGS_log_dir); }
void DIA_encoding::setFrame(uint32_t nb,uint32_t total) { uint32_t tim; #define ETA_SAMPLE_PERIOD 60000 //Use last n millis to calculate ETA #define GUI_UPDATE_RATE 500 static uint32_t _lastnb=0; ADM_assert(dialog); // // nb/total=timestart/totaltime -> total time =timestart*total/nb // // if(nb < _lastnb || _lastnb == 0) // restart ? { _lastnb = nb; clock.reset(); _lastTime=clock.getElapsedMS(); _lastFrame=0; _fps_average=0; _nextUpdate = _lastTime + GUI_UPDATE_RATE; _nextSampleStartTime=_lastTime + ETA_SAMPLE_PERIOD; _nextSampleStartFrame=0; if(tray) tray->setPercent(0); UI_purge(); return; } _lastnb = nb; tim=clock.getElapsedMS(); // printf("%lu / %lu\n",tim,_lastTime); if(_lastTime > tim) return; if( tim < _nextUpdate) return ; _nextUpdate = tim+GUI_UPDATE_RATE; sprintf(string,"%lu/%lu",nb,total); gtk_label_set_text(GTK_LABEL(WID(label_frame)),string); // compute fps uint32_t deltaFrame, deltaTime; deltaTime=tim-_lastTime; deltaFrame=nb-_lastFrame; sprintf(string,"%lu",(uint32_t)( deltaFrame*1000.0 / deltaTime )); gtk_label_set_text(GTK_LABEL(WID(label_fps)),string); uint32_t hh,mm,ss; double framesLeft=(total-nb); ms2time((uint32_t)floor(0.5+deltaTime*framesLeft/deltaFrame),&hh,&mm,&ss); sprintf(string,"%02d:%02d:%02d",hh,mm,ss); gtk_label_set_text(GTK_LABEL(WID(label_eta)),string); // Check if we should move on to the next sample period if (tim >= _nextSampleStartTime + ETA_SAMPLE_PERIOD ) { _lastTime=_nextSampleStartTime; _lastFrame=_nextSampleStartFrame; _nextSampleStartTime=tim; _nextSampleStartFrame=0; } else if (tim >= _nextSampleStartTime && _nextSampleStartFrame == 0 ) { // Store current point for use later as the next sample period. // _nextSampleStartTime=tim; _nextSampleStartFrame=nb; } // update progress bar float f=nb; f=f/total; if(tray) tray->setPercent((int)(f*100.)); gtk_progress_set_percentage(GTK_PROGRESS(WID(progressbar1)),(gfloat)f); sprintf(string,"Done : %02d%%",(int)(100*f)); if(isQuiet()) printf("[Encoding]%s\n",string); gtk_progress_bar_set_text (GTK_PROGRESS_BAR(WID(progressbar1)), string); UI_purge(); }
bool CJson:: matchArray(const ValueP &value, const std::string &lhs, const std::string &rhs, Values &values) { if (isDebug()) std::cerr << "matchArray \'" << lhs << "\' \'" << rhs << "\'" << std::endl; if (! value->isArray()) { if (! isQuiet()) std::cerr << value->typeName() << " is not an array" << std::endl; return false; } Array *array = value->cast<Array>(); if (lhs[0] != '[' || lhs[lhs.size() - 1] != ']') return false; std::string range = lhs.substr(1, lhs.size() - 2); if (range == "?size") { Number *n = createNumber(array->size()); values.push_back(ValueP(n)); return true; } auto p = range.find(','); if (p != std::string::npos) { std::string match1 = range; std::string lhs1 = match1.substr(0, p); std::string rhs1 = match1.substr(p + 1); bool ok1, ok2; int i1 = CJson::stol(lhs1, ok1); int i2 = CJson::stol(rhs1, ok2); if (! ok1 || ! ok2) { if (! isQuiet()) std::cerr << "Invalid array indices '" << lhs1 << "', '" << rhs1 << "'" << std::endl; return false; } for (int i = i1; i <= i2 && i < int(array->size()); ++i) { ValueP value1 = array->at(i); if (rhs1 != "") matchValues(value1, i, rhs1, values); else values.push_back(value1); } } else if (range != "") { bool ok; int i1 = CJson::stol(range, ok); if (! ok) { if (! isQuiet()) std::cerr << "Invalid array index '" << lhs << "'" << std::endl; return false; } int i = 0; for (const auto &v : array->values()) { if (i == i1) { if (rhs != "") matchValues(v, i, rhs, values); else values.push_back(v); } ++i; } } else { int i = 0; for (const auto &v : array->values()) { if (rhs != "") matchValues(v, i, rhs, values); else values.push_back(v); ++i; } } return true; }
void SchemeThread::run() { double qtime, utime; XSchemeNode* node; if (!init()) return; if (!isQuiet()) printBanner(); pausing=false; while (! threadShouldExit()) { while ( true ) { // schemeNodes.lockArray(); node=schemeNodes.getFirst(); // schemeNodes.unlockArray(); if ( node == NULL ) { break; } // if scoremode is true then qtime will be in seconds else // milliseconds. qtime=node->time; utime = Time::getMillisecondCounterHiRes() ; // this should probably test if the difference between qtime // and utime is less that 1ms, if not then it probably // shouldn't sleep (?) if ( qtime > utime ) { // if scoremode is true then qtime will be in seconds // so this will not happen (which is what we want) wait(1); } else { // schemeNodes.lockArray(); schemeNodes.remove(0, false); // schemeNodes.unlockArray(); // NOTE: the node to process has now been popped from the // queue. i did this while trying to debug the random // crashing. im not sure if this is the right thing to do or // not since this means that flushing the queue, etc will have // no effect on this node. Search for the word POP to see the // places this affects... //lock.enter(); bool keep=node->applyNode(this, 0.0); //lock.exit(); if (keep) { // schemeNodes.lockArray(); schemeNodes.addSorted(comparator,node); // schemeNodes.remove(0, false); // schemeNodes.unlockArray(); } else { delete node; } } node=NULL; } // queue is now empty. if (sprouted && isScoreMode()) closeScore(); sprouted=false; scoretime=0.0; // setScoreMode(ScoreTypes::Empty); only done in closeScore #ifdef GRACE wait(-1); #else read(); #endif } // leaving killed process.... }
void DIA_encoding::updateUI(void) { uint32_t tim; ADM_assert(dialog); // // nb/total=timestart/totaltime -> total time =timestart*total/nb // // if(!_lastnb) return; tim=clock.getElapsedMS(); if(_lastTime > tim) return; if( tim < _nextUpdate) return ; _nextUpdate = tim+GUI_UPDATE_RATE; sprintf(string,"%lu",_lastnb); gtk_label_set_text(GTK_LABEL(WID(label_frame)),string); sprintf(string,"%lu",_total); gtk_label_set_text(GTK_LABEL(WID(label_totalframe)),string); // Average bitrate on the last second uint32_t sum=0,aquant=0,gsum; for(int i=0;i<_roundup;i++) { sum+=_bitrate[i].size; aquant+=_bitrate[i].quant; } aquant/=_roundup; sum=(sum*8)/1000; // Now compute global average bitrate float whole=_videoSize,second; second=_lastnb; second/=_fps1000; second*=1000; whole/=second; whole/=1000; whole*=8; gsum=(uint32_t)whole; setBitrate(sum,gsum); setQuantIn(aquant); // compute fps uint32_t deltaFrame, deltaTime; deltaTime=tim-_lastTime; deltaFrame=_lastnb-_lastFrame; _fps_average =(float)( deltaFrame*1000.0F / deltaTime ); sprintf(string,"%.2f",_fps_average); gtk_label_set_text(GTK_LABEL(WID(label_fps)),string); uint32_t hh,mm,ss; double framesLeft=(_total-_lastnb); ms2time(tim,&hh,&mm,&ss); sprintf(string,"%02d:%02d:%02d",hh,mm,ss); gtk_label_set_text(GTK_LABEL(WID(label_elapsed)),string); gtk_label_set_text(GTK_LABEL(WID(label_eta)), ms2timedisplay((uint32_t) floor(0.5 + deltaTime * framesLeft / deltaFrame))); // Check if we should move on to the next sample period if (tim >= _nextSampleStartTime + ETA_SAMPLE_PERIOD ) { _lastTime=_nextSampleStartTime; _lastFrame=_nextSampleStartFrame; _nextSampleStartTime=tim; _nextSampleStartFrame=0; } else if (tim >= _nextSampleStartTime && _nextSampleStartFrame == 0 ) { // Store current point for use later as the next sample period. // _nextSampleStartTime=tim; _nextSampleStartFrame=_lastnb; } // update progress bar float f=_lastnb; f=f/_total; if(tray) tray->setPercent((int)(f*100.)); gtk_progress_set_percentage(GTK_PROGRESS(WID(progressbar1)),(gfloat)f); sprintf(string,QT_TR_NOOP("%d%%"),(int)(100*f)); if(isQuiet()) printf("[Encoding]%s\n",string); gtk_progress_bar_set_text (GTK_PROGRESS_BAR(WID(progressbar1)), string); _totalSize=_audioSize+_videoSize; setSize(_totalSize>>20); setAudioSizeIn((_audioSize>>20)); setVideoSizeIn((_videoSize>>20)); UI_purge(); }