// Update void key_manager::update(){ // Pressing them keys // You haven't won if(!switch_flicked){ // Got a correct letter if((key_queue.size() > 0) && (!joystick_enabled && key[key_queue.at(0).getValue()] && keyIsPressed == false) || (joystick_enabled && joy[0].button[key_queue.at(0).getValue()].b && buttonIsPressed == false)){ // Nice sound play_sample( sounds[1],255,125,1000,0); key_queue.erase( key_queue.begin()); // Add key to queue if( joystick_enabled){ key_data newKey(random(0,3)); key_queue.push_back(newKey); } else{ key_data newKey(random(KEY_LEFT, KEY_DOWN)); key_queue.push_back(newKey); } // Increase speed if( stair::scrollSpeed < stair::maxScrollSpeed) stair::scrollSpeed += 0.8; } else if( (keyDown() && keyIsPressed == false) || (buttonDown() && buttonIsPressed == false)){ if(stair::scrollSpeed > 0) stair::scrollSpeed /= 4; play_sample(sounds[0],255,125,1000,0); } } // Stop else{ stair::scrollSpeed = 0; } // Prevents held keys if(!joystick_enabled){ keyIsPressed = keyDown(); } if(joystick_enabled){ buttonIsPressed = buttonDown(); } // Slow stairs down if( stair::scrollSpeed > 0.01) stair::scrollSpeed -= 0.02; else{ stair::scrollSpeed = 0; } }
KeyFrame Curve::setKeyFrameDerivatives(double left, double right,int index,int* newIndex) { bool evaluateAnimation = false; KeyFrame ret; { QWriteLocker l(&_imp->_lock); KeyFrameSet::iterator it = atIndex(index); assert(it != _imp->keyFrames.end()); if (left != it->getLeftDerivative() || right != it->getRightDerivative()) { KeyFrame newKey(*it); newKey.setLeftDerivative(left); newKey.setRightDerivative(right); it = addKeyFrameNoUpdate(newKey).first; it = evaluateCurveChanged(DERIVATIVES_CHANGED,it); evaluateAnimation = true; } if (newIndex) { *newIndex = std::distance(_imp->keyFrames.begin(),it); } ret = *it; } if (evaluateAnimation && _imp->owner) { _imp->owner->evaluateAnimationChange(); } return ret; }
KeyFrame Curve::setKeyFrameInterpolation(Natron::KeyframeType interp,int index,int* newIndex) { bool evaluateAnimation = false; KeyFrame ret; { QWriteLocker l(&_imp->_lock); KeyFrameSet::iterator it = atIndex(index); assert(it != _imp->keyFrames.end()); ///if the curve is a string_curve or bool_curve the interpolation is bound to be constant. if ((_imp->type == CurvePrivate::STRING_CURVE || _imp->type == CurvePrivate::BOOL_CURVE) && interp != Natron::KEYFRAME_CONSTANT) { return *it; } if (interp != it->getInterpolation()) { KeyFrame newKey(*it); newKey.setInterpolation(interp); it = addKeyFrameNoUpdate(newKey).first; evaluateCurveChanged(KEYFRAME_CHANGED,it); evaluateAnimation = true; } if (newIndex) { *newIndex = std::distance(_imp->keyFrames.begin(),it); } ret = *it; } if (evaluateAnimation && _imp->owner) { _imp->owner->evaluateAnimationChange(); } return ret; }
void EstablishmentManager::processCreated(EstablishmentStatePtr const &state) { state->calculateDHSecret(); if(!state->verifyCreationSignature()) { I2P_LOG(m_log, warning) << "creation signature verification failed"; state->setState(EstablishmentState::State::FAILURE); return; } const ByteArray& dhSecret = state->getDHSecret(); SessionKey newKey(toSessionKey(dhSecret)), newMacKey; state->setSessionKey(newKey); copy(dhSecret.begin() + 32, dhSecret.begin() + 32 + 32, newMacKey.begin()); state->setMacKey(newMacKey); Endpoint ep = state->getTheirEndpoint(); PeerState ps(ep, state->getTheirIdentity().getHash()); ps.setCurrentSessionKey(state->getSessionKey()); ps.setCurrentMacKey(state->getMacKey()); std::lock_guard<std::mutex> lock(m_context.peers.getMutex()); m_context.peers.addPeer(std::move(ps)); PacketPtr p = PacketBuilder::buildSessionConfirmed(state); p->encrypt(state->getSessionKey(), state->getMacKey()); m_context.sendPacket(p); state->setState(EstablishmentState::State::CONFIRMED_SENT); post(state); }
TLSTicketKeyManager::TLSTicketKeySource* TLSTicketKeyManager::insertNewKey(TLSTicketSeed* seed, uint32_t hashCount, TLSTicketKeySource* prevKey) { unsigned char nameBuf[SHA256_DIGEST_LENGTH]; std::unique_ptr<TLSTicketKeySource> newKey(new TLSTicketKeySource); // This function supports hash chaining but it is not currently used. if (prevKey != nullptr) { hashNth(prevKey->keySource_, sizeof(prevKey->keySource_), newKey->keySource_, 1); } else { // can't go backwards or the current is missing, start from the beginning hashNth((unsigned char *)seed->seed_.data(), seed->seed_.length(), newKey->keySource_, hashCount); } newKey->hashCount_ = hashCount; newKey->keyName_ = makeKeyName(seed, hashCount, nameBuf); newKey->type_ = seed->type_; auto it = ticketKeys_.insert(std::make_pair(newKey->keyName_, std::move(newKey))); auto key = it.first->second.get(); if (key->type_ == SEED_CURRENT) { activeKeys_.push_back(key); } VLOG(4) << "Adding key for " << hashCount << " type=" << (uint32_t)key->type_ << " Name=" << SSLUtil::hexlify(key->keyName_); return key; }
BasicKey BasicKeyManager::addLowerGroup(const BasicId & id) { BasicId prefixId(id.at(0)); prefixId += BasicName("0"); return newKey(prefixId, BasicKey::LowerGroup, id.at(2)); }
/** * Since this is going to be deprecated, I'll leave it as it is */ U_CAPI int32_t U_EXPORT2 ucol_keyHashCode(const uint8_t *key, int32_t length) { CollationKey newKey(key, length); return newKey.hashCode(); }
BasicKey BasicKeyManager::addLowerValue(const BasicId & id) { BasicId prefixId(id.at(0)); prefixId += id.at(1); prefixId += id.at(2); return newKey(prefixId, BasicKey::LowerGroup, id.at(3)); }
static QCString decodeKey(const char *key) { QCString newKey(key); newKey.replace("%5b", "["); newKey.replace("%5d", "]"); return newKey; }
static QCString encodeKey(const char *key) { QCString newKey(key); newKey.replace('[', "%5b"); newKey.replace(']', "%5d"); return newKey; }
U_NAMESPACE_END U_CAPI int32_t U_EXPORT2 ucol_keyHashCode(const uint8_t *key, int32_t length) { U_NAMESPACE_QUALIFIER CollationKey newKey(key, length); return newKey.hashCode(); }
KeyFrameSet::iterator Curve::setKeyframeInterpolation_internal(KeyFrameSet::iterator it,Natron::KeyframeType interp) { ///private should not be locked assert(it != _imp->keyFrames.end()); KeyFrame newKey(*it); newKey.setInterpolation(interp); it = addKeyFrameNoUpdate(newKey).first; it = evaluateCurveChanged(KEYFRAME_CHANGED,it); return it; }
RegisterNameForm::RegisterNameForm( QWidget* parent, const QString& label ) :QWidget(parent) { m_ui = new Ui_RegisterNameForm(); m_ui->setupUi(this); m_ui->label->setText(label); connect( m_ui->toolButton, SIGNAL( clicked() ), this, SLOT( newKey() ) ); }
// Init key_manager::key_manager(int newX, int newY){ // Set position x = newX; y = newY; // Add keys for( int i = 0; i < 4; i++){ if(!joystick_enabled){ key_data newKey(random(KEY_LEFT, KEY_DOWN)); key_queue.push_back(newKey); } if(joystick_enabled){ key_data newKey(random(0,3)); key_queue.push_back(newKey); } } // No keys down keyIsPressed = false; }
KeyFrameSet::iterator Curve::setKeyFrameValueAndTimeNoUpdate(double value,double time, KeyFrameSet::iterator k) { // PRIVATE - should not lock KeyFrame newKey(*k); // nothing special has to be done, since the derivatives are with respect to t newKey.setTime(time); newKey.setValue(value); _imp->keyFrames.erase(k); return addKeyFrameNoUpdate(newKey).first; }
bool QSslServer::setPrivateKey(const QString &fileName, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat format, const QByteArray &passPhrase) { bool ret = false; QFile file(fileName); if(file.open(QIODevice::ReadOnly)) { QSslKey newKey(file.readAll(), algorithm, format, QSsl::PrivateKey, passPhrase); if(!newKey.isNull()) { this->configuration.setPrivateKey(newKey); ret = true; } file.close(); } return ret; }
const wchar_t* TcJSONObject::parseValue(QString Key, const wchar_t* ptr) { ptr = skip(ptr); if ( *ptr ) { if ( *ptr==L'\"' ) { QString Value; ptr = skip(parseKey(Value, ptr)); add(newKey(Key), Value); }else if ( *ptr==L'{' ) { TcJSONObject* child = addObject(Key); ptr = skip(child->fromObject(Key, ptr)); }else if ( *ptr==L'[' ) { TcJSONObject* child = addArray(Key); ptr = skip(child->fromArray(ptr)); }else if ( ptr && *ptr && (*ptr==L'+'||*ptr==L'-'||*ptr==L'.'||(*ptr>=L'0'&&*ptr<=L'9')||*ptr==L'E'||*ptr==L'e') ) { QString Value; ptr = skip(parseNumber(Value, ptr)); if ( Value.indexOf(".") >-1 ) { add(newKey(Key), Value.toDouble() ); }else { add(newKey(Key), Value.toInt() ); } }else if ( std::wstring(ptr, 4).compare(L"true")==0 ) { add(newKey(Key), true); ptr+=4; }else if ( std::wstring(ptr, 5).compare(L"false")==0 ) { add(newKey(Key), false); ptr+=5; }else if ( std::wstring(ptr, 4).compare(L"null")==0 ) { add(newKey(Key)); ptr+=4; } } return ptr; }
void EstablishmentManager::processRequest(EstablishmentStatePtr const &state) { state->calculateDHSecret(); PacketPtr p = PacketBuilder::buildSessionCreated(state); p->encrypt(state->getIV(), state->getSessionKey(), state->getMacKey()); const ByteArray& dhSecret = state->getDHSecret(); SessionKey newKey(toSessionKey(dhSecret)), newMacKey; state->setSessionKey(newKey); copy(dhSecret.begin() + 32, dhSecret.begin() + 32 + 32, newMacKey.begin()); state->setMacKey(newMacKey); m_context.sendPacket(p); state->setState(EstablishmentState::State::CREATED_SENT); post(state); }
bool ShortcutEdit::event(QEvent *event) { if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) { QKeyEvent *keyevent = static_cast<QKeyEvent *> (event); switch (keyevent->key()) { case Qt::Key_Shift: case Qt::Key_Control: case Qt::Key_Alt: case Qt::Key_AltGr: emit newModifiers(keyevent->modifiers()); break; default: if (event->type() == QEvent::KeyPress) { emit newKey(keyevent->key()); } } return true; } return QLineEdit::event(event); }
/** A keychooser changed. Update and emit a signal if necessary. */ void CBookKeyChooser::keyChooserChanged(int /*newIndex*/) { const int activeID = boxes[const_cast<QObject*>(sender())]; //no so good code! QStringList items; CKeyChooserWidget* chooser; for (int i = 0; i < m_chooserWidgets.count(); ++i) { chooser = m_chooserWidgets.at(i); const QString currentText = (chooser && chooser->comboBox()) ? chooser->comboBox()->currentText() : QString::null; if (currentText.isEmpty() || i > activeID) { break; } items << currentText; } QString newKey("/"); newKey.append(items.join("/")); m_key->key(newKey); setKey(m_key); }
// renyang - 只是用來判斷完成某件事情的訊號 void Receiver::emitSignal(signal_type type) { #ifdef REN_DEBUG qWarning(QString("Receiver::emitSignal(signal_type %1)").arg(type)); #endif switch(type) { case SIGNAL_FINISH: emit finishSignal(); break; if (working) { case SIGNAL_INIT: emit initSignal(); break; case SIGNAL_RING: emit ringSignal(); break; // renyang - 回覆答鈴 case SIGNAL_RINGREPLY: emit ringReplySignal(); break; case SIGNAL_SENDNEWKEY: emit sendNewKey(); break; case SIGNAL_KEYREQUEST: emit keyRequest(); break; case SIGNAL_NEWKEY: QString text = blowfish->isAsciiKey() ? blowfish->getPass() : "random key"; emit newKey(text); break; } default: break; } }
KeyFrameSet::iterator Curve::refreshDerivatives(Curve::CurveChangedReason reason, KeyFrameSet::iterator key) { // PRIVATE - should not lock double tcur = key->getTime(); double vcur = key->getValue(); double tprev, vprev, tnext, vnext, vprevDerivRight, vnextDerivLeft; Natron::KeyframeType prevType, nextType; if (key == _imp->keyFrames.begin()) { tprev = tcur; vprev = vcur; vprevDerivRight = 0.; prevType = Natron::KEYFRAME_NONE; } else { KeyFrameSet::const_iterator prev = key; --prev; tprev = prev->getTime(); vprev = prev->getValue(); vprevDerivRight = prev->getRightDerivative(); prevType = prev->getInterpolation(); //if prev is the first keyframe, and not edited by the user then interpolate linearly if (prev == _imp->keyFrames.begin() && prevType != Natron::KEYFRAME_FREE && prevType != Natron::KEYFRAME_BROKEN) { prevType = Natron::KEYFRAME_LINEAR; } } KeyFrameSet::const_iterator next = key; ++next; if (next == _imp->keyFrames.end()) { tnext = tcur; vnext = vcur; vnextDerivLeft = 0.; nextType = Natron::KEYFRAME_NONE; } else { tnext = next->getTime(); vnext = next->getValue(); vnextDerivLeft = next->getLeftDerivative(); nextType = next->getInterpolation(); KeyFrameSet::const_iterator nextnext = next; ++nextnext; //if next is thelast keyframe, and not edited by the user then interpolate linearly if (nextnext == _imp->keyFrames.end() && nextType != Natron::KEYFRAME_FREE && nextType != Natron::KEYFRAME_BROKEN) { nextType = Natron::KEYFRAME_LINEAR; } } double vcurDerivLeft,vcurDerivRight; assert(key->getInterpolation() != Natron::KEYFRAME_NONE && key->getInterpolation() != Natron::KEYFRAME_BROKEN && key->getInterpolation() != Natron::KEYFRAME_FREE); Natron::autoComputeDerivatives(prevType, key->getInterpolation(), nextType, tprev, vprev, tcur, vcur, tnext, vnext, vprevDerivRight, vnextDerivLeft, &vcurDerivLeft, &vcurDerivRight); KeyFrame newKey(*key); newKey.setLeftDerivative(vcurDerivLeft); newKey.setRightDerivative(vcurDerivRight); std::pair<KeyFrameSet::iterator,bool> newKeyIt = _imp->keyFrames.insert(newKey); // keyframe at this time exists, erase and insert again if (!newKeyIt.second) { _imp->keyFrames.erase(newKeyIt.first); newKeyIt = _imp->keyFrames.insert(newKey); assert(newKeyIt.second); } key = newKeyIt.first; if (reason != DERIVATIVES_CHANGED) { key = evaluateCurveChanged(DERIVATIVES_CHANGED,key); } return key; }
Call::Call(int callId, QString myName) { #ifdef REN_DEBUG qWarning(QString("Call::Call(int %1, QString %2)").arg(callId).arg(myName)); #endif id = callId; sd = -1; dec_state = NULL; dec_state = speex_decoder_init(&speex_uwb_mode); // renyang - Initializes and allocates resources for a SpeexBits struct speex_bits_init(&bits); int enh = 1; speex_decoder_ctl(dec_state, SPEEX_SET_ENH, &enh); speex_decoder_ctl(dec_state, SPEEX_GET_FRAME_SIZE, &frame_size); if ((outBuffer = (float *) malloc(frame_size*4*sizeof(float)))==NULL) throw Error(Error::IHU_ERR_MEMORY); if ((soundBuffer = (float *) malloc(MAXBUFSIZE*sizeof(float)))==NULL) throw Error(Error::IHU_ERR_MEMORY); readyFrames = 0; rsa = new Rsa(RSA_STRENGTH); transmitter = new Transmitter(rsa); receiver = new Receiver(rsa); // renyang-modify 建立一個ip handler sctpiphandler = new SctpIPHandler(); // renyang-modify - 當某一個ip沒有一段時間後, 沒有辦法收到data, 要處理 connect(sctpiphandler,SIGNAL(SigAddressConfrim(QString)),this,SLOT(SlotAddressConfirm(QString))); // renyang-modify - 當多次沒有收到資料, 宣告這一個ip失聯 connect(sctpiphandler,SIGNAL(SigAddressFail(QString)),this,SLOT(SlotAddressFail(QString))); // renyang-modify - 某一個ip有收到資料, 宣告這一個ip復活啦 connect(sctpiphandler,SIGNAL(SigAddressAvailable(QString)),this,SLOT(SlotAddressAvailable(QString))); stopTimer = new QTimer(this); active = false; muteRec = false; mutePlay = false; callFree = true; aborted = false; recording = false; // renyang-modify - 初始化IPChanging, 表示最近沒有改變primary address IPChanging = false; // renyang-modify - 建立一個Timer來計數改完primary address後多久要改回IPChanging=false IPChangingTimer = new QTimer(this); connect(IPChangingTimer,SIGNAL(timeout()),this,SLOT(resetIPChanging())); // renyang-modify - 初始化傳送與接收image的index recvImage_index = sendImage_index = 0; transmitter->setMyName(myName); srand(time(NULL)); connect( receiver, SIGNAL(newSocket(int,int,struct sockaddr_in)), this, SLOT(newConnection(int,int,struct sockaddr_in)) ); connect( receiver, SIGNAL(keyRequest()), this, SLOT(sendKeyRequest()) ); connect( receiver, SIGNAL(sendNewKey()), this, SLOT(sendKey()) ); connect( receiver, SIGNAL(newKey(QString)), this, SLOT(receivedNewKey(QString)) ); // renyang - 沒有再接收到client端傳送過來的訊息, 結束此Call connect( receiver, SIGNAL(finishSignal()), this, SLOT(stopCall()) ); connect( receiver, SIGNAL(error(QString)), this, SLOT(abortCall(QString)) ); connect( receiver, SIGNAL(warning(QString)), this, SLOT(warning(QString)) ); connect( receiver, SIGNAL(message(QString)), this, SLOT(warning(QString)) ); // renyang - 對方接受通話, 或是本地端接受通話 connect( receiver, SIGNAL(connectedSignal()), this, SLOT(connected()) ); connect( receiver, SIGNAL(ringSignal()), this, SLOT(playRing()) ); connect( receiver, SIGNAL(initSignal()), this, SLOT(playInit()) ); connect( receiver, SIGNAL(newAudioData(char*, int)), this, SLOT(decodeAudioData(char*, int)) ); connect( receiver, SIGNAL(ringReplySignal()), transmitter, SLOT(sendRingReplyPacket()) ); // renyang-modify - 接收由receiver傳送上來的peer address connect (receiver,SIGNAL(SignalgetIps(QStringList)),this,SLOT(SlotgetIps(QStringList))); // renyang-modify - 當Receiver接收到與之前的primary不同時, 要求改變primary address connect (receiver,SIGNAL(setPrimaddrSignal(QString)),this,SLOT(setPrimaddr(QString))); // renyang-modify - 當Receiver接收到事件時, 會通知上層的Call, 以便修改CallTab的ip list情況 connect (receiver,SIGNAL(SigAddressEvent(QString,QString)),this,SLOT(SlotAddressEvent(QString,QString))); // renyang-modify - 對方要求影像 connect (receiver,SIGNAL(requestImage()),this,SLOT(SlotGetImage())); // renyang-modify - 由receiver接收到image資料, 並處理這一些資料 connect (receiver,SIGNAL(newVideoData(char *,int)),this,SLOT(decodeVideoData(char *,int))); // renyang-modify - 當收到想要接收目前封包的下一部分時... connect (receiver,SIGNAL(requestNextImage()),this,SLOT(sendVideo())); // renyang-modify - 接收到完整的image,準備把它放到video_label connect (receiver,SIGNAL(completeImage()),this,SLOT(processImage())); // renyang-modify - 跟對方要求影像失敗 connect (receiver,SIGNAL(requestImageFail()),this,SLOT(SlotrequestImageFail())); // renyang-modify - end connect( transmitter, SIGNAL(ringMessage()), this, SLOT(ringMessage()) ); connect( transmitter, SIGNAL(finishSignal()), this, SLOT(stopCall()) ); connect( transmitter, SIGNAL(error(QString)), this, SLOT(abortCall(QString)) ); connect( transmitter, SIGNAL(message(QString)), this, SLOT(message(QString)) ); connect( transmitter, SIGNAL(startSignal()), this, SLOT(startRecorder()) ); connect( stopTimer, SIGNAL(timeout()), this, SLOT(close()) ); // renyang-modify - 初始化streamno streamno = 1; }
// updateitem notification handler void JsonDbSortingListModelPrivate::updateItem(const QVariantMap &changedItem, int partitionIndex) { Q_Q(JsonDbSortingListModel); QVariantMap item = changedItem; if (isCallable) generateCustomData(item); QString uuid = item.value(QLatin1String("_uuid")).toString(); QMap<QString, SortingKey>::const_iterator keyIndex = objectSortValues.constFind(uuid); if (keyIndex != objectSortValues.constEnd()) { SortingKey key = keyIndex.value(); SortingKey newKey(partitionIndex, item, ascendingOrders, orderPaths); QMap<SortingKey, QString>::const_iterator begin = objectUuids.constBegin(); QMap<SortingKey, QString>::const_iterator end = objectUuids.constEnd(); QMap<SortingKey, QString>::const_iterator oldPos = objectUuids.constFind(key); int oldIndex = iterator_position(begin, end, oldPos); // keys are same, modify the object if (key == newKey) { objects.remove(uuid); objects.insert(uuid, item); QModelIndex modelIndex = q->createIndex(oldIndex, 0); emit q->dataChanged(modelIndex, modelIndex); return; } // keys are different QMap<SortingKey, QString>::const_iterator newPos = objectUuids.upperBound(newKey); int newIndex = iterator_position(begin, end, newPos); if (overflow && oldIndex <= limit-1 && newIndex >= limit-1) { // new position is the last or beyond the limit // this will do a refresh deleteItem(item, partitionIndex); return; } if (newIndex != oldIndex && newIndex != oldIndex+1) { q->beginMoveRows(parent, oldIndex, oldIndex, parent, newIndex); objects.remove(uuid); objects.insert(uuid, item); objectUuids.remove(key); objectUuids.insert(newKey, uuid); objectSortValues.remove(uuid); objectSortValues.insert(uuid, newKey); q->endMoveRows(); } else { // same position, update the object objects.remove(uuid); objects.insert(uuid, item); objectUuids.remove(key); objectUuids.insert(newKey, uuid); objectSortValues.remove(uuid); objectSortValues.insert(uuid, newKey); } newPos = objectUuids.constFind(newKey); begin = objectUuids.constBegin(); end = objectUuids.constEnd(); newIndex = iterator_position(begin, end, newPos); QModelIndex modelIndex = q->createIndex(newIndex, 0); emit q->dataChanged(modelIndex, modelIndex); } else { addItem(item, partitionIndex); } }
void db_key::inToCont(pki_base *pki) { db_base::inToCont(pki); emit newKey((pki_key *)pki); }
BasicKey BasicKeyManager::addUpperValue(const BasicId & id) { return newKey(id.at(0), BasicKey::LowerGroup, id.at(1)); }
BasicKey BasicKeyManager::addUpperGroup(const BasicId & id) { return newKey(BasicId(), BasicKey::LowerGroup, id.at(0)); }
// Find a symbol given by string key of the specified symbol type. Context // information can be specified through ctx, sym, and ar. // // StaticRoot, StaticProp // * Search for a static property given by key in class ctx // * A class name may be encoded with the property as *classname*propname // to indicate a class that should be used as the visibility context for // loading the property static Variant xdebug_lookup_symbol(SymbolType type, String key, Class*& ctx, Variant& sym, ActRec* ar) { char* name = key.get()->mutableData(); char* end = key.get()->mutableData() + key.size(); assert(name != end); switch (type) { case SymbolType::StaticRoot: case SymbolType::StaticProp: { TypedValue* ret = nullptr; if (!ctx) return uninit_null(); Class* newCtx = nullptr; char* secStar; bool vis, acc; if ((ret = ctx->getSProp(ctx, key.get(), vis, acc))) { return tvAsVariant(ret); } for (secStar = name + 1; secStar != end && *secStar != '*'; ++secStar); if (secStar != end && *name == '*' && *secStar == '*') { String clsKey(name + 1, secStar - name - 1, CopyStringMode()); String newKey(secStar + 1, end - secStar - 1, CopyStringMode()); newCtx = Unit::lookupClass(clsKey.get()); if (newCtx && (ret = ctx->getSProp(newCtx, newKey.get(), vis, acc))) { return tvAsVariant(ret); } } return uninit_null(); } break; case SymbolType::Root: { const Func* func = ar->func(); if (key.size() == 4 && strncmp(name, "this", 4) == 0) { return ar->hasThis() ? ar->getThis() : nullptr; } Id localId = func->lookupVarId(key.get()); if (localId != kInvalidId) { TypedValue* tv = frame_local(ar, localId); return tv ? tvAsVariant(tv) : uninit_null(); } Class* tmp = Unit::lookupClass(key.get()); if (tmp) ctx = tmp; return uninit_null(); } break; case SymbolType::ArrayIndexAssoc: { return sym.isArray() ? sym.asArrRef().rvalAt(key) : sym.isObject() ? sym.asObjRef().o_get(key, false) : uninit_null(); } case SymbolType::ArrayIndexNum: { int64_t iKey = key.toInt64(); return sym.isArray() ? sym.asArrRef().rvalAt(iKey) : uninit_null(); } case SymbolType::ObjProp: { char* secStar; if (!sym.is(KindOfObject)) return uninit_null(); Object obj = sym.toObject(); Variant v = obj->o_get(key, false); if(!v.isNull()) return v; for (secStar = name + 1; secStar != end && *secStar != '*'; ++secStar); if (secStar != end && *name == '*' && *secStar == '*') { String clsKey(name + 1, secStar - name - 1, CopyStringMode()); String newKey(secStar + 1, end - secStar - 1, CopyStringMode()); v = obj.o_get(key, false, clsKey); } return v; } } not_reached(); }
Segment * SegmentJoinCommand::makeSegment(SegmentVec oldSegments) { // We can proceed even if composition is NULL, just normalize // rests will do less. Composition *composition = oldSegments[0]->getComposition(); // Find the leftmost segment's index and the rightmost segment's // index. timeT t0 = oldSegments[0]->getStartTime(); timeT t1 = oldSegments[0]->getEndMarkerTime(); size_t leftmostIndex = 0; size_t rightmostIndex = 0; for (size_t i = 1; i < oldSegments.size(); ++i) { timeT startTime = oldSegments[i]->getStartTime(); if (startTime < t0) { t0 = startTime; leftmostIndex = i; } timeT endMarkerTime = oldSegments[i]->getEndMarkerTime(); if (endMarkerTime > t1) { t1 = endMarkerTime; rightmostIndex = i; } } // Always begin with the leftmost segment to keep in the new segment // any clef or key change found at the start of this segment. Segment *newSegment = oldSegments[leftmostIndex]->clone(false); // drop any events beyond the end marker newSegment->setEndTime(newSegment->getEndMarkerTime()); // that duplicated the leftmost segment; now do the rest // we normalize rests in any overlapping areas timeT overlapStart = 0, overlapEnd = 0; bool haveOverlap = false; for (size_t i = 0; i < oldSegments.size(); ++i) { // Don't add twice the first old segment if (i == leftmostIndex) continue; Segment *s = oldSegments[i]; timeT start = s->getStartTime(), end = s->getEndMarkerTime(); timeT os = 0, oe = 0; bool haveOverlapHere = false; if (start < newSegment->getEndMarkerTime() && end > newSegment->getStartTime()) { haveOverlapHere = true; os = std::max(start, newSegment->getStartTime()); oe = std::min(end, newSegment->getEndMarkerTime()); RG_DEBUG << "overlap here, os = " << os << ", oe = " << oe; } if (haveOverlapHere) { if (haveOverlap) { overlapStart = std::min(overlapStart, os); overlapEnd = std::max(overlapEnd, oe); } else { overlapStart = os; overlapEnd = oe; haveOverlap = true; } } if (start > newSegment->getEndMarkerTime()) { newSegment->setEndMarkerTime(start); } for (Segment::iterator si = s->begin(); ; ++si) { // If we're in the rightmost segment if (i == rightmostIndex) { // Copy all of the events to the end if (si == s->end()) break; } else { // Just copy up to the End Marker of this segment. if (!s->isBeforeEndMarker(si)) break; } // weed out duplicate clefs and keys if ((*si)->isa(Clef::EventType)) { try { Clef newClef(**si); if (newSegment->getClefAtTime ((*si)->getAbsoluteTime() + 1) == newClef) { continue; } } catch (...) { } } if ((*si)->isa(Key::EventType)) { try { Key newKey(**si); if (newSegment->getKeyAtTime ((*si)->getAbsoluteTime() + 1) == newKey) { continue; } } catch (...) { } } newSegment->insert(new Event(**si)); } if (end > newSegment->getEndMarkerTime()) { newSegment->setEndMarkerTime(end); } } if (haveOverlap) { /// normalizeRests doesn't require Composition, but is less /// than ideal without it; newSegment->setComposition(composition); newSegment->normalizeRests(overlapStart, overlapEnd); newSegment->setComposition(0); } return newSegment; }