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: 2012 Red Hat, Inc.
4 : :
5 : : #include <config.h>
6 : :
7 : : #include <glib-object.h>
8 : :
9 : : #include <js/PropertyDescriptor.h> // for JSPROP_PERMANENT
10 : : #include <js/RootingAPI.h>
11 : : #include <js/TypeDecls.h>
12 : :
13 : : #include "gi/cwrapper.h"
14 : : #include "gi/gtype.h"
15 : : #include "gjs/atoms.h"
16 : : #include "gjs/context-private.h"
17 : :
18 : 1868 : bool gjs_wrapper_define_gtype_prop(JSContext* cx, JS::HandleObject constructor,
19 : : GType gtype) {
20 : 1868 : JS::RootedObject gtype_obj(cx, gjs_gtype_create_gtype_wrapper(cx, gtype));
21 [ - + ]: 1868 : if (!gtype_obj)
22 : 0 : return false;
23 : :
24 : 1868 : const GjsAtoms& atoms = GjsContextPrivate::atoms(cx);
25 : 3736 : return JS_DefinePropertyById(cx, constructor, atoms.gtype(), gtype_obj,
26 : 1868 : JSPROP_PERMANENT);
27 : 1868 : }
|