15 #ifndef SHAKA_EMBEDDED_CORE_WEAK_JS_PTR_H_ 16 #define SHAKA_EMBEDDED_CORE_WEAK_JS_PTR_H_ 18 #include <glog/logging.h> 20 #include <type_traits> 50 template <
typename U = T>
60 template <
typename U = T>
62 return ptr_ == other.ptr_;
64 template <
typename U = T>
68 template <
typename U = T>
70 return ptr_ != other.ptr_;
72 template <
typename U = T>
80 return ptr_.IsEmpty();
81 #elif defined(USING_JSC) 91 #elif defined(USING_JSC) 97 ReturnVal<JsValue>
value()
const {
102 #if defined(USING_V8) 104 #elif defined(USING_JSC) 108 template <
typename U>
110 ResetInternal(other);
116 #if defined(USING_V8) 123 static_assert(std::is_convertible<T, v8::Data>::value,
124 "Can only store Data types");
126 v8_trace->RegisterEmbedderReference(ptr_.template As<v8::Data>());
135 template <
typename U>
136 void ResetInternal(
const U& other) {
137 #if defined(USING_V8) 140 if (ptr_.IsEmpty() && other.IsEmpty())
149 #if defined(USING_V8) 150 v8::TracedGlobal<T> ptr_;
151 #elif defined(USING_JSC) 158 #endif // SHAKA_EMBEDDED_CORE_WEAK_JS_PTR_H_
WeakJsPtr(Handle< U > other)
void Trace(memory::HeapTracer *tracer) const override
bool operator==(const WeakJsPtr< U > &other) const
bool operator!=(const WeakJsPtr< U > &other) const
ReturnVal< JsValue > value() const
bool operator!=(const Handle< U > &other) const
ReturnVal< JsValue > RawToJsValue(Handle< T > source)
bool operator==(const Handle< U > &other) const
WeakJsPtr & operator=(const WeakJsPtr &other)=default
WeakJsPtr(std::nullptr_t)
Handle< T > handle() const
v8::Isolate * GetIsolate()
void reset(Handle< U > other)