Exemplo n.º 1
0
TLSBlock&
DynamicThreadVector::operator[](unsigned dso)
{
	unsigned generation = TLSBlockTemplates::Get().GetGeneration(-1);
	if (_Generation() < generation) {
		for (unsigned i = 0; i < _Size(); i++) {
			TLSBlock& block = (*fVector)[i + 1];
			unsigned dsoGeneration
				= TLSBlockTemplates::Get().GetGeneration(dso);
			if (_Generation() < dsoGeneration && dsoGeneration <= generation)
				block.Destroy();
		}

		fGeneration->SetCounter(generation);
	}

	if (_Size() <= dso) {
		status_t result = _ResizeVector(dso + 1);
		if (result != B_OK)
			return fNullBlock;
	}

	TLSBlock& block = (*fVector)[dso + 1];
	if (block.IsInvalid()) {
		status_t result = block.Initialize(dso);
		if (result != B_OK)
			return fNullBlock;
	};

	return block;
}
Exemplo n.º 2
0
	size_t _Size(Node<T> *pRoot)
	{
		if (NULL != pRoot)
		{
			return 1 + _Size(pRoot->pLeft) + _Size(pRoot->pRight);	
		}

		return 0;
	}
Exemplo n.º 3
0
status_t
DynamicThreadVector::_ResizeVector(unsigned minimumSize)
{
	static const unsigned kInitialSize = 4;
	unsigned size = std::max(minimumSize, kInitialSize);
	unsigned oldSize = _Size();
	if (size <= oldSize)
		return B_OK;

	void* newVector = realloc(*fVector, (size + 1) * sizeof(TLSBlock));
	if (newVector == NULL)
		return B_NO_MEMORY;

	*fVector = (TLSBlock*)newVector;
	memset(*fVector + oldSize + 1, 0, (size - oldSize) * sizeof(TLSBlock));
	if (fGeneration == NULL) {
		fGeneration = new Generation;
		if (fGeneration == NULL)
			return B_NO_MEMORY;
	}

	*(Generation**)*fVector = fGeneration;
	fGeneration->SetSize(size);

	return B_OK;
}
Exemplo n.º 4
0
// ----------------------------------------------------
//	Keys::Compare
// ----------------------------------------------------
bool			Keys::Compare(const Keys &KeyList) const
{
	// もしサイズが違うなら
	if(_Size() != KeyList._Size()){
		// false
		return false;
	}
	// ループを回す
	for(int i = 0; i < _Size(); i++){
		// もし一致しない要素が存在するなら
		if(KeyList && _Get(i) == false){
			// false
			return false;
		}
	}
	return true;
}
Exemplo n.º 5
0
CRgn*
ESChildSeatStatus::GetControlRgn(_Size& szRgnBound, bool& bCentered){
	if( IsDesignerMode() )
		return NULL;
	CRgn*	pRgn		=  ESChildControlTable::GetSeatStatusImageRgn();
	szRgnBound			= m_pBgImage ? _Size(m_pBgImage->GetWidth(), m_pBgImage->GetHeight()) : _Size(0, 0);
	bCentered			= true;
	return pRgn;
	};
Exemplo n.º 6
0
void
SplitView::SetSplitterProportion(float proportion)
{
	// make sure 'proportion' is within valid bounds
	float min = fMin;
	float max = fMax;
	if (!ProportionalMode()) {
		min /= _Size();
		max /= _Size();
	}
	if (proportion < min)
		proportion = min;
	else if (proportion > max)
		proportion = max;

	fProportion = proportion;
	fPosition = -1;
	Relayout();
}
Exemplo n.º 7
0
void
SplitView::FrameResized(float width, float height)
{
	if (fProportional && fPosition != -1) {
		fProportion = fPosition / fPreviousSize;
		fPosition = -1;
	}
	fPreviousSize = _Size();

	Relayout();
}
Exemplo n.º 8
0
void
DynamicThreadVector::DestroyAll()
{
	for (unsigned i = 0; i < _Size(); i++) {
		TLSBlock& block = (*fVector)[i + 1];
		if (!block.IsInvalid())
			block.Destroy();
	}

	free(*fVector);
	*fVector = NULL;

	delete fGeneration;
}
Exemplo n.º 9
0
void
SplitView::Relayout()
{
	if (fSplitter)
		fSplitter->SetOrientation(Orientation());

	float max = _Size();

	if (fPosition == -1) {
		// set initial default position in the middle
		fPosition = max * fProportion;
	}
	if (fPosition > max)
		fPosition = max;

	int32 count = CountChildren();
	float last = 0;

	for (int32 index = 0; index < count; index++) {
		BView* child = ChildAt(index);
		float size;
		if (index == 0)
			size = fPosition;
		else if (Orientation() == B_VERTICAL)
			size = (Bounds().right + 1 - last) / (count - index);
		else
			size = (Bounds().bottom + 1 - last) / (count - index);

		if (index == 1 && fSplitter == NULL) {
			// we need to add a splitter
			AddChild(fSplitter = NewSplitter(), child);
			child = fSplitter;
			count++;
		}

		if (child == fSplitter)
			size = SPLITTER_WIDTH;// + (Orientation() == B_VERTICAL ? 0 : 1);

		if (Orientation() == B_VERTICAL) {
			child->MoveTo(last, 0);
			child->ResizeTo(size, Bounds().Height());
		} else {
			child->MoveTo(0, last);
			child->ResizeTo(Bounds().Width(), size);
		}

		last += size + 1;
	}
}
Exemplo n.º 10
0
void
SplitView::SetSplitterPosition(float position)
{
	// make sure 'position' is within valid bounds
	if (fProportional) {
		float size = _Size();
		if (position < size * fMin)
			position = size * fMin;
		else if (position > size * fMax)
			position = size * fMax;
	} else {
		if (position < fMin)
			position = fMin;
		else if (position > fMax)
			position = fMax;
	}

	if (position == fPosition)
		return;

	fPosition = position;
	fProportion = fPosition / _Size();
	Relayout();
}
Exemplo n.º 11
0
	size_t _Size(GeneralListNode* head)
	{
		GeneralListNode* cur = head;
		size_t size = 0;
		while (cur)
		{
			if (cur->_type == VALUE)
			{
				size++;
			}
			else if (cur->_type == SUB)
			{
				size += _Size(cur->_subLink);
			}
			cur = cur->_next;
		}
		return size;
	}
Exemplo n.º 12
0
	int _Size(GeneralListNode* head)
	{
		int size = 0;
		GeneralListNode* begin = head;
		while (begin)
		{
			if(begin->_type == SUB_TYPE)
			{	
				size += _Size(begin->_subLink);
			}
			else if(begin->_type == VALUE_TYPE)
			{
				++size;
			}

			begin = begin->_next;
		}

		return size;
	}
Exemplo n.º 13
0
bool
NumberEditor::TypeMatches()
{
	return fEditor.FileSize() >= (off_t)_Size();
		// we only look at as many bytes we need to
}
Exemplo n.º 14
0
void
ESChildComboBox::CalcButtonRect(){
	MercuryGUI* pGUI		= MercuryGUI::GetInstance();
	int			nCX			= pGUI->comboBox.m_imgComboButton.GetWidth();
	int			nCY			= pGUI->comboBox.m_imgComboButton.GetHeight();
    m_rcBoxButton.SetRect(m_rRect.right - nCX - 2, m_rRect.top + (m_rRect.Height() - nCY)/2, _Size(nCX, nCY));
	}
Exemplo n.º 15
0
void
SplitView::AllAttached()
{
	fPreviousSize = _Size();
	Relayout();
}
Exemplo n.º 16
0
	int Size()
	{
		return _Size(_head);
	}
Exemplo n.º 17
0
	size_t Size()
	{
		return _Size(_head);
	}
Exemplo n.º 18
0
void
NumberEditor::_UpdateText()
{
	if (fEditor.Lock()) {
		const char* number;
		if (fEditor.GetViewBuffer((const uint8**)&number) == B_OK) {
			char buffer[64];
			char format[16];
			switch (fEditor.Type()) {
				case B_FLOAT_TYPE:
				{
					float value = *(float*)number;
					snprintf(buffer, sizeof(buffer), "%g", value);
					break;
				}
				case B_DOUBLE_TYPE:
				{
					double value = *(double *)number;
					snprintf(buffer, sizeof(buffer), "%g", value);
					break;
				}
				case B_SSIZE_T_TYPE:
				case B_INT8_TYPE:
				case B_INT16_TYPE:
				case B_INT32_TYPE:
				case B_INT64_TYPE:
				case B_OFF_T_TYPE:
				{
					_Format(format);
					switch (_Size()) {
						case 1:
						{
							int8 value = *(int8 *)number;
							snprintf(buffer, sizeof(buffer), format, value);
							break;
						}
						case 2:
						{
							int16 value = *(int16 *)number;
							snprintf(buffer, sizeof(buffer), format, value);
							break;
						}
						case 4:
						{
							int32 value = *(int32 *)number;
							snprintf(buffer, sizeof(buffer), format, value);
							break;
						}
						case 8:
						{
							int64 value = *(int64 *)number;
							snprintf(buffer, sizeof(buffer), format, value);
							break;
						}
					}
					break;
				}

				default:
				{
					_Format(format);
					switch (_Size()) {
						case 1:
						{
							uint8 value = *(uint8 *)number;
							snprintf(buffer, sizeof(buffer), format, value);
							break;
						}
						case 2:
						{
							uint16 value = *(uint16 *)number;
							snprintf(buffer, sizeof(buffer), format, value);
							break;
						}
						case 4:
						{
							uint32 value = *(uint32 *)number;
							snprintf(buffer, sizeof(buffer), format, value);
							break;
						}
						case 8:
						{
							uint64 value = *(uint64 *)number;
							snprintf(buffer, sizeof(buffer), format, value);
							break;
						}
					}
					break;
				}
			}
			fTextControl->SetText(buffer);
			fPreviousText.SetTo(buffer);
		}

		fEditor.Unlock();
	}
}
Exemplo n.º 19
0
void
NumberEditor::CommitChanges()
{
	if (fPreviousText == fTextControl->Text())
		return;

	const char *number = fTextControl->Text();
	uint8 buffer[8];

	switch (fEditor.Type()) {
		case B_FLOAT_TYPE:
		{
			float value = strtod(number, NULL);
			*(float *)buffer = value;
			break;
		}
		case B_DOUBLE_TYPE:
		{
			double value = strtod(number, NULL);
			*(double *)buffer = value;
			break;
		}
		case B_INT8_TYPE:
		{
			int64 value = strtoll(number, NULL, 0);
			if (value > CHAR_MAX)
				value = CHAR_MAX;
			else if (value < CHAR_MIN)
				value = CHAR_MIN;
			*(int8 *)buffer = (int8)value;
			break;
		}
		case B_UINT8_TYPE:
		{
			int64 value = strtoull(number, NULL, 0);
			if (value > UCHAR_MAX)
				value = UCHAR_MAX;
			*(uint8 *)buffer = (uint8)value;
			break;
		}
		case B_INT16_TYPE:
		{
			int64 value = strtoll(number, NULL, 0);
			if (value > SHRT_MAX)
				value = SHRT_MAX;
			else if (value < SHRT_MIN)
				value = SHRT_MIN;
			*(int16 *)buffer = (int16)value;
			break;
		}
		case B_UINT16_TYPE:
		{
			int64 value = strtoull(number, NULL, 0);
			if (value > USHRT_MAX)
				value = USHRT_MAX;
			*(uint16 *)buffer = (uint16)value;
			break;
		}
		case B_INT32_TYPE:
		case B_SSIZE_T_TYPE:
		{
			int64 value = strtoll(number, NULL, 0);
			if (value > LONG_MAX)
				value = LONG_MAX;
			else if (value < LONG_MIN)
				value = LONG_MIN;
			*(int32 *)buffer = (int32)value;
			break;
		}
		case B_UINT32_TYPE:
		case B_SIZE_T_TYPE:
		case B_POINTER_TYPE:
		{
			uint64 value = strtoull(number, NULL, 0);
			if (value > ULONG_MAX)
				value = ULONG_MAX;
			*(uint32 *)buffer = (uint32)value;
			break;
		}
		case B_INT64_TYPE:
		case B_OFF_T_TYPE:
		{
			int64 value = strtoll(number, NULL, 0);
			*(int64 *)buffer = value;
			break;
		}
		case B_UINT64_TYPE:
		{
			uint64 value = strtoull(number, NULL, 0);
			*(uint64 *)buffer = value;
			break;
		}
		default:
			return;
	}

	fEditor.Replace(0, buffer, _Size());
	fPreviousText.SetTo((char *)buffer);
}
Exemplo n.º 20
0
	size_t Size()
	{
		return _Size(pRoot);
	}