CSize CXTPPropertyGridItemSize::StringToSize(LPCTSTR str) { int nWidth = NextNumber(str); int nHeight = NextNumber(str); return CSize(nWidth, nHeight); }
CPoint CXTPPropertyGridItemPoint::StringToPoint(LPCTSTR str) { int x = NextNumber(str); int y = NextNumber(str); return CPoint(x, y); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - unsigned ValueNumber::GetValueNumber(Operand* op) { unsigned valNumb; // Check if the operand is defined by an instruction; // in this case we use the value number of the expression. // An exception is for 'load', 'phi' and most 'call' instructions. if(auto definingInstr = op->DefiningInstruction()) { if(resultOpValNumbers_.TryGetValue(op, &valNumb)) { return valNumb; } if((definingInstr->IsLoad() || definingInstr->IsPhi() || definingInstr->IsCall()) == false) { return GetValueNumber(CreateExpession(definingInstr)); } else if(auto callInstr = definingInstr->As<CallInstr>()) { if(IsCallSafe(callInstr)) { return GetValueNumber(CreateExpession(definingInstr)); } } } // Check if the operand has already a value number. if(opValNumbers_.TryGetValue(op, &valNumb)) { return valNumb; } valNumb = NextNumber(); opValNumbers_.Add(op, valNumb); return valNumb; }
void MusicPlayer::AddSound(string filename) { IStreamingSoundResourcePtr resource = ResourceManager<IStreamingSoundResource>::Create(filename); // ISoundResourcePtr resource = // ResourceManager<ISoundResource>::Create(filename); ISound* sound = system->CreateSound(resource); // @todo: ugly cast only for testing if (sound->IsStereoSound()) { IMonoSound* left = ((IStereoSound*)sound)->GetLeft(); left->SetRelativePosition(true); left->SetPosition(Vector<3,float>(-10.0,0.0,0.0)); IMonoSound* right = ((IStereoSound*)sound)->GetRight(); right->SetRelativePosition(true); right->SetPosition(Vector<3,float>(10.0,0.0,0.0)); } else if (sound->IsMonoSound()) { IMonoSound* mono = ((IMonoSound*)sound); mono->SetRelativePosition(true); mono->SetPosition(Vector<3,float>(0.0,0.0,0.0)); } playlist.push_back((ISound*) sound); sound->SetGain(gain); // if we are playing the last number and insert a new // one, then update which number should be next nextTrackNumber = NextNumber(); //@todo: set the sound to be relative to the listener i openal }
void MusicPlayer::Next() { if (playlist.size() == 0) return; if (random) SwitchTo(RandomNumber()); else SwitchTo(NextNumber()); }
void MusicPlayer::SwitchTo(unsigned int trackNumber) { if (playlist.at(current)->IsPlaying()) { nextTrackNumber = trackNumber; switchToNextNumber = true; } else { current = trackNumber; nextTrackNumber = NextNumber(); } // logger.info << "Switching to song number: " << trackNumber+1; // logger.info << " out of " << NumberOfTracks() << logger.end; }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - unsigned ValueNumber::GetValueNumber(Expression& expr, Operand* destOp) { // Search for an existing value number in the current scope, // and if not found, in the parent table. unsigned valNumb; if(expValNumbers_.TryGetValue(expr, &valNumb)) { return valNumb; } // Create a value number. valNumb = NextNumber(); expValNumbers_.Add(expr, valNumb); if(destOp) resultOpValNumbers_.Add(destOp, valNumb); return valNumb; }
// Get the next token NNT Lexer::Next() { restart: // Delegate based on the next character in the file stream if (ifs.eof()) { RETURN_NNT("", eof, 0); } else if (IsAlphaOrUnderscore(*cursor)) { return NextWord(); } else if (IsDigit(*cursor)) { return NextNumber(); } switch (*cursor) { case '\t': case ' ': IncrementCursor(); goto restart; // Explicit TCO case '\0': IncrementCursor(); RETURN_NNT("", newline, 0); default: return NextOperator(); } }
unsigned int MusicPlayer::RandomNumber() { unsigned int switchTo = randGen->UniformInt(0,NumberOfTracks()-1); if (switchTo == current && NumberOfTracks() > 1) return NextNumber(); return switchTo; }