Debian Codegraph @

js/public/ScriptPrivate.h

raw
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef js_ScriptPrivate_h
8 #define js_ScriptPrivate_h
9
10 #include "jstypes.h"
11
12 #include "js/TypeDecls.h"
13
14 namespace JS {
15
16 /**
17 * Set a private value associated with a script. Note that this value is shared
18 * by all nested scripts compiled from a single source file.
19 */
20 extern JS_PUBLIC_API void SetScriptPrivate(JSScript* script,
21 const JS::Value& value);
22
23 /**
24 * Get the private value associated with a script. Note that this value is
25 * shared by all nested scripts compiled from a single source file.
26 */
27 extern JS_PUBLIC_API JS::Value GetScriptPrivate(JSScript* script);
28
29 /**
30 * Return the private value associated with currently executing script or
31 * module, or undefined if there is no such script.
32 */
33 extern JS_PUBLIC_API JS::Value GetScriptedCallerPrivate(JSContext* cx);
34
35 /**
36 * Hooks called when references to a script private value are created or
37 * destroyed. This allows use of a reference counted object as the
38 * script private.
39 */
40 using ScriptPrivateReferenceHook = void (*)(const JS::Value&);
41
42 /**
43 * Set the script private finalize hook for the runtime to the given function.
44 */
45 extern JS_PUBLIC_API void SetScriptPrivateReferenceHooks(
46 JSRuntime* rt, ScriptPrivateReferenceHook addRefHook,
47 ScriptPrivateReferenceHook releaseHook);
48
49 } // namespace JS
50
51 #endif // js_ScriptPrivate_h