| 2909 | } |
| 2910 | |
| 2911 | void ObjectInstance::associate_closure(JSContext* cx, GClosure* closure) { |
| 2912 | if (!is_prototype()) |
| 2913 | to_instance()->ensure_uses_toggle_ref(cx); |
| 2914 | |
| 2915 | g_assert(std::find(m_closures.begin(), m_closures.end(), closure) == |
| 2916 | m_closures.end() && |
| 2917 | "This closure was already associated with this object"); |
| 2918 | |
| 2919 | /* This is a weak reference, and will be cleared when the closure is |
| 2920 | * invalidated */ |
| 2921 | m_closures.push_back(closure); |
| 2922 | g_closure_add_invalidate_notifier( |
| 2923 | closure, this, &ObjectInstance::closure_invalidated_notify); |
| 2924 | } |
| 2925 | |
| 2926 | void ObjectInstance::closure_invalidated_notify(void* data, GClosure* closure) { |
| 2927 | // This callback should *only* touch m_closures |
no test coverage detected