37#if !defined(WARN_UNUSED_RETURN)
38#define WARN_UNUSED_RETURN
58 T
get()
const {
return m_ptr; }
63 T operator->()
const {
return m_ptr; }
66 explicit operator bool()
const {
return m_ptr; }
129 if (T ptr = leakRef())
135 return std::exchange(m_ptr,
nullptr);
140 return operator=(o.
get());
145 if (T ptr = std::exchange(m_ptr, o.leakRef()))
154 if (T ptr = std::exchange(m_ptr, optr))
161 std::swap(m_ptr, o.m_ptr);
171 return a.
get() == b.
get();
186 return a.
get() != b.
get();
struct OpaqueJSClass * JSClassRef
Definition JSBase.h:52
struct OpaqueJSString * JSStringRef
Definition JSBase.h:49
struct OpaqueJSContext * JSGlobalContextRef
Definition JSBase.h:46
void JSGlobalContextRelease(JSGlobalContextRef ctx)
Releases a global JavaScript execution context.
JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx)
Retains a global JavaScript execution context.
void JSClassRelease(JSClassRef jsClass)
Releases a JavaScript class.
JSClassRef JSClassRetain(JSClassRef jsClass)
Retains a JavaScript class.
void swap(JSRetainPtr< T > &a, JSRetainPtr< T > &b)
Definition JSRetainPtr.h:164
JSRetainPtr< JSClassRef > adopt(JSClassRef)
Definition JSRetainPtr.h:94
AdoptTag
Definition JSRetainPtr.h:48
@ Adopt
Definition JSRetainPtr.h:48
#define WARN_UNUSED_RETURN
Definition JSRetainPtr.h:38
bool operator==(const JSRetainPtr< T > &a, const JSRetainPtr< U > &b)
Definition JSRetainPtr.h:169
void JSRelease(JSClassRef context)
Definition JSRetainPtr.h:42
bool operator!=(const JSRetainPtr< T > &a, const JSRetainPtr< U > &b)
Definition JSRetainPtr.h:184
void JSRetain(JSClassRef context)
Definition JSRetainPtr.h:41
void JSStringRelease(JSStringRef string)
Releases a JavaScript string.
JSStringRef JSStringRetain(JSStringRef string)
Retains a JavaScript string.
Definition JSRetainPtr.h:50
void swap(JSRetainPtr &)
Definition JSRetainPtr.h:159
JSRetainPtr(T ptr)
Definition JSRetainPtr.h:53
JSRetainPtr & operator=(const JSRetainPtr &)
Definition JSRetainPtr.h:138
friend JSRetainPtr< JSStringRef > adopt(JSStringRef)
Definition JSRetainPtr.h:99
bool operator!() const
Definition JSRetainPtr.h:65
T get() const
Definition JSRetainPtr.h:58
T leakRef() WARN_UNUSED_RETURN
Definition JSRetainPtr.h:133
void clear()
Definition JSRetainPtr.h:127
~JSRetainPtr()
Definition JSRetainPtr.h:121