Bug 1096328 - Remove nativeOwnership from Bindings.conf, autodetect the right smart pointer for owned and refcounted objects. r=bz.

--HG--
extra : rebase_source : 605390cd0b599e4922f8c13d70dd727976c48152
This commit is contained in:
Peter Van der Beken 2014-11-01 15:08:00 +01:00
Родитель ac844526e8
Коммит 7a111997bf
2 изменённых файлов: 15 добавлений и 10 удалений

Просмотреть файл

@ -3214,17 +3214,26 @@ StrongOrRawPtr(already_AddRefed<S>&& aPtr)
return aPtr.template downcast<T>();
}
template<class T>
inline T*
template<class T,
class ReturnType=typename Conditional<IsRefcounted<T>::value, T*,
nsAutoPtr<T>>::Type>
inline ReturnType
StrongOrRawPtr(T* aPtr)
{
return aPtr;
return ReturnType(aPtr);
}
template<class T, template<typename> class SmartPtr, class S>
inline void
StrongOrRawPtr(SmartPtr<S>&& aPtr) = delete;
template<class T>
struct StrongPtrForMember
{
typedef typename Conditional<IsRefcounted<T>::value,
nsRefPtr<T>, nsAutoPtr<T>>::Type Type;
};
inline
JSObject*
GetErrorPrototype(JSContext* aCx, JS::Handle<JSObject*> aForObj)

Просмотреть файл

@ -6071,11 +6071,8 @@ def getRetvalDeclarationForType(returnType, descriptorProvider,
result = CGGeneric(descriptorProvider.getDescriptor(
returnType.unroll().inner.identifier.name).nativeType)
conversion = None
if descriptorProvider.getDescriptor(
returnType.unroll().inner.identifier.name).nativeOwnership == 'owned':
result = CGTemplatedType("nsAutoPtr", result)
elif isMember:
result = CGTemplatedType("nsRefPtr", result)
if isMember:
result = CGGeneric("StrongPtrForMember<%s>::Type" % result.define())
else:
conversion = CGGeneric("StrongOrRawPtr<%s>" % result.define())
result = CGGeneric("auto")
@ -6666,8 +6663,7 @@ class CGPerSignatureCall(CGThing):
returnsNewObject = memberReturnsNewObject(self.idlNode)
if (returnsNewObject and
self.returnType.isGeckoInterface() and
not self.descriptor.getDescriptor(self.returnType.unroll().inner.identifier.name).nativeOwnership == 'owned'):
self.returnType.isGeckoInterface()):
wrapCode += dedent(
"""
static_assert(!IsPointer<decltype(result)>::value,