コード例 #1
0
ファイル: qwt_arrow_button.cpp プロジェクト: chongle/prorata
/*!
   Calculate the size for a arrow that fits into a rect of a given size

   \param arrowType Arrow type
   \param boundingSize Bounding size
   \return Size of the arrow
*/
QSize QwtArrowButton::arrowSize(Qt::ArrowType arrowType,
    const QSize &boundingSize) const
{
    QSize bs = boundingSize;
    if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow )
        bs.transpose();
        
    const int MinLen = 2;
    const QSize sz = bs.expandedTo(
        QSize(MinLen, 2 * MinLen - 1)); // minimum

    int w = sz.width();
    int h = 2 * w - 1;

    if ( h > sz.height() )
    {
        h = sz.height();
        w = (h + 1) / 2;
    }

    QSize arrSize(w, h);
    if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow )
        arrSize.transpose();

    return arrSize;
}
コード例 #2
0
ファイル: Value.cpp プロジェクト: gbitzes/root
 size_t Value::GetNumberOfElements() const {
   if (const clang::ConstantArrayType* ArrTy
       = llvm::dyn_cast<clang::ConstantArrayType>(getType())) {
     llvm::APInt arrSize(sizeof(size_t)*8, 1);
     do {
       arrSize *= ArrTy->getSize();
       ArrTy = llvm::dyn_cast<clang::ConstantArrayType>(ArrTy->getElementType()
                                                        .getTypePtr());
     } while (ArrTy);
     return static_cast<size_t>(arrSize.getZExtValue());
   }
   return 1;
 }
コード例 #3
0
ファイル: shared-variant.cpp プロジェクト: aakrit/hiphop-php
int SharedVariant::countReachable() const {
  int count = 1;
  if (getType() == KindOfArray) {
    int size = arrSize();
    if (!isPacked()) {
      count += size; // for keys
    }
    for (int i = 0; i < size; i++) {
      SharedVariant* p = getValue(i);
      count += p->countReachable(); // for values
    }
  }
  return count;
}
コード例 #4
0
void SharedVariant::loadElems(ArrayData *&elems,
                                    const SharedMap &sharedMap,
                                    bool keepRef /* = false */) {
  ASSERT(is(KindOfArray));
  uint count = arrSize();
  ArrayInit ai(count, getIsVector(), keepRef);
  for (uint i = 0; i < count; i++) {
    if (getIsVector()) {
      ai.add((int64)i, sharedMap.getValueRef(i), true);
    } else {
      ai.add(m_data.map->getKeyIndex(i)->toLocal(), sharedMap.getValueRef(i),
             true);
    }
  }
  elems = ai.create();
  if (elems->isStatic()) elems = elems->copy();
}
コード例 #5
0
ファイル: shared-variant.cpp プロジェクト: aakrit/hiphop-php
ArrayData* SharedVariant::loadElems(const SharedArray &array) {
  assert(is(KindOfArray));
  auto count = arrSize();
  ArrayData* elems;
  if (isPacked()) {
    PackedArrayInit ai(count);
    for (uint i = 0; i < count; i++) {
      ai.append(array.getValueRef(i));
    }
    elems = ai.create();
  } else {
    ArrayInit ai(count);
    for (uint i = 0; i < count; i++) {
      ai.add(m_data.array->getKeyIndex(i)->toLocal(), array.getValueRef(i),
             true);
    }
    elems = ai.create();
  }
  if (elems->isStatic()) elems = elems->copy();
  return elems;
}
コード例 #6
0
ArrayData* SharedVariant::loadElems(const SharedMap &sharedMap) {
  assert(is(KindOfArray));
  auto count = arrSize();
  ArrayData* elems;
  if (getIsVector()) {
    VectorInit ai(count);
    for (uint i = 0; i < count; i++) {
      ai.add(sharedMap.getValueRef(i));
    }
    elems = ai.create();
  } else {
    ArrayInit ai(count);
    for (uint i = 0; i < count; i++) {
      ai.add(m_data.map->getKeyIndex(i)->toLocal(), sharedMap.getValueRef(i),
             true);
    }
    elems = ai.create();
  }
  if (elems->isStatic()) elems = elems->copy();
  return elems;
}
コード例 #7
0
ArrayData* SharedVariant::loadElems(const SharedMap &sharedMap,
                                    bool mapInit /* = false */) {
  assert(is(KindOfArray));
  uint count = arrSize();
  bool isVector = getIsVector();
  ArrayInit ai = mapInit ? ArrayInit(count, ArrayInit::mapInit) :
                 isVector ? ArrayInit(count, ArrayInit::vectorInit) :
                 ArrayInit(count);
  if (isVector) {
    for (uint i = 0; i < count; i++) {
      ai.set(sharedMap.getValueRef(i));
    }
  } else {
    for (uint i = 0; i < count; i++) {
      ai.add(m_data.map->getKeyIndex(i)->toLocal(), sharedMap.getValueRef(i),
             true);
    }
  }
  ArrayData* elems = ai.create();
  if (elems->isStatic()) elems = elems->copy();
  return elems;
}