コード例 #1
0
ファイル: IOInstance.cpp プロジェクト: japgo/mygithub
BOOL CIOInstance::IsOn(UINT io_no, PWORD pCh)
{
	UINT nChNo	 = GetChNo(io_no);
	UINT nChData = pCh[nChNo];
	UINT nBitPos = GetBitPos(io_no);
	UINT nOn	 = (nChData & GetBitMask(nBitPos));

	return (!!nOn);
}//--------------------------------------------------------------
コード例 #2
0
ファイル: IOInstance.cpp プロジェクト: japgo/mygithub
void CIOInstance::SetIO(UINT io_no, BOOL out_on, PWORD pCh)
{
	UINT nChNo	 = GetChNo(io_no);
	UINT nBitPos = GetBitPos(io_no);

	if(out_on)
		pCh[nChNo] |= GetBitMask(nBitPos);
	else
		pCh[nChNo] &= ~GetBitMask(nBitPos);
}//--------------------------------------------------------------
コード例 #3
0
//---------------------------------------------------------------------------
std::array<int, 2> UEBoolProperty::GetMissingBitsCount(const UEBoolProperty& other) const
{
	// If there is no previous bitfield member, just calculate the missing bits.
	if (!other.IsValid())
	{
		return { GetBitPosition(GetBitMask()), -1 };
	}

	// If both bitfield member belong to the same int, calculate the bit position difference.
	if (GetOffset() == other.GetOffset())
	{
		return { GetBitPosition(GetBitMask()) - GetBitPosition(other.GetBitMask()) - 1, -1 };
	}

	// If they have different offsets, we need two distances
	// |0000...1000|0010...0000|
	// 1.      ^---^
	// 2.          ^--^

	return { std::numeric_limits<uint32_t>::digits - GetBitPosition(other.GetBitMask()) - 1, GetBitPosition(GetBitMask()) };
}