本文整理汇总了C++中XPCJSRuntime::GetNativeSetMap方法的典型用法代码示例。如果您正苦于以下问题:C++ XPCJSRuntime::GetNativeSetMap方法的具体用法?C++ XPCJSRuntime::GetNativeSetMap怎么用?C++ XPCJSRuntime::GetNativeSetMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XPCJSRuntime
的用法示例。
在下文中一共展示了XPCJSRuntime::GetNativeSetMap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: XPCJSRuntime
// static
XPCJSRuntime*
XPCJSRuntime::newXPCJSRuntime(nsXPConnect* aXPConnect,
nsIJSRuntimeService* aJSRuntimeService)
{
NS_PRECONDITION(aXPConnect,"bad param");
NS_PRECONDITION(aJSRuntimeService,"bad param");
XPCJSRuntime* self;
self = new XPCJSRuntime(aXPConnect,
aJSRuntimeService);
if(self &&
self->GetJSRuntime() &&
self->GetContextMap() &&
self->GetWrappedJSMap() &&
self->GetWrappedJSClassMap() &&
self->GetIID2NativeInterfaceMap() &&
self->GetClassInfo2NativeSetMap() &&
self->GetNativeSetMap() &&
self->GetThisTranslatorMap() &&
self->GetNativeScriptableSharedMap() &&
self->GetDyingWrappedNativeProtoMap() &&
self->GetExplicitNativeWrapperMap() &&
self->GetMapLock())
{
return self;
}
delete self;
return nsnull;
}
示例2: set
// static
XPCNativeSet*
XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, const nsIID* iid)
{
AutoMarkingNativeSetPtr set(ccx);
AutoMarkingNativeInterfacePtr iface(ccx);
iface = XPCNativeInterface::GetNewOrUsed(ccx, iid);
if(!iface)
return nsnull;
XPCNativeSetKey key(nsnull, iface, 0);
XPCJSRuntime* rt = ccx.GetRuntime();
NativeSetMap* map = rt->GetNativeSetMap();
if(!map)
return nsnull;
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
set = map->Find(&key);
}
if(set)
return set;
// hacky way to get a XPCNativeInterface** using the AutoPtr
XPCNativeInterface* temp[] = {iface};
set = NewInstance(ccx, temp, 1);
if(!set)
return nsnull;
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
XPCNativeSet* set2 = map->Add(&key, set);
if(!set2)
{
NS_ERROR("failed to add our set!");
DestroyInstance(set);
set = nsnull;
}
else if(set2 != set)
{
DestroyInstance(set);
set = set2;
}
}
return set;
}
示例3: set
// static
XPCNativeSet*
XPCNativeSet::GetNewOrUsed(const nsIID* iid)
{
AutoJSContext cx;
AutoMarkingNativeSetPtr set(cx);
AutoMarkingNativeInterfacePtr iface(cx);
iface = XPCNativeInterface::GetNewOrUsed(iid);
if (!iface)
return nullptr;
XPCNativeSetKey key(nullptr, iface, 0);
XPCJSRuntime* rt = XPCJSRuntime::Get();
NativeSetMap* map = rt->GetNativeSetMap();
if (!map)
return nullptr;
set = map->Find(&key);
if (set)
return set;
// hacky way to get a XPCNativeInterface** using the AutoPtr
XPCNativeInterface* temp[] = {iface};
set = NewInstance(temp, 1);
if (!set)
return nullptr;
XPCNativeSet* set2 = map->Add(&key, set);
if (!set2) {
NS_ERROR("failed to add our set!");
DestroyInstance(set);
set = nullptr;
} else if (set2 != set) {
DestroyInstance(set);
set = set2;
}
return set;
}
示例4: set
// static
XPCNativeSet*
XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, nsIClassInfo* classInfo)
{
AutoMarkingNativeSetPtr set(ccx);
XPCJSRuntime* rt = ccx.GetRuntime();
ClassInfo2NativeSetMap* map = rt->GetClassInfo2NativeSetMap();
if (!map)
return nsnull;
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
set = map->Find(classInfo);
}
if (set)
return set;
nsIID** iidArray = nsnull;
AutoMarkingNativeInterfacePtrArrayPtr interfaceArray(ccx);
PRUint32 iidCount = 0;
if (NS_FAILED(classInfo->GetInterfaces(&iidCount, &iidArray))) {
// Note: I'm making it OK for this call to fail so that one can add
// nsIClassInfo to classes implemented in script without requiring this
// method to be implemented.
// Make sure these are set correctly...
iidArray = nsnull;
iidCount = 0;
}
NS_ASSERTION((iidCount && iidArray) || !(iidCount || iidArray), "GetInterfaces returned bad array");
// !!! from here on we only exit through the 'out' label !!!
if (iidCount) {
AutoMarkingNativeInterfacePtrArrayPtr
arr(ccx, new XPCNativeInterface*[iidCount], iidCount, true);
if (!arr)
goto out;
interfaceArray = arr;
XPCNativeInterface** currentInterface = interfaceArray;
nsIID** currentIID = iidArray;
PRUint16 interfaceCount = 0;
for (PRUint32 i = 0; i < iidCount; i++) {
nsIID* iid = *(currentIID++);
if (!iid) {
NS_ERROR("Null found in classinfo interface list");
continue;
}
XPCNativeInterface* iface =
XPCNativeInterface::GetNewOrUsed(ccx, iid);
if (!iface) {
// XXX warn here
continue;
}
*(currentInterface++) = iface;
interfaceCount++;
}
if (interfaceCount) {
set = NewInstance(ccx, interfaceArray, interfaceCount);
if (set) {
NativeSetMap* map2 = rt->GetNativeSetMap();
if (!map2)
goto out;
XPCNativeSetKey key(set, nsnull, 0);
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
XPCNativeSet* set2 = map2->Add(&key, set);
if (!set2) {
NS_ERROR("failed to add our set!");
DestroyInstance(set);
set = nsnull;
goto out;
}
if (set2 != set) {
DestroyInstance(set);
set = set2;
}
}
}
} else
set = GetNewOrUsed(ccx, &NS_GET_IID(nsISupports));
} else
set = GetNewOrUsed(ccx, &NS_GET_IID(nsISupports));
if (set)
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
//.........这里部分代码省略.........