本文整理汇总了C++中XPCNativeInterface::GetMemberCount方法的典型用法代码示例。如果您正苦于以下问题:C++ XPCNativeInterface::GetMemberCount方法的具体用法?C++ XPCNativeInterface::GetMemberCount怎么用?C++ XPCNativeInterface::GetMemberCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XPCNativeInterface
的用法示例。
在下文中一共展示了XPCNativeInterface::GetMemberCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
// static
XPCNativeSet*
XPCNativeSet::NewInstance(XPCCallContext& ccx,
XPCNativeInterface** array,
PRUint16 count)
{
XPCNativeSet* obj = nsnull;
if(!array || !count)
return nsnull;
// We impose the invariant:
// "All sets have exactly one nsISupports interface and it comes first."
// This is the place where we impose that rule - even if given inputs
// that don't exactly follow the rule.
XPCNativeInterface* isup = XPCNativeInterface::GetISupports(ccx);
PRUint16 slots = count+1;
PRUint16 i;
XPCNativeInterface** pcur;
for(i = 0, pcur = array; i < count; i++, pcur++)
{
if(*pcur == isup)
slots--;
}
// Use placement new to create an object with the right amount of space
// to hold the members array
int size = sizeof(XPCNativeSet);
if(slots > 1)
size += (slots - 1) * sizeof(XPCNativeInterface*);
void* place = new char[size];
if(place)
obj = new(place) XPCNativeSet();
if(obj)
{
// Stick the nsISupports in front and skip additional nsISupport(s)
XPCNativeInterface** inp = array;
XPCNativeInterface** outp = (XPCNativeInterface**) &obj->mInterfaces;
PRUint16 memberCount = 1; // for the one member in nsISupports
*(outp++) = isup;
for(i = 0; i < count; i++)
{
XPCNativeInterface* cur;
if(isup == (cur = *(inp++)))
continue;
*(outp++) = cur;
memberCount += cur->GetMemberCount();
}
obj->mMemberCount = memberCount;
obj->mInterfaceCount = slots;
}
return obj;
}
示例2: ccx
static bool
XPC_WN_Shared_Proto_Enumerate(JSContext* cx, HandleObject obj)
{
MOZ_ASSERT(js::GetObjectClass(obj) == &XPC_WN_ModsAllowed_Proto_JSClass ||
js::GetObjectClass(obj) == &XPC_WN_NoMods_Proto_JSClass,
"bad proto");
XPCWrappedNativeProto* self =
(XPCWrappedNativeProto*) xpc_GetJSPrivate(obj);
if (!self)
return false;
XPCNativeSet* set = self->GetSet();
if (!set)
return false;
XPCCallContext ccx(cx);
if (!ccx.IsValid())
return false;
uint16_t interface_count = set->GetInterfaceCount();
XPCNativeInterface** interfaceArray = set->GetInterfaceArray();
for (uint16_t i = 0; i < interface_count; i++) {
XPCNativeInterface* iface = interfaceArray[i];
uint16_t member_count = iface->GetMemberCount();
for (uint16_t k = 0; k < member_count; k++) {
if (!xpc_ForcePropertyResolve(cx, obj, iface->GetMemberAt(k)->GetName()))
return false;
}
}
return true;
}