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