Debian Codegraph @

src/dex-promise.h

raw symbols SCIP
1 /*
2 * dex-promise.h
3 *
4 * Copyright 2022 Christian Hergert <[email protected]>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this library; if not, see <http://www.gnu.org/licenses/>.
18 *
19 * SPDX-License-Identifier: LGPL-2.1-or-later
20 */
21
22 #pragma once
23
24 #if !defined (DEX_INSIDE) && !defined (DEX_COMPILATION)
25 # error "Only <libdex.h> can be included directly."
26 #endif
27
28 #include <gio/gio.h>
29
30 #include "dex-future.h"
31
32 G_BEGIN_DECLS
33
34 #define DEX_TYPE_PROMISE (dex_promise_get_type())
35 #define DEX_IS_PROMISE(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, DEX_TYPE_PROMISE))
36 #define DEX_PROMISE(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, DEX_TYPE_PROMISE, DexPromise))
37
38 typedef struct _DexPromise DexPromise;
39
40 DEX_AVAILABLE_IN_ALL
41 GType dex_promise_get_type (void);
42 DEX_AVAILABLE_IN_ALL
43 DexPromise *dex_promise_new (void) G_GNUC_WARN_UNUSED_RESULT;
44 DEX_AVAILABLE_IN_ALL
45 DexPromise *dex_promise_new_cancellable (void) G_GNUC_WARN_UNUSED_RESULT;
46 DEX_AVAILABLE_IN_ALL
47 GCancellable *dex_promise_get_cancellable (DexPromise *promise);
48 DEX_AVAILABLE_IN_ALL
49 void dex_promise_resolve (DexPromise *promise,
50 const GValue *value);
51 DEX_AVAILABLE_IN_ALL
52 void dex_promise_resolve_fd (DexPromise *promise,
53 int fd);
54 DEX_AVAILABLE_IN_ALL
55 void dex_promise_resolve_int (DexPromise *promise,
56 int value);
57 DEX_AVAILABLE_IN_ALL
58 void dex_promise_resolve_uint (DexPromise *promise,
59 guint value);
60 DEX_AVAILABLE_IN_1_2
61 void dex_promise_resolve_enum (DexPromise *promise,
62 GType enum_type,
63 guint value);
64 DEX_AVAILABLE_IN_ALL
65 void dex_promise_resolve_int64 (DexPromise *promise,
66 gint64 value);
67 DEX_AVAILABLE_IN_ALL
68 void dex_promise_resolve_uint64 (DexPromise *promise,
69 guint64 value);
70 DEX_AVAILABLE_IN_ALL
71 void dex_promise_resolve_long (DexPromise *promise,
72 glong value);
73 DEX_AVAILABLE_IN_ALL
74 void dex_promise_resolve_ulong (DexPromise *promise,
75 glong value);
76 DEX_AVAILABLE_IN_ALL
77 void dex_promise_resolve_float (DexPromise *promise,
78 float value);
79 DEX_AVAILABLE_IN_ALL
80 void dex_promise_resolve_double (DexPromise *promise,
81 double value);
82 DEX_AVAILABLE_IN_ALL
83 void dex_promise_resolve_boolean (DexPromise *promise,
84 gboolean value);
85 DEX_AVAILABLE_IN_ALL
86 void dex_promise_resolve_string (DexPromise *promise,
87 char *value);
88 DEX_AVAILABLE_IN_ALL
89 void dex_promise_resolve_object (DexPromise *promise,
90 gpointer object);
91 DEX_AVAILABLE_IN_ALL
92 void dex_promise_resolve_variant (DexPromise *promise,
93 GVariant *variant);
94 DEX_AVAILABLE_IN_ALL
95 void dex_promise_resolve_boxed (DexPromise *promise,
96 GType boxed_type,
97 gpointer instance);
98 DEX_AVAILABLE_IN_ALL
99 void dex_promise_reject (DexPromise *promise,
100 GError *error);
101
102 G_DEFINE_AUTOPTR_CLEANUP_FUNC (DexPromise, dex_unref)
103
104 #if G_GNUC_CHECK_VERSION(3,0) && !defined(DEX_DISABLE_STATIC_NAME_MACROS)
105 # define _DEX_PROMISE_NEW(func, ...) \
106 ({ DexPromise *__p = G_PASTE (dex_promise_, func) (__VA_ARGS__); \
107 dex_future_set_static_name (DEX_FUTURE (__p), G_STRLOC); \
108 __p; })
109 # define dex_promise_new() _DEX_PROMISE_NEW(new)
110 #endif
111
112 G_END_DECLS