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: 2019 Marco Trevisan <marco.trevisan@canonical.com>
4 : :
5 : : #pragma once
6 : :
7 : : #include <config.h>
8 : :
9 : : #include <glib-object.h>
10 : :
11 : : #include <js/TypeDecls.h>
12 : :
13 : : #include "gjs/auto.h"
14 : : #include "gjs/macros.h"
15 : :
16 : : class ObjectBox {
17 : : static void destroy(ObjectBox*);
18 : :
19 : : public:
20 : 36 : using Ptr = Gjs::AutoPointer<ObjectBox, ObjectBox, ObjectBox::destroy>;
21 : :
22 : : [[nodiscard]] static GType gtype();
23 : :
24 : : [[nodiscard]] static ObjectBox::Ptr boxed(JSContext*, JSObject*);
25 : :
26 : : GJS_JSAPI_RETURN_CONVENTION
27 : : static JSObject* object_for_c_ptr(JSContext*, ObjectBox*);
28 : :
29 : : private:
30 : : explicit ObjectBox(JSContext*, JSObject*);
31 : :
32 : : static void* boxed_copy(void*);
33 : : static void boxed_free(void*);
34 : :
35 : : struct impl;
36 : : static void destroy_impl(impl*);
37 : 33 : Gjs::AutoPointer<impl, impl, destroy_impl> m_impl;
38 : : };
|