New upstream version 24.0.1+dfsg1

This commit is contained in:
Sebastian Ramacher 2019-09-22 23:19:10 +02:00
parent b14f9eae6d
commit 5a730d6ec3
842 changed files with 42245 additions and 33385 deletions

View file

@ -33,18 +33,28 @@ protected:
inline void Replace(T *p)
{
if (ptr != p) {
if (p) p->AddRef();
if (ptr) ptr->Release();
if (p)
p->AddRef();
if (ptr)
ptr->Release();
ptr = p;
}
}
public:
inline ComPtr() : ptr(nullptr) {}
inline ComPtr(T *p) : ptr(p) {if (ptr) ptr->AddRef();}
inline ComPtr(const ComPtr<T> &c) : ptr(c.ptr) {if (ptr) ptr->AddRef();}
inline ComPtr(ComPtr<T> &&c) : ptr(c.ptr) {c.ptr = nullptr;}
inline ~ComPtr() {Kill();}
inline ComPtr() : ptr(nullptr) {}
inline ComPtr(T *p) : ptr(p)
{
if (ptr)
ptr->AddRef();
}
inline ComPtr(const ComPtr<T> &c) : ptr(c.ptr)
{
if (ptr)
ptr->AddRef();
}
inline ComPtr(ComPtr<T> &&c) : ptr(c.ptr) { c.ptr = nullptr; }
inline ~ComPtr() { Kill(); }
inline void Clear()
{
@ -87,7 +97,8 @@ public:
inline void CopyTo(T **out)
{
if (out) {
if (ptr) ptr->AddRef();
if (ptr)
ptr->AddRef();
*out = ptr;
}
}
@ -96,26 +107,35 @@ public:
{
ULONG ref;
if (!ptr) return 0;
if (!ptr)
return 0;
ref = ptr->Release();
ptr = nullptr;
return ref;
}
inline T **Assign() {Clear(); return &ptr;}
inline void Set(T *p) {Kill(); ptr = p;}
inline T **Assign()
{
Clear();
return &ptr;
}
inline void Set(T *p)
{
Kill();
ptr = p;
}
inline T *Get() const {return ptr;}
inline T *Get() const { return ptr; }
inline T **operator&() {return Assign();}
inline T **operator&() { return Assign(); }
inline operator T*() const {return ptr;}
inline T *operator->() const {return ptr;}
inline operator T *() const { return ptr; }
inline T *operator->() const { return ptr; }
inline bool operator==(T *p) const {return ptr == p;}
inline bool operator!=(T *p) const {return ptr != p;}
inline bool operator==(T *p) const { return ptr == p; }
inline bool operator!=(T *p) const { return ptr != p; }
inline bool operator!() const {return !ptr;}
inline bool operator!() const { return !ptr; }
};
#ifdef _WIN32
@ -126,13 +146,13 @@ public:
inline ComQIPtr(IUnknown *unk)
{
this->ptr = nullptr;
unk->QueryInterface(__uuidof(T), (void**)&this->ptr);
unk->QueryInterface(__uuidof(T), (void **)&this->ptr);
}
inline ComPtr<T> &operator=(IUnknown *unk)
{
ComPtr<T>::Clear();
unk->QueryInterface(__uuidof(T), (void**)&this->ptr);
unk->QueryInterface(__uuidof(T), (void **)&this->ptr);
return *this;
}
};