本文整理汇总了C++中PropertyList::mDtorFunc方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyList::mDtorFunc方法的具体用法?C++ PropertyList::mDtorFunc怎么用?C++ PropertyList::mDtorFunc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyList
的用法示例。
在下文中一共展示了PropertyList::mDtorFunc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
nsresult
nsPropertyTable::SetPropertyInternal(nsPropertyOwner aObject,
nsIAtom *aPropertyName,
void *aPropertyValue,
NSPropertyDtorFunc aPropDtorFunc,
void *aPropDtorData,
bool aTransfer,
void **aOldValue)
{
NS_PRECONDITION(aPropertyName && aObject, "unexpected null param");
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
if (propertyList) {
// Make sure the dtor function and data and the transfer flag match
if (aPropDtorFunc != propertyList->mDtorFunc ||
aPropDtorData != propertyList->mDtorData ||
aTransfer != propertyList->mTransfer) {
NS_WARNING("Destructor/data mismatch while setting property");
return NS_ERROR_INVALID_ARG;
}
} else {
propertyList = new PropertyList(aPropertyName, aPropDtorFunc,
aPropDtorData, aTransfer);
if (!propertyList || !propertyList->mObjectValueMap.ops) {
delete propertyList;
return NS_ERROR_OUT_OF_MEMORY;
}
propertyList->mNext = mPropertyList;
mPropertyList = propertyList;
}
// The current property value (if there is one) is replaced and the current
// value is destroyed
nsresult result = NS_OK;
PropertyListMapEntry *entry = static_cast<PropertyListMapEntry*>
(PL_DHashTableOperate(&propertyList->mObjectValueMap, aObject, PL_DHASH_ADD));
if (!entry)
return NS_ERROR_OUT_OF_MEMORY;
// A nullptr entry->key is the sign that the entry has just been allocated
// for us. If it's non-nullptr then we have an existing entry.
if (entry->key) {
if (aOldValue)
*aOldValue = entry->value;
else if (propertyList->mDtorFunc)
propertyList->mDtorFunc(const_cast<void*>(entry->key), aPropertyName,
entry->value, propertyList->mDtorData);
result = NS_PROPTABLE_PROP_OVERWRITTEN;
}
else if (aOldValue) {
*aOldValue = nullptr;
}
entry->key = aObject;
entry->value = aPropertyValue;
return result;
}