MCPcopy Create free account
hub / github.com/GNOME/gjs / boxed

Method boxed

gjs/objectbox.cpp:91–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89void ObjectBox::destroy_impl(ObjectBox::impl* impl) { delete impl; }
90
91ObjectBox::Ptr ObjectBox::boxed(JSContext* cx, JSObject* obj) {
92 ObjectBox::Ptr box;
93
94 ObjectBox** found =
95 std::find_if(m_wrappers.begin(), m_wrappers.end(),
96 [obj](ObjectBox* b) { return b->m_impl->m_root == obj; });
97 if (found != m_wrappers.end()) {
98 box = *found;
99 box->m_impl->ref();
100 box->m_impl->debug("Reusing box");
101 } else {
102 box = new ObjectBox(obj);
103 if (!box->m_impl->init(cx))
104 return nullptr;
105 }
106
107 return box;
108}
109
110JSObject* ObjectBox::object_for_c_ptr(JSContext* cx, ObjectBox* box) {
111 if (!box) {

Callers

nothing calls this directly

Calls 5

beginMethod · 0.80
endMethod · 0.80
debugMethod · 0.65
refMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected