当前位置: 首页>>代码示例>>C++>>正文


C++ XPCNativeSet::HasInterface方法代码示例

本文整理汇总了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;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:47,代码来源:XPCWrappedNativeInfo.cpp


注:本文中的XPCNativeSet::HasInterface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。