Branch data Line data Source code
1 : : /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 : : /*
3 : : * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
4 : : * SPDX-FileCopyrightText: 2008 litl, LLC
5 : : */
6 : :
7 : : #ifndef GJS_CONTEXT_H_
8 : : #define GJS_CONTEXT_H_
9 : :
10 : : #if !defined(INSIDE_GJS_H) && !defined(GJS_COMPILATION)
11 : : # error "Only <gjs/gjs.h> can be included directly."
12 : : #endif
13 : :
14 : : #include <stdbool.h> /* IWYU pragma: keep */
15 : : #include <stdint.h>
16 : : #include <sys/types.h> /* for ssize_t */
17 : :
18 : : #ifndef _WIN32
19 : : # include <signal.h> /* for siginfo_t */
20 : : #endif
21 : :
22 : : #include <glib-object.h>
23 : : #include <glib.h>
24 : :
25 : : #include <gjs/macros.h>
26 : : #include <gjs/profiler.h>
27 : :
28 : : G_BEGIN_DECLS
29 : :
30 : : #define GJS_TYPE_CONTEXT (gjs_context_get_type ())
31 : :
32 : : /* clang-format off */
33 : : GJS_EXPORT GJS_USE
34 [ - + + - : 16291 : G_DECLARE_FINAL_TYPE(GjsContext, gjs_context, GJS, CONTEXT, GObject);
+ - ]
35 : : /* clang-format on */
36 : :
37 : : /* These class macros are not defined by G_DECLARE_FINAL_TYPE, but are kept for
38 : : * backwards compatibility */
39 : : #define GJS_CONTEXT_CLASS(klass) \
40 : : (G_TYPE_CHECK_CLASS_CAST((klass), GJS_TYPE_CONTEXT, GjsContextClass))
41 : : #define GJS_IS_CONTEXT_CLASS(klass) \
42 : : (G_TYPE_CHECK_CLASS_TYPE((klass), GJS_TYPE_CONTEXT))
43 : : #define GJS_CONTEXT_GET_CLASS(obj) \
44 : : (G_TYPE_INSTANCE_GET_CLASS((obj), GJS_TYPE_CONTEXT, GjsContextClass))
45 : :
46 : : typedef void (*GjsContextInRealmFunc)(GjsContext*, void*);
47 : :
48 : : GJS_EXPORT GJS_USE
49 : : GjsContext* gjs_context_new(void);
50 : : GJS_EXPORT GJS_USE
51 : : GjsContext* gjs_context_new_with_search_path(char** search_path);
52 : : GJS_EXPORT GJS_USE
53 : : bool gjs_context_eval_file(GjsContext* self, const char* filename,
54 : : int* exit_status_p, GError** error);
55 : : GJS_EXPORT GJS_USE
56 : : bool gjs_context_eval_module_file(GjsContext* self, const char* filename,
57 : : uint8_t* exit_status_p, GError** error);
58 : : GJS_EXPORT GJS_USE
59 : : bool gjs_context_eval(GjsContext* self, const char* script, ssize_t script_len,
60 : : const char* filename, int* exit_status_p, GError** error);
61 : : GJS_EXPORT GJS_USE
62 : : bool gjs_context_register_module(GjsContext* self, const char* identifier,
63 : : const char* uri, GError** error);
64 : : GJS_EXPORT GJS_USE
65 : : bool gjs_context_eval_module(GjsContext* self, const char* identifier,
66 : : uint8_t* exit_code, GError** error);
67 : : GJS_EXPORT GJS_USE
68 : : bool gjs_context_define_string_array(GjsContext* self, const char* array_name,
69 : : ssize_t array_length,
70 : : const char** array_values, GError** error);
71 : :
72 : : GJS_EXPORT
73 : : void gjs_context_set_argv(GjsContext* self, ssize_t array_length,
74 : : const char** array_values);
75 : :
76 : : GJS_EXPORT GJS_USE
77 : : GList* gjs_context_get_all(void);
78 : :
79 : : GJS_EXPORT GJS_USE
80 : : GjsContext* gjs_context_get_current(void);
81 : : GJS_EXPORT
82 : : void gjs_context_make_current(GjsContext* self);
83 : :
84 : : GJS_EXPORT
85 : : void* gjs_context_get_native_context(GjsContext* self);
86 : :
87 : : GJS_EXPORT
88 : : void gjs_context_run_in_realm(GjsContext* self, GjsContextInRealmFunc func,
89 : : void* user_data);
90 : :
91 : : GJS_EXPORT
92 : : void gjs_context_print_stack_stderr(GjsContext* self);
93 : :
94 : : GJS_EXPORT
95 : : void gjs_context_maybe_gc(GjsContext* self);
96 : :
97 : : GJS_EXPORT
98 : : void gjs_context_gc(GjsContext* self);
99 : :
100 : : GJS_EXPORT GJS_USE
101 : : GjsProfiler* gjs_context_get_profiler(GjsContext* self);
102 : :
103 : : GJS_EXPORT GJS_USE
104 : : bool gjs_profiler_chain_signal(GjsContext* context, siginfo_t* info);
105 : :
106 : : GJS_EXPORT
107 : : void gjs_dumpstack(void);
108 : :
109 : : GJS_EXPORT GJS_USE
110 : : const char* gjs_get_js_version(void);
111 : :
112 : : GJS_EXPORT
113 : : void gjs_context_setup_debugger_console(GjsContext* self);
114 : :
115 : : GJS_EXPORT GJS_USE
116 : : const char* gjs_context_get_repl_history_path(GjsContext* self);
117 : : G_END_DECLS
118 : :
119 : : #endif /* GJS_CONTEXT_H_ */
|