bzr branch
http://gegoxaren.bato24.eu/bzr/%2Bjunk/gjs-vapi
1
by Gustav Hartvigsson
* Inital, untested code |
1 |
/*
|
2 |
* SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
|
|
3 |
*
|
|
4 |
* SPDX-FileContributor: Authored By: Gustav Hartvigsson
|
|
5 |
*/
|
|
6 |
||
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
7 |
/*
|
8 |
* All comments are copid from the GJS source code, but changed to work with
|
|
9 |
* valadoc.
|
|
10 |
*/
|
|
11 |
||
12 |
/**
|
|
13 |
* JavaScript bindings for GNOME
|
|
14 |
*
|
|
15 |
* Use the GNOME platform libraries in your JavaScript programs.
|
|
16 |
* GJS powers GNOME Shell, Polari, GNOME Documents, and many other apps.
|
|
17 |
* Under the hood it uses SpiderMonkey, Mozilla's JavaScript engine
|
|
18 |
* originally developed for Firefox.
|
|
19 |
*/
|
|
4
by Gustav Hartvigsson
* Readability changes |
20 |
[CCode (cheader_filename = "gjs/gjs.h", |
21 |
cprefix = "Gjs", |
|
22 |
lower_case_cprefix = "gjs_")] |
|
1
by Gustav Hartvigsson
* Inital, untested code |
23 |
namespace Gjs { |
24 |
|
|
25 |
|
|
4
by Gustav Hartvigsson
* Readability changes |
26 |
[CCode (cname = "GjsError", |
27 |
cprefix = "GJS_ERROR_", |
|
28 |
lower_case_cprefix = "gjs_error_")] |
|
29 |
public errordomain Error { |
|
1
by Gustav Hartvigsson
* Inital, untested code |
30 |
FAILED, |
31 |
EXIT, |
|
32 |
} |
|
33 |
|
|
4
by Gustav Hartvigsson
* Readability changes |
34 |
[CCode (cname = "GjsJSError", |
35 |
cprefix = "GJS_JS_ERROR_", |
|
36 |
lower_case_cprefix = "gjs_js_error_")] |
|
37 |
public errordomain JSError { |
|
1
by Gustav Hartvigsson
* Inital, untested code |
38 |
ERROR, |
39 |
EVAL_ERROR, |
|
40 |
INTERNAL_ERROR, |
|
41 |
RANGE_ERROR, |
|
42 |
REFERENCE_ERROR, |
|
43 |
STOP_ITERATION, |
|
44 |
SYNTAX_ERROR, |
|
45 |
TYPE_ERROR, |
|
46 |
URI_ERROR, |
|
47 |
} |
|
48 |
|
|
2
by Gustav Hartvigsson
More code. |
49 |
[CCode (cname = "GjsContext", |
50 |
type_id = "GJS_TYPE_CONTEXT")] |
|
51 |
public class Context : GLib.Object { |
|
1
by Gustav Hartvigsson
* Inital, untested code |
52 |
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
53 |
/* |
54 |
* The properties here are based on what I can read from the C++ source
|
|
55 |
* code.
|
|
56 |
*/
|
|
57 |
|
|
58 |
/** |
|
59 |
* Path where modules to import should reside.
|
|
60 |
*/
|
|
61 |
|
|
62 |
public string[] search_path {construct;} |
|
63 |
|
|
64 |
/** |
|
65 |
* The filename of the launched JS program
|
|
66 |
*/
|
|
67 |
public string program_name {get { |
|
68 |
unowned string ret_val = null; |
|
69 |
this.@get ("program-name", ref ret_val); |
|
70 |
return ret_val; |
|
71 |
} construct;} |
|
72 |
|
|
73 |
/** |
|
74 |
* The full path of the launched file or NULL if GJS was launched from
|
|
75 |
* the C API or interactive console.
|
|
76 |
*/
|
|
77 |
public string program_path {get { |
|
78 |
unowned string ret_val = null; |
|
79 |
this.@get ("program-path", ref ret_val); |
|
80 |
return ret_val; |
|
81 |
} construct;} |
|
82 |
/** |
|
83 |
* Set this property to profile any JS code run by this context. By
|
|
84 |
* default, the profiler is started and stopped when you call
|
|
85 |
* {@link Gjs.Context.eval}.
|
|
86 |
*
|
|
87 |
* The value of this property is superseded by the GJS_ENABLE_PROFILER
|
|
88 |
* environment variable.
|
|
89 |
*
|
|
90 |
* You may only have one context with the profiler enabled at a time.
|
|
91 |
*/
|
|
92 |
[NoAccessorMethod] |
|
93 |
public bool profiler_enabled {construct;} |
|
94 |
|
|
95 |
/** |
|
96 |
* Set this property to install a SIGUSR2 signal handler that starts and
|
|
97 |
* stops the profiler. This property also implies that
|
|
98 |
* {@link Gjs.Context.profiler_enabled} is set.
|
|
99 |
*/
|
|
100 |
[NoAccessorMethod] |
|
101 |
public bool profiler_sigusr2 {construct;} |
|
102 |
|
|
103 |
/** |
|
104 |
* Whether to execute the file as a module
|
|
105 |
*/
|
|
106 |
[NoAccessorMethod] |
|
107 |
public bool exec_as_module {construct;} |
|
108 |
|
|
109 |
|
|
1
by Gustav Hartvigsson
* Inital, untested code |
110 |
[CCode (cname = "gjs_context_new")] |
111 |
public Context (); |
|
112 |
|
|
113 |
[CCode (cname = "gjs_context_new_with_search_path")] |
|
4
by Gustav Hartvigsson
* Readability changes |
114 |
public Context.with_search_path ([CCode (array_length = false)] |
115 |
string[] search_path); |
|
1
by Gustav Hartvigsson
* Inital, untested code |
116 |
|
2
by Gustav Hartvigsson
More code. |
117 |
[CCode (cname = "gjs_context_eval_file")] |
118 |
public bool eval_file (string filename, |
|
1
by Gustav Hartvigsson
* Inital, untested code |
119 |
out int exit_status_p) |
120 |
throws GLib.Error; |
|
121 |
|
|
122 |
[CCode (cname = "gjs_context_eval_module_file")] |
|
2
by Gustav Hartvigsson
More code. |
123 |
public bool eval_module_file (string filename, |
1
by Gustav Hartvigsson
* Inital, untested code |
124 |
out uint8 exit_status_p) |
125 |
throws GLib.Error; |
|
126 |
|
|
127 |
|
|
128 |
[CCode (cname = "gjs_context_eval")] |
|
2
by Gustav Hartvigsson
More code. |
129 |
public bool eval (string script, |
130 |
string filename, |
|
131 |
out int exit_status_p) |
|
1
by Gustav Hartvigsson
* Inital, untested code |
132 |
throws GLib.Error; |
133 |
|
|
134 |
[CCode (cname = "gjs_context_register_module")] |
|
2
by Gustav Hartvigsson
More code. |
135 |
public bool register_module (string identifier, |
136 |
string uri) |
|
1
by Gustav Hartvigsson
* Inital, untested code |
137 |
throws GLib.Error; |
138 |
|
|
139 |
[CCode (cname = "gjs_context_eval_module")] |
|
2
by Gustav Hartvigsson
More code. |
140 |
public bool eval_module (string identifier, |
1
by Gustav Hartvigsson
* Inital, untested code |
141 |
out uint8 exit_code) |
142 |
throws GLib.Error; |
|
143 |
|
|
144 |
[CCode (cname = "gjs_context_define_string_array")] |
|
2
by Gustav Hartvigsson
More code. |
145 |
public bool define_string_array (string array_name, |
146 |
[CCode (array_length_pos = 1.1)] |
|
147 |
string[] array_values) |
|
1
by Gustav Hartvigsson
* Inital, untested code |
148 |
throws GLib.Error; |
149 |
|
|
150 |
[CCode (cname = "gjs_context_set_argv")] |
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
151 |
public void set_argv ([CCode (array_length_pos = 0.1, |
152 |
type = "const char**")] |
|
1
by Gustav Hartvigsson
* Inital, untested code |
153 |
string[] array_values); |
154 |
|
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
155 |
/** |
156 |
* Returns a newly-allocated list containing all known instances of
|
|
157 |
* {@link Gjs.Context}. This is useful for operating on the contexts from a
|
|
158 |
* process-global situation such as a debugger.
|
|
159 |
*
|
|
160 |
* @return Known {@link Gjs.Context} instances
|
|
161 |
*/
|
|
1
by Gustav Hartvigsson
* Inital, untested code |
162 |
[CCode (cname = "gjs_context_get_all")] |
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
163 |
public GLib.List<Context> get_all (); |
1
by Gustav Hartvigsson
* Inital, untested code |
164 |
|
165 |
[CCode (cname = "gjs_context_get_current")] |
|
166 |
public static Context get_current (); |
|
167 |
|
|
168 |
[CCode (cname = "gjs_context_make_current")] |
|
169 |
public void make_current (); |
|
170 |
|
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
171 |
/** |
172 |
* Returns a pointer to the underlying native context. For SpiderMonkey,
|
|
173 |
* this is a JSContext *
|
|
174 |
*/
|
|
1
by Gustav Hartvigsson
* Inital, untested code |
175 |
[CCode (cname = "gjs_context_get_native_context")] |
2
by Gustav Hartvigsson
More code. |
176 |
public GLib.pointer get_native_context (); |
1
by Gustav Hartvigsson
* Inital, untested code |
177 |
|
178 |
[CCode (cname = "gjs_context_print_stack_stderr")] |
|
179 |
public void print_stack_stderr (); |
|
180 |
|
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
181 |
/** |
182 |
* Similar to the Spidermonkey JS_MaybeGC() call which
|
|
183 |
* heuristically looks at JS runtime memory usage and
|
|
184 |
* may initiate a garbage collection.
|
|
185 |
*
|
|
186 |
* This function always unconditionally invokes JS_MaybeGC(), but
|
|
187 |
* additionally looks at memory usage from the system malloc()
|
|
188 |
* when available, and if the delta has grown since the last run
|
|
189 |
* significantly, also initiates a full JavaScript garbage
|
|
190 |
* collection. The idea is that since GJS is a bridge between
|
|
191 |
* JavaScript and system libraries, and JS objects act as proxies
|
|
192 |
* for these system memory objects, GJS consumers need a way to
|
|
193 |
* hint to the runtime that it may be a good idea to try a
|
|
194 |
* collection.
|
|
195 |
*
|
|
196 |
* A good time to call this function is when your application
|
|
197 |
* transitions to an idle state.
|
|
198 |
*/
|
|
1
by Gustav Hartvigsson
* Inital, untested code |
199 |
[CCode (cname = "gjs_context_maybe_gc")] |
200 |
public void maybe_gc (); |
|
201 |
|
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
202 |
/** |
203 |
* Initiate a full GC; may or may not block until complete. This
|
|
204 |
* function just calls Spidermonkey JS_GC().
|
|
205 |
*/
|
|
1
by Gustav Hartvigsson
* Inital, untested code |
206 |
[CCode (cname = "gjs_context_gc")] |
207 |
public void gc (); |
|
208 |
|
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
209 |
/* |
210 |
* Returns the profiler's internal instance of {@link Gjs.Profiler}
|
|
211 |
* for you to customize, or %NULL if profiling is not enabled on this
|
|
212 |
* {@link Gjs.Context}.
|
|
213 |
*
|
|
214 |
* @returns {@link Gjs.Profiler}
|
|
215 |
*/
|
|
1
by Gustav Hartvigsson
* Inital, untested code |
216 |
[CCode (cname = "gjs_context_get_profiler")] |
217 |
public Profiler get_profiler (); |
|
218 |
|
|
219 |
[CCode (cname = "gjs_context_setup_debugger_console")] |
|
220 |
public void setup_debugger_console (); |
|
221 |
} |
|
222 |
|
|
4
by Gustav Hartvigsson
* Readability changes |
223 |
[CCode (cheader_filename = "gjs/context.h", |
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
224 |
cname = "gjs_dumpstack")] |
1
by Gustav Hartvigsson
* Inital, untested code |
225 |
public void dump_stack (); |
226 |
|
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
227 |
/** |
228 |
* Returns the underlying version of the JS engine.
|
|
229 |
*
|
|
230 |
* Returns: a string
|
|
231 |
*/
|
|
4
by Gustav Hartvigsson
* Readability changes |
232 |
[CCode (cheader_filename = "gjs/context.h", |
233 |
cname = "gjs_get_js_version")] |
|
2
by Gustav Hartvigsson
More code. |
234 |
public string get_js_version (); |
1
by Gustav Hartvigsson
* Inital, untested code |
235 |
|
236 |
/* |
|
237 |
* This class has no visible _new function, can only be created from
|
|
238 |
* context.
|
|
239 |
*/
|
|
4
by Gustav Hartvigsson
* Readability changes |
240 |
[CCode (cheader_filename = "gjs/profiler.h", |
241 |
cname = "GjsProfiler", |
|
242 |
type_id = "GJS_TYPE_PROFILER")] |
|
2
by Gustav Hartvigsson
More code. |
243 |
public class Profiler : GLib.Object { |
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
244 |
/** |
245 |
* Set the capture writer to which profiling data is written when the
|
|
246 |
* ''this'' is stopped.
|
|
247 |
*
|
|
248 |
* @param capture A {SysprofCaptureWriter}
|
|
249 |
*/
|
|
1
by Gustav Hartvigsson
* Inital, untested code |
250 |
[CCode (cname = "gjs_profiler_set_capture_writer")] |
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
251 |
public void set_capture_writer (GLib.pointer capture); |
1
by Gustav Hartvigsson
* Inital, untested code |
252 |
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
253 |
/** |
254 |
* Set the file to which profiling data is written when the ''this'' is
|
|
255 |
* stopped. By default, this is `gjs-$PID.syscap` in the current directory.
|
|
256 |
*/
|
|
1
by Gustav Hartvigsson
* Inital, untested code |
257 |
[CCode (cname = "gjs_profiler_set_filename")] |
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
258 |
public void set_filename (string filename); |
259 |
|
|
1
by Gustav Hartvigsson
* Inital, untested code |
260 |
|
261 |
[CCode (cname = "gjs_profiler_set_fd")] |
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
262 |
public void set_fd (int fd); |
1
by Gustav Hartvigsson
* Inital, untested code |
263 |
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
264 |
/** |
265 |
* As expected, this starts the {@link Gjs.Profiler}.
|
|
266 |
*
|
|
267 |
* This will enable the underlying JS profiler and register a POSIX timer to
|
|
268 |
* deliver SIGPROF on the configured sampling frequency.
|
|
269 |
*
|
|
270 |
* To reduce sampling overhead, Gjs.Profiler stashes information
|
|
271 |
* about the profile to be calculated once the profiler has been disabled.
|
|
272 |
* Calling Gjs.Profiler.stop() will result in that delayed work to be
|
|
273 |
* completed.
|
|
274 |
*
|
|
275 |
* You should call Gjs.Profiler.stop() when the profiler is no longer
|
|
276 |
* needed.
|
|
277 |
*/
|
|
1
by Gustav Hartvigsson
* Inital, untested code |
278 |
[CCode (cname = "gjs_profiler_start")] |
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
279 |
public void start (); |
1
by Gustav Hartvigsson
* Inital, untested code |
280 |
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
281 |
/** |
282 |
* Stops a currently running {@link Gjs.Profiler}. If the profiler is not
|
|
283 |
* running, this function will do nothing.
|
|
284 |
*
|
|
285 |
* Some work may be delayed until the end of the capture. Such delayed work
|
|
286 |
* includes flushing the resulting samples and file location information to
|
|
287 |
* disk.
|
|
288 |
*
|
|
289 |
* This may block while writing to disk. Generally, the writes are delivered
|
|
290 |
* to a tmpfs device, and are therefore negligible.
|
|
291 |
*/
|
|
1
by Gustav Hartvigsson
* Inital, untested code |
292 |
[CCode (cname = "gjs_profiler_stop")] |
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
293 |
public void stop (); |
294 |
|
|
295 |
/** |
|
296 |
* Use this to pass a signal info caught by another signal handler to a
|
|
297 |
* {@link Gjs.Profiler}. This might be needed if you have your own complex
|
|
298 |
* signal handling system for which Gjs.Profiler cannot simply add a SIGUSR2
|
|
299 |
* handler.
|
|
300 |
*
|
|
301 |
* This function should only be called from the JS thread.
|
|
302 |
*
|
|
303 |
* @return true if the signal was handled.
|
|
304 |
*/
|
|
305 |
[CCode (cname = "gjs_profiler_chain_signal")] |
|
306 |
public static bool chain_signal (Context ctx, |
|
307 |
Posix.siginfo_t info); |
|
1
by Gustav Hartvigsson
* Inital, untested code |
308 |
} |
309 |
|
|
4
by Gustav Hartvigsson
* Readability changes |
310 |
[CCode (cheader_filename = "gjs/mem.h", |
311 |
cname = "gjs_memory_report")] |
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
312 |
public void memory_report (string where, |
1
by Gustav Hartvigsson
* Inital, untested code |
313 |
bool die_if_fail); |
314 |
|
|
4
by Gustav Hartvigsson
* Readability changes |
315 |
[CCode (cheader_filename = "gjs/coverage.h", |
316 |
cname = "GjsProfiler", |
|
317 |
type_id = "GJS_TYPE_COVERAGE")] |
|
2
by Gustav Hartvigsson
More code. |
318 |
public class Coverage : GLib.Object { |
1
by Gustav Hartvigsson
* Inital, untested code |
319 |
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
320 |
/** |
321 |
* Prefixes of files on which to perform coverage analysis
|
|
322 |
*/
|
|
323 |
public string prefixes {construct;} |
|
324 |
|
|
325 |
/** |
|
326 |
* A context to gather coverage stats for
|
|
327 |
*/
|
|
328 |
public Context context {construct;} |
|
329 |
|
|
330 |
/** |
|
331 |
* Directory handle at which to output coverage statistics
|
|
332 |
*/
|
|
333 |
public GLib.File output_directory {construct;} |
|
334 |
|
|
335 |
/** |
|
336 |
* Creates a new {@link Gjs.Coverage} object that collects coverage
|
|
337 |
* information for any scripts run in context.
|
|
338 |
*
|
|
339 |
* Scripts which were provided as part of {@link prefixes} will be written
|
|
340 |
* out to {@link output_dir}, in the same directory structure relative to
|
|
341 |
* the source dir where the tests were run.
|
|
342 |
*
|
|
343 |
* @param coverage_prefixes A null-terminated strv of prefixes of files on
|
|
344 |
* which to record code coverage
|
|
345 |
*
|
|
346 |
* @param coverage_context A {@link Gjs.Context} object
|
|
347 |
*
|
|
348 |
* @param output_dir A {@link GLib.File} handle to a directory in which to
|
|
349 |
* write coverage information
|
|
350 |
*/
|
|
1
by Gustav Hartvigsson
* Inital, untested code |
351 |
[CCode (cname = "gjs_coverage_new")] |
2
by Gustav Hartvigsson
More code. |
352 |
public Coverage (string coverage_prefixes, |
1
by Gustav Hartvigsson
* Inital, untested code |
353 |
Context coverage_context, |
354 |
GLib.File output_dir); |
|
355 |
|
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
356 |
/** |
357 |
* Scripts which were provided as part of the {@link Gjs.Coverage.prefixes}
|
|
358 |
* construction property will be written out to {output_directory}, in the
|
|
359 |
* same directory structure relative to the source dir where the tests were
|
|
360 |
* run.
|
|
361 |
*
|
|
362 |
* This function takes all available statistics and writes them out to
|
|
363 |
* either the file provided or to files of the pattern (filename).info in
|
|
364 |
* the same directory as the scanned files. It will provide coverage data
|
|
365 |
* for all files ending with ".js" in the coverage directories.
|
|
366 |
*/
|
|
1
by Gustav Hartvigsson
* Inital, untested code |
367 |
[CCode (cname = "gjs_coverage_write_statistics")] |
368 |
public void write_statistics (); |
|
369 |
|
|
5
by Gustav Hartvigsson
* Added comments to the VAPI file. |
370 |
/** |
371 |
* This function must be called before creating any {@link Gjs.Context},
|
|
372 |
* if you intend to use any {@link Gjs.Coverage} APIs.
|
|
373 |
*/
|
|
1
by Gustav Hartvigsson
* Inital, untested code |
374 |
[CCode (cname = "gjs_coverage_enable")] |
2
by Gustav Hartvigsson
More code. |
375 |
public static void enable (); |
1
by Gustav Hartvigsson
* Inital, untested code |
376 |
} |
377 |
}
|