File: cwrapper.cpp

package info (click to toggle)
cjs 128.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,872 kB
  • sloc: cpp: 34,377; javascript: 27,762; ansic: 13,033; sh: 1,611; python: 780; xml: 116; makefile: 38
file content (27 lines) | stat: -rw-r--r-- 872 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
// SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
// SPDX-FileCopyrightText: 2012 Red Hat, Inc.

#include <config.h>

#include <glib-object.h>

#include <js/PropertyDescriptor.h>  // for JSPROP_PERMANENT
#include <js/RootingAPI.h>
#include <js/TypeDecls.h>

#include "gi/cwrapper.h"
#include "gi/gtype.h"
#include "cjs/atoms.h"
#include "cjs/context-private.h"

bool gjs_wrapper_define_gtype_prop(JSContext* cx, JS::HandleObject constructor,
                                   GType gtype) {
    JS::RootedObject gtype_obj(cx, gjs_gtype_create_gtype_wrapper(cx, gtype));
    if (!gtype_obj)
        return false;

    const GjsAtoms& atoms = GjsContextPrivate::atoms(cx);
    return JS_DefinePropertyById(cx, constructor, atoms.gtype(), gtype_obj,
                                 JSPROP_PERMANENT);
}