本文整理汇总了C++中XPCNativeSet::HasInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ XPCNativeSet::HasInterface方法的具体用法?C++ XPCNativeSet::HasInterface怎么用?C++ XPCNativeSet::HasInterface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XPCNativeSet
的用法示例。
在下文中一共展示了XPCNativeSet::HasInterface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// static
XPCNativeSet*
XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx,
XPCNativeSet* firstSet,
XPCNativeSet* secondSet,
bool preserveFirstSetOrder)
{
// Figure out how many interfaces we'll need in the new set.
PRUint32 uniqueCount = firstSet->mInterfaceCount;
for (PRUint32 i = 0; i < secondSet->mInterfaceCount; ++i) {
if (!firstSet->HasInterface(secondSet->mInterfaces[i]))
uniqueCount++;
}
// If everything in secondSet was a duplicate, we can just use the first
// set.
if (uniqueCount == firstSet->mInterfaceCount)
return firstSet;
// If the secondSet is just a superset of the first, we can use it provided
// that the caller doesn't care about ordering.
if (!preserveFirstSetOrder && uniqueCount == secondSet->mInterfaceCount)
return secondSet;
// Ok, darn. Now we have to make a new set.
//
// It would be faster to just create the new set all at once, but that
// would involve wrangling with some pretty hairy code - especially since
// a lot of stuff assumes that sets are created by adding one interface to an
// existing set. So let's just do the slow and easy thing and hope that the
// above optimizations handle the common cases.
XPCNativeSet* currentSet = firstSet;
for (PRUint32 i = 0; i < secondSet->mInterfaceCount; ++i) {
XPCNativeInterface* iface = secondSet->mInterfaces[i];
if (!currentSet->HasInterface(iface)) {
// Create a new augmented set, inserting this interface at the end.
PRUint32 pos = currentSet->mInterfaceCount;
currentSet = XPCNativeSet::GetNewOrUsed(ccx, currentSet, iface, pos);
if (!currentSet)
return nsnull;
}
}
// We've got the union set. Hand it back to the caller.
MOZ_ASSERT(currentSet->mInterfaceCount == uniqueCount);
return currentSet;
}