* FundamentalInstance::associate_js_instance: * * Associates @gfundamental with @object so that @object can be retrieved in the * future if you have a pointer to @gfundamental. (Assuming @object has not been * garbage collected in the meantime.) */
| 59 | * garbage collected in the meantime.) |
| 60 | */ |
| 61 | bool FundamentalInstance::associate_js_instance(JSContext* cx, JSObject* object, |
| 62 | void* gfundamental) { |
| 63 | m_ptr = gfundamental; |
| 64 | |
| 65 | GjsContextPrivate* gjs = GjsContextPrivate::from_cx(cx); |
| 66 | if (!gjs->fundamental_table().putNew(gfundamental, object)) { |
| 67 | JS_ReportOutOfMemory(cx); |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | debug_lifecycle(object, "associated JSObject with fundamental"); |
| 72 | |
| 73 | ref(); |
| 74 | return true; |
| 75 | } |
| 76 | |
| 77 | // Find the first constructor |
| 78 | [[nodiscard]] |