Branch data Line data Source code
1 : : /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 : : // SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
3 : : // SPDX-FileCopyrightText: 2008 litl, LLC
4 : :
5 : : #ifndef GI_OBJECT_H_
6 : : #define GI_OBJECT_H_
7 : :
8 : : #include <config.h>
9 : :
10 : : #include <stddef.h> // for size_t
11 : : #include <stdint.h> // for uint32_t
12 : :
13 : : #include <functional>
14 : : #include <vector>
15 : :
16 : : #include <girepository.h>
17 : : #include <glib-object.h>
18 : : #include <glib.h>
19 : :
20 : : #include <js/AllocPolicy.h>
21 : : #include <js/GCHashTable.h> // for GCHashMap
22 : : #include <js/HashTable.h> // for DefaultHasher
23 : : #include <js/Id.h>
24 : : #include <js/PropertySpec.h>
25 : : #include <js/RootingAPI.h>
26 : : #include <js/TypeDecls.h>
27 : : #include <mozilla/HashFunctions.h> // for HashGeneric, HashNumber
28 : : #include <mozilla/Likely.h> // for MOZ_LIKELY
29 : : #include <mozilla/Maybe.h>
30 : :
31 : : #include "gi/info.h"
32 : : #include "gi/value.h"
33 : : #include "gi/wrapperutils.h"
34 : : #include "gjs/auto.h"
35 : : #include "gjs/jsapi-util-root.h"
36 : : #include "gjs/macros.h"
37 : : #include "util/log.h"
38 : :
39 : : class GjsAtoms;
40 : : class JSTracer;
41 : : namespace JS {
42 : : class CallArgs;
43 : : }
44 : : namespace Gjs {
45 : : namespace Test {
46 : : struct ObjectInstance;
47 : : }
48 : : }
49 : : class ObjectInstance;
50 : : class ObjectPrototype;
51 : : class ObjectPropertyInfoCaller;
52 : : class ObjectPropertyPspecCaller;
53 : :
54 : : /*
55 : : * ObjectBase:
56 : : *
57 : : * Specialization of GIWrapperBase for GObject instances. See the documentation
58 : : * in wrapperutils.h.
59 : : *
60 : : * It's important that ObjectBase and ObjectInstance not grow in size without a
61 : : * very good reason. There can be tens, maybe hundreds of thousands of these
62 : : * objects alive in a typical gnome-shell run, so even 8 more bytes will add up.
63 : : * It's less critical that ObjectPrototype stay small, since only one of these
64 : : * is allocated per GType.
65 : : */
66 : : class ObjectBase
67 : : : public GIWrapperBase<ObjectBase, ObjectPrototype, ObjectInstance> {
68 : : friend class GIWrapperBase<ObjectBase, ObjectPrototype, ObjectInstance>;
69 : :
70 : : protected:
71 : 2122 : explicit ObjectBase(ObjectPrototype* proto = nullptr)
72 : 2122 : : GIWrapperBase(proto) {}
73 : :
74 : : public:
75 : : using SignalMatchFunc = guint(gpointer, GSignalMatchType, guint, GQuark,
76 : : GClosure*, gpointer, gpointer);
77 : : static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_GOBJECT;
78 : : static constexpr const char* DEBUG_TAG = "GObject";
79 : :
80 : : static const struct JSClassOps class_ops;
81 : : static const struct JSClass klass;
82 : : static JSFunctionSpec proto_methods[];
83 : : static JSPropertySpec proto_properties[];
84 : :
85 : : static GObject* to_c_ptr(JSContext* cx, JS::HandleObject obj) = delete;
86 : : GJS_JSAPI_RETURN_CONVENTION
87 : : static bool to_c_ptr(JSContext* cx, JS::HandleObject obj, GObject** ptr);
88 : : GJS_JSAPI_RETURN_CONVENTION
89 : : static bool transfer_to_gi_argument(JSContext* cx, JS::HandleObject obj,
90 : : GIArgument* arg,
91 : : GIDirection transfer_direction,
92 : : GITransfer transfer_ownership,
93 : : GType expected_gtype,
94 : : GIBaseInfo* expected_info = nullptr);
95 : :
96 : : private:
97 : : // This is used in debug methods only.
98 : : [[nodiscard]] const void* jsobj_addr() const;
99 : :
100 : : /* Helper methods */
101 : :
102 : : protected:
103 : 5671 : void debug_lifecycle(const char* message) const {
104 : 5671 : GIWrapperBase::debug_lifecycle(jsobj_addr(), message);
105 : 5671 : }
106 : :
107 : : [[nodiscard]] bool id_is_never_lazy(jsid name, const GjsAtoms& atoms);
108 : : [[nodiscard]] bool is_custom_js_class();
109 : :
110 : : public:
111 : : GJS_JSAPI_RETURN_CONVENTION
112 : : static bool typecheck(JSContext* cx, JS::HandleObject obj,
113 : : GIObjectInfo* expected_info, GType expected_gtype);
114 : 262 : [[nodiscard]] static bool typecheck(JSContext* cx, JS::HandleObject obj,
115 : : GIObjectInfo* expected_info,
116 : : GType expected_gtype,
117 : : GjsTypecheckNoThrow no_throw) {
118 : 262 : return GIWrapperBase::typecheck(cx, obj, expected_info, expected_gtype,
119 : 262 : no_throw);
120 : : }
121 : :
122 : : /* JSClass operations */
123 : :
124 : : static bool add_property(JSContext* cx, JS::HandleObject obj,
125 : : JS::HandleId id, JS::HandleValue value);
126 : :
127 : : /* JS property getters/setters */
128 : :
129 : : public:
130 : : template <typename T = void, GITypeTag TAG = GI_TYPE_TAG_VOID>
131 : : GJS_JSAPI_RETURN_CONVENTION static bool prop_getter(JSContext*, unsigned,
132 : : JS::Value*);
133 : : GJS_JSAPI_RETURN_CONVENTION
134 : : static bool prop_getter_write_only(JSContext*, unsigned argc,
135 : : JS::Value* vp);
136 : : GJS_JSAPI_RETURN_CONVENTION
137 : : static bool prop_getter_func(JSContext* cx, unsigned argc, JS::Value* vp);
138 : : template <typename T = void, GITypeTag TAG = GI_TYPE_TAG_VOID,
139 : : GITransfer TRANSFER = GI_TRANSFER_NOTHING>
140 : : GJS_JSAPI_RETURN_CONVENTION static bool prop_getter_simple_type_func(
141 : : JSContext*, unsigned argc, JS::Value* vp);
142 : : GJS_JSAPI_RETURN_CONVENTION
143 : : static bool field_getter(JSContext* cx, unsigned argc, JS::Value* vp);
144 : : template <typename T = void, GITypeTag TAG = GI_TYPE_TAG_VOID>
145 : : GJS_JSAPI_RETURN_CONVENTION static bool prop_setter(JSContext*, unsigned,
146 : : JS::Value*);
147 : : GJS_JSAPI_RETURN_CONVENTION
148 : : static bool prop_setter_read_only(JSContext*, unsigned argc, JS::Value* vp);
149 : : GJS_JSAPI_RETURN_CONVENTION
150 : : static bool prop_setter_func(JSContext* cx, unsigned argc, JS::Value* vp);
151 : : template <typename T = void, GITypeTag TAG = GI_TYPE_TAG_VOID,
152 : : GITransfer TRANSFER = GI_TRANSFER_NOTHING>
153 : : GJS_JSAPI_RETURN_CONVENTION static bool prop_setter_simple_type_func(
154 : : JSContext*, unsigned argc, JS::Value* vp);
155 : : GJS_JSAPI_RETURN_CONVENTION
156 : : static bool field_setter(JSContext* cx, unsigned argc, JS::Value* vp);
157 : :
158 : : /* JS methods */
159 : :
160 : : GJS_JSAPI_RETURN_CONVENTION
161 : : static bool connect(JSContext* cx, unsigned argc, JS::Value* vp);
162 : : GJS_JSAPI_RETURN_CONVENTION
163 : : static bool connect_after(JSContext* cx, unsigned argc, JS::Value* vp);
164 : : GJS_JSAPI_RETURN_CONVENTION
165 : : static bool connect_object(JSContext* cx, unsigned argc, JS::Value* vp);
166 : : GJS_JSAPI_RETURN_CONVENTION
167 : : static bool emit(JSContext* cx, unsigned argc, JS::Value* vp);
168 : : GJS_JSAPI_RETURN_CONVENTION
169 : : static bool signal_find(JSContext* cx, unsigned argc, JS::Value* vp);
170 : : template <SignalMatchFunc(*MATCH_FUNC)>
171 : : GJS_JSAPI_RETURN_CONVENTION static bool signals_action(JSContext* cx,
172 : : unsigned argc,
173 : : JS::Value* vp);
174 : : GJS_JSAPI_RETURN_CONVENTION
175 : : static bool to_string(JSContext* cx, unsigned argc, JS::Value* vp);
176 : : GJS_JSAPI_RETURN_CONVENTION
177 : : static bool init_gobject(JSContext* cx, unsigned argc, JS::Value* vp);
178 : : GJS_JSAPI_RETURN_CONVENTION
179 : : static bool hook_up_vfunc(JSContext* cx, unsigned argc, JS::Value* vp);
180 : :
181 : : /* Quarks */
182 : :
183 : : protected:
184 : : [[nodiscard]] static GQuark instance_strings_quark();
185 : :
186 : : public:
187 : : [[nodiscard]] static GQuark custom_type_quark();
188 : : [[nodiscard]] static GQuark custom_property_quark();
189 : : [[nodiscard]] static GQuark disposed_quark();
190 : : };
191 : :
192 : : // See https://bugzilla.mozilla.org/show_bug.cgi?id=1614220
193 : : struct IdHasher {
194 : : typedef jsid Lookup;
195 : 12987 : static mozilla::HashNumber hash(jsid id) {
196 [ + + ]: 12987 : if (MOZ_LIKELY(id.isString()))
197 : 12478 : return js::DefaultHasher<JSString*>::hash(id.toString());
198 [ + - ]: 509 : if (id.isSymbol())
199 : 509 : return js::DefaultHasher<JS::Symbol*>::hash(id.toSymbol());
200 : 0 : return mozilla::HashGeneric(id.asRawBits());
201 : : }
202 : 5974 : static bool match(jsid id1, jsid id2) { return id1 == id2; }
203 : : };
204 : :
205 : : class ObjectPrototype
206 : : : public GIWrapperPrototype<ObjectBase, ObjectPrototype, ObjectInstance> {
207 : : friend class GIWrapperPrototype<ObjectBase, ObjectPrototype,
208 : : ObjectInstance>;
209 : : friend class GIWrapperBase<ObjectBase, ObjectPrototype, ObjectInstance>;
210 : :
211 : : using NegativeLookupCache =
212 : : JS::GCHashSet<JS::Heap<jsid>, IdHasher, js::SystemAllocPolicy>;
213 : :
214 : : NegativeLookupCache m_unresolvable_cache;
215 : : // a list of vfunc GClosures installed on this prototype, used when tracing
216 : : std::vector<GClosure*> m_vfuncs;
217 : : // a list of interface types explicitly associated with this prototype,
218 : : // by gjs_add_interface
219 : : std::vector<GType> m_interface_gtypes;
220 : :
221 : : ObjectPrototype(GIObjectInfo* info, GType gtype);
222 : : ~ObjectPrototype();
223 : :
224 : : static constexpr InfoType::Tag info_type_tag = InfoType::Object;
225 : :
226 : : public:
227 : : [[nodiscard]] static ObjectPrototype* for_gtype(GType gtype);
228 : :
229 : : /* Helper methods */
230 : : private:
231 : : GJS_JSAPI_RETURN_CONVENTION
232 : : bool get_parent_proto(JSContext* cx, JS::MutableHandleObject proto) const;
233 : : GJS_JSAPI_RETURN_CONVENTION
234 : : bool get_parent_constructor(JSContext* cx,
235 : : JS::MutableHandleObject constructor) const;
236 : :
237 : : [[nodiscard]] bool is_vfunc_unchanged(GIVFuncInfo* info);
238 : : static void vfunc_invalidated_notify(void* data, GClosure* closure);
239 : :
240 : : GJS_JSAPI_RETURN_CONVENTION
241 : : bool lazy_define_gobject_property(
242 : : JSContext* cx, JS::HandleObject obj, JS::HandleId id, GParamSpec*,
243 : : bool* resolved, const char* name,
244 : : mozilla::Maybe<const GI::AutoPropertyInfo> = {});
245 : :
246 : : enum ResolveWhat { ConsiderOnlyMethods, ConsiderMethodsAndProperties };
247 : : GJS_JSAPI_RETURN_CONVENTION
248 : : bool resolve_no_info(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
249 : : bool* resolved, const char* name,
250 : : ResolveWhat resolve_props);
251 : : GJS_JSAPI_RETURN_CONVENTION
252 : : bool uncached_resolve(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
253 : : const char* name, bool* resolved);
254 : :
255 : : public:
256 : : void set_interfaces(GType* interface_gtypes, uint32_t n_interface_gtypes);
257 : : void set_type_qdata(void);
258 : : GJS_JSAPI_RETURN_CONVENTION
259 : : GParamSpec* find_param_spec_from_id(JSContext*,
260 : : Gjs::AutoTypeClass<GObjectClass> const&,
261 : : JS::HandleString key);
262 : : GJS_JSAPI_RETURN_CONVENTION
263 : : bool props_to_g_parameters(JSContext*,
264 : : Gjs::AutoTypeClass<GObjectClass> const&,
265 : : JS::HandleObject props,
266 : : std::vector<const char*>* names,
267 : : AutoGValueVector* values);
268 : :
269 : : GJS_JSAPI_RETURN_CONVENTION
270 : : static bool define_class(JSContext* cx, JS::HandleObject in_object,
271 : : GIObjectInfo* info, GType gtype,
272 : : GType* interface_gtypes,
273 : : uint32_t n_interface_gtypes,
274 : : JS::MutableHandleObject constructor,
275 : : JS::MutableHandleObject prototype);
276 : :
277 : 0 : void ref_vfuncs(void) {
278 [ # # ]: 0 : for (GClosure* closure : m_vfuncs)
279 : 0 : g_closure_ref(closure);
280 : 0 : }
281 : 0 : void unref_vfuncs(void) {
282 [ # # ]: 0 : for (GClosure* closure : m_vfuncs)
283 : 0 : g_closure_unref(closure);
284 : 0 : }
285 : :
286 : : /* JSClass operations */
287 : : private:
288 : : GJS_JSAPI_RETURN_CONVENTION
289 : : bool resolve_impl(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
290 : : bool* resolved);
291 : :
292 : : GJS_JSAPI_RETURN_CONVENTION
293 : : bool new_enumerate_impl(JSContext* cx, JS::HandleObject obj,
294 : : JS::MutableHandleIdVector properties,
295 : : bool only_enumerable);
296 : : void trace_impl(JSTracer* tracer);
297 : :
298 : : /* JS methods */
299 : : public:
300 : : GJS_JSAPI_RETURN_CONVENTION
301 : : bool hook_up_vfunc_impl(JSContext* cx, const JS::CallArgs& args);
302 : : };
303 : :
304 : : class ObjectInstance : public GIWrapperInstance<ObjectBase, ObjectPrototype,
305 : : ObjectInstance, GObject> {
306 : : friend class GIWrapperInstance<ObjectBase, ObjectPrototype, ObjectInstance,
307 : : GObject>;
308 : : friend class GIWrapperBase<ObjectBase, ObjectPrototype, ObjectInstance>;
309 : : friend class ObjectBase; // for add_property, prop_getter, etc.
310 : : friend struct Gjs::Test::ObjectInstance;
311 : :
312 : : // GIWrapperInstance::m_ptr may be null in ObjectInstance.
313 : :
314 : : GjsMaybeOwned m_wrapper;
315 : : // a list of all GClosures installed on this object (from signal connections
316 : : // and scope-notify callbacks passed to methods), used when tracing
317 : : std::vector<GClosure*> m_closures;
318 : :
319 : : bool m_wrapper_finalized : 1;
320 : : bool m_gobj_disposed : 1;
321 : : bool m_gobj_finalized : 1;
322 : :
323 : : /* True if this object has visible JS state, and thus its lifecycle is
324 : : * managed using toggle references. False if this object just keeps a
325 : : * hard ref on the underlying GObject, and may be finalized at will. */
326 : : bool m_uses_toggle_ref : 1;
327 : :
328 : : static bool s_weak_pointer_callback;
329 : :
330 : : /* Constructors */
331 : :
332 : : private:
333 : : ObjectInstance(ObjectPrototype* prototype, JS::HandleObject obj);
334 : : ~ObjectInstance();
335 : :
336 : : GJS_JSAPI_RETURN_CONVENTION
337 : : static ObjectInstance* new_for_gobject(JSContext* cx, GObject* gobj);
338 : :
339 : : // Extra method to get an existing ObjectInstance from qdata
340 : :
341 : : public:
342 : : [[nodiscard]] static ObjectInstance* for_gobject(GObject* gobj);
343 : :
344 : : /* Accessors */
345 : :
346 : : private:
347 : 2692 : [[nodiscard]] bool has_wrapper() const { return !!m_wrapper; }
348 : :
349 : : public:
350 : 2751 : [[nodiscard]] JSObject* wrapper() const { return m_wrapper.get(); }
351 : :
352 : : /* Methods to manipulate the JS object wrapper */
353 : :
354 : : private:
355 : 1702 : void discard_wrapper(void) { m_wrapper.reset(); }
356 : 1122 : void switch_to_rooted(JSContext* cx) { m_wrapper.switch_to_rooted(cx); }
357 : 981 : void switch_to_unrooted(JSContext* cx) { m_wrapper.switch_to_unrooted(cx); }
358 : 1411 : [[nodiscard]] bool update_after_gc(JSTracer* trc) {
359 : 1411 : return m_wrapper.update_after_gc(trc);
360 : : }
361 : 7571 : [[nodiscard]] bool wrapper_is_rooted() const { return m_wrapper.rooted(); }
362 : : void release_native_object(void);
363 : : void associate_js_gobject(JSContext* cx, JS::HandleObject obj,
364 : : GObject* gobj);
365 : : void disassociate_js_gobject(void);
366 : : void handle_context_dispose(void);
367 : : [[nodiscard]] bool weak_pointer_was_finalized(JSTracer* trc);
368 : : static void ensure_weak_pointer_callback(JSContext* cx);
369 : : static void update_heap_wrapper_weak_pointers(JSTracer* trc,
370 : : JS::Compartment*, void* data);
371 : :
372 : : public:
373 : : void toggle_down(void);
374 : : void toggle_up(void);
375 : :
376 : : GJS_JSAPI_RETURN_CONVENTION
377 : : static JSObject* wrapper_from_gobject(JSContext* cx, GObject* ptr);
378 : :
379 : : GJS_JSAPI_RETURN_CONVENTION
380 : : static bool set_value_from_gobject(JSContext* cx, GObject*,
381 : : JS::MutableHandleValue);
382 : :
383 : : /* Methods to manipulate the list of closures */
384 : :
385 : : private:
386 : : void invalidate_closures();
387 : : static void closure_invalidated_notify(void* data, GClosure* closure);
388 : :
389 : : public:
390 : : GJS_JSAPI_RETURN_CONVENTION bool associate_closure(JSContext*, GClosure*);
391 : :
392 : : /* Helper methods */
393 : :
394 : : private:
395 : : void set_object_qdata(void);
396 : : void unset_object_qdata(void);
397 : : void track_gobject_finalization();
398 : : void ignore_gobject_finalization();
399 : : void check_js_object_finalized(void);
400 : : void ensure_uses_toggle_ref(JSContext*);
401 : : [[nodiscard]] bool check_gobject_disposed_or_finalized(
402 : : const char* for_what) const;
403 : : [[nodiscard]] bool check_gobject_finalized(const char* for_what) const;
404 : : GJS_JSAPI_RETURN_CONVENTION
405 : : bool signal_match_arguments_from_object(
406 : : JSContext* cx, JS::HandleObject props_obj, GSignalMatchType* mask_out,
407 : : unsigned* signal_id_out, GQuark* detail_out,
408 : : JS::MutableHandleObject callable_out);
409 : :
410 : : public:
411 : 55 : static GObject* copy_ptr(JSContext*, GType, void* ptr) {
412 : 55 : return G_OBJECT(g_object_ref(G_OBJECT(ptr)));
413 : : }
414 : :
415 : : GJS_JSAPI_RETURN_CONVENTION
416 : : bool init_custom_class_from_gobject(JSContext* cx, JS::HandleObject wrapper,
417 : : GObject* gobj);
418 : :
419 : : static void associate_string(GObject* obj, char* str);
420 : :
421 : : /* Methods to manipulate the linked list of instances */
422 : :
423 : : private:
424 : : static std::vector<ObjectInstance*> s_wrapped_gobject_list;
425 : : void link(void);
426 : : void unlink(void);
427 : : [[nodiscard]] static size_t num_wrapped_gobjects() {
428 : : return s_wrapped_gobject_list.size();
429 : : }
430 : : using Action = std::function<void(ObjectInstance*)>;
431 : : using Predicate = std::function<bool(ObjectInstance*)>;
432 : : static void remove_wrapped_gobjects_if(const Predicate& predicate,
433 : : const Action& action);
434 : :
435 : : public:
436 : : static void prepare_shutdown(void);
437 : :
438 : : /* JSClass operations */
439 : :
440 : : private:
441 : : GJS_JSAPI_RETURN_CONVENTION
442 : : bool add_property_impl(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
443 : : JS::HandleValue value);
444 : : void finalize_impl(JS::GCContext*, JSObject* obj);
445 : : void trace_impl(JSTracer* trc);
446 : :
447 : : /* JS property getters/setters */
448 : :
449 : : private:
450 : : template <typename T, GITypeTag TAG = GI_TYPE_TAG_VOID>
451 : : GJS_JSAPI_RETURN_CONVENTION bool prop_getter_impl(
452 : : JSContext* cx, GParamSpec*, JS::MutableHandleValue rval);
453 : : GJS_JSAPI_RETURN_CONVENTION
454 : : bool prop_getter_impl(JSContext* cx, ObjectPropertyInfoCaller*,
455 : : JS::CallArgs const& args);
456 : : template <typename T, GITypeTag TAG = GI_TYPE_TAG_VOID,
457 : : GITransfer TRANSFER = GI_TRANSFER_NOTHING>
458 : : GJS_JSAPI_RETURN_CONVENTION bool prop_getter_impl(
459 : : JSContext*, ObjectPropertyPspecCaller*, JS::CallArgs const&);
460 : : GJS_JSAPI_RETURN_CONVENTION
461 : : bool field_getter_impl(JSContext* cx, GI::AutoFieldInfo const&,
462 : : JS::MutableHandleValue rval);
463 : : template <typename T, GITypeTag TAG = GI_TYPE_TAG_VOID>
464 : : GJS_JSAPI_RETURN_CONVENTION bool prop_setter_impl(JSContext*, GParamSpec*,
465 : : JS::HandleValue);
466 : : GJS_JSAPI_RETURN_CONVENTION
467 : : bool prop_setter_impl(JSContext* cx, ObjectPropertyInfoCaller*,
468 : : JS::CallArgs const& args);
469 : : template <typename T, GITypeTag TAG = GI_TYPE_TAG_VOID,
470 : : GITransfer TRANSFER = GI_TRANSFER_NOTHING>
471 : : GJS_JSAPI_RETURN_CONVENTION bool prop_setter_impl(
472 : : JSContext*, ObjectPropertyPspecCaller*, JS::CallArgs const&);
473 : : GJS_JSAPI_RETURN_CONVENTION
474 : : bool field_setter_not_impl(JSContext* cx, GI::AutoFieldInfo const&);
475 : :
476 : : // JS constructor
477 : :
478 : : GJS_JSAPI_RETURN_CONVENTION
479 : : bool constructor_impl(JSContext* cx, JS::HandleObject obj,
480 : : const JS::CallArgs& args);
481 : :
482 : : /* JS methods */
483 : :
484 : : private:
485 : : GJS_JSAPI_RETURN_CONVENTION
486 : : bool connect_impl(JSContext* cx, const JS::CallArgs& args, bool after,
487 : : bool object = false);
488 : : GJS_JSAPI_RETURN_CONVENTION
489 : : bool emit_impl(JSContext* cx, const JS::CallArgs& args);
490 : : GJS_JSAPI_RETURN_CONVENTION
491 : : bool signal_find_impl(JSContext* cx, const JS::CallArgs& args);
492 : : template <SignalMatchFunc(*MATCH_FUNC)>
493 : : GJS_JSAPI_RETURN_CONVENTION bool signals_action_impl(
494 : : JSContext* cx, const JS::CallArgs& args);
495 : : GJS_JSAPI_RETURN_CONVENTION
496 : : bool init_impl(JSContext* cx, const JS::CallArgs& args,
497 : : JS::HandleObject obj);
498 : : [[nodiscard]] const char* to_string_kind() const;
499 : :
500 : : GJS_JSAPI_RETURN_CONVENTION
501 : : bool typecheck_impl(JSContext* cx, GIBaseInfo* expected_info,
502 : : GType expected_type) const;
503 : :
504 : : /* Notification callbacks */
505 : : void gobj_dispose_notify(void);
506 : : static void wrapped_gobj_dispose_notify(void* data, GObject*);
507 : : static void wrapped_gobj_toggle_notify(void* instance, GObject* gobj,
508 : : gboolean is_last_ref);
509 : :
510 : : public:
511 : : static void context_dispose_notify(void* data,
512 : : GObject* where_the_object_was);
513 : : };
514 : :
515 : : GJS_JSAPI_RETURN_CONVENTION
516 : : bool gjs_lookup_object_constructor(JSContext *context,
517 : : GType gtype,
518 : : JS::MutableHandleValue value_p);
519 : :
520 : : void gjs_object_clear_toggles(void);
521 : : void gjs_object_shutdown_toggle_queue(void);
522 : :
523 : : #endif // GI_OBJECT_H_
|