void CContainerTypeInfo::Assign(TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode how) const { if (how == eShallowChildless) { SetDefault(dst); // clear destination container return; } CIterator idst; CConstIterator isrc; bool old_element = InitIterator(idst,dst); if ( InitIterator(isrc, src) ) { TTypeInfo elementType = GetElementType(); do { TConstObjectPtr elementPtr = GetElementPtr(isrc); if (old_element) { elementType->Assign(GetElementPtr(idst), elementPtr, how); old_element = NextElement(idst); } else { AddElement(dst, elementPtr, how); } } while ( NextElement(isrc) ); } if (old_element) { EraseAllElements(idst); } }
bool CContainerTypeInfo::Equals(TConstObjectPtr object1, TConstObjectPtr object2, ESerialRecursionMode how) const { if (how == eShallowChildless) { return true; } TTypeInfo elementType = GetElementType(); CConstIterator i1, i2; if ( InitIterator(i1, object1) ) { if ( !InitIterator(i2, object2) ) return false; if ( !elementType->Equals(GetElementPtr(i1), GetElementPtr(i2), how) ) return false; while ( NextElement(i1) ) { if ( !NextElement(i2) ) return false; if ( !elementType->Equals(GetElementPtr(i1), GetElementPtr(i2), how) ) return false; } return !NextElement(i2); } else { return !InitIterator(i2, object2); } }
// Get the value of the OMObjectVector at position index. AAFRESULT STDMETHODCALLTYPE ImplAAFRefArrayValue::GetElementAt( aafUInt32 index, ImplAAFPropertyValue** ppPropertyValue) const { AAFRESULT result = AAFRESULT_SUCCESS; if (NULL == ppPropertyValue) return AAFRESULT_NULL_PARAM; *ppPropertyValue = NULL; ImplAAFStorableSP pObject; result = GetObjectAt(index, &pObject); if (AAFRESULT_FAILED(result)) return result; ImplAAFTypeDefObjectRef *pElementType = GetElementType(); ASSERTU(NULL != pElementType); if (NULL == pElementType) return AAFRESULT_INVALID_OBJ; result = pElementType->CreateValue((ImplAAFStorable *)pObject, ppPropertyValue); if (AAFRESULT_FAILED(result)) return result; return result; }
LRESULT CHTMLayoutCtrl::OnCreateControl(LPNMHL_CREATE_CONTROL pnmcc) { TRACE(_T("CHTMLayoutCtrl::OnCreateControl: type='%s' \n"), GetElementType(pnmcc->helement) ); // Try to create control and if failed, proceed with default processing. // Note that this code assumes that the host and control windows are the same. If // you are handling HTMLayout control notification in another window, you'll have // to override this method and provide proper hWnd. ASSERT(::IsWindow(m_hWnd)); //return CreateControl(pT->m_hWnd, pnmcc); return 0; }
bool CSettingList::SetValue(const SettingPtrList &values) { CExclusiveLock lock(m_critical); if ((int)values.size() < m_minimumItems || (m_maximumItems > 0 && (int)values.size() > m_maximumItems)) return false; bool equal = values.size() == m_values.size(); for (size_t index = 0; index < values.size(); index++) { if (values[index]->GetType() != GetElementType()) return false; if (equal && !values[index]->Equals(m_values[index]->ToString())) equal = false; } if (equal) return true; SettingPtrList oldValues = m_values; m_values.clear(); m_values.insert(m_values.begin(), values.begin(), values.end()); if (!OnSettingChanging(this)) { m_values = oldValues; // the setting couldn't be changed because one of the // callback handlers failed the OnSettingChanging() // callback so we need to let all the callback handlers // know that the setting hasn't changed OnSettingChanging(this); return false; } m_changed = (toString(m_values) != toString(m_defaults)); OnSettingChanged(this); return true; }
CTypeInfo::EMayContainType CContainerTypeInfo::GetMayContainType(TTypeInfo type) const { return GetElementType()->IsOrMayContainType(type); }
Type* ArrayToPtr (Type* T) /* Convert an array to a pointer to it's first element */ { /* Return pointer to first element */ return PointerTo (GetElementType (T)); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Operand* ConstantFolder::LoadFromAddress(Operand* op, const Type* loadType, __int64 offset) { // If the operand has a defining instruction then we try to compute // the offset from which we should load. If it's a variable reference // we try to load from the offset that was already computed. if(op->HasDefiningInstruction() == false) { return LoadFromGlobal(op, loadType, offset); } auto instr = op->DefiningInstruction(); switch(instr->GetOpcode()) { case Instr_Index: { // If the index operand is not a constant give up. auto indexInstr = instr->As<IndexInstr>(); auto indexConst = indexInstr->IndexOp()->As<IntConstant>(); if(indexConst == nullptr) { return nullptr; } // The type of the base is 'pointer-to-array', so we need to strip the pointer. auto elementType = indexInstr->GetElementType(); __int64 index = indexConst->Value(); __int64 elemSize = TypeInfo::GetSize(elementType, target_); // The offset is incremented by the index multiplied with the element size. __int64 newOffset = offset + (index * elemSize); return LoadFromAddress(indexInstr->BaseOp(), loadType, newOffset); } case Instr_Element: { auto elemInstr = instr->As<ElementInstr>(); __int64 index = elemInstr->GetFieldIndex(); // The type of the base is 'pointer-to-record', // so we need to strip the pointer. auto recordType = elemInstr->GetRecordType(); // Obtain the offset of the selected field. // The new offset is the old one added with the field offset. __int64 fieldOffset = recordType->Fields()[index].FieldOffset; __int64 newOffset = offset + fieldOffset; return LoadFromAddress(elemInstr->BaseOp(), loadType, newOffset); } case Instr_Address: { // If the index operand is not a constant give up. auto addrInstr = instr->As<AddressInstr>(); auto indexConst = addrInstr->IndexOp()->As<IntConstant>(); if(indexConst == nullptr) { return nullptr; } // The type of the base is 'pointer-to-object', // so we need to strip the pointer. auto objectType = addrInstr->GetPointeeType(); __int64 index = indexConst->Value(); __int64 elemSize = TypeInfo::GetSize(objectType, target_); // The offset is incremented by the index multiplied with the object size. __int64 newOffset = offset + (index * elemSize); return LoadFromAddress(addrInstr->BaseOp(), loadType, newOffset); } case Instr_Ptop: { // This instruction is ignored (the previous recursion step // has already taken care about its effects). auto ptopInstr = instr->As<PtopInstr>(); auto targetInstr = ptopInstr->TargetOp()->DefiningInstruction(); return LoadFromAddress(ptopInstr->TargetOp(), loadType, offset); } case Instr_Load: { // This happens when the variable is a pointer. auto loadInstr = instr->As<LoadInstr>(); return LoadFromAddress(loadInstr->SourceOp(), loadType, offset); } default: { // All other cases don't lead to a constant operand. return nullptr; } } }
LRESULT CHTMLayoutCtrl::OnControlCreated(LPNMHL_CREATE_CONTROL pnmcc) { TRACE(_T("CHTMLayoutHost::OnControlCreated: type='%s' \n"), GetElementType(pnmcc->helement) ); return 0; }