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/. */
7 #ifndef js_ScriptPrivate_h
8 #define js_ScriptPrivate_h
12 #include "js/TypeDecls.h"
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.
20 extern JS_PUBLIC_API
void SetScriptPrivate(JSScript
* script
,
21 const JS::Value
& value
);
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.
27 extern JS_PUBLIC_API
JS::Value
GetScriptPrivate(JSScript
* script
);
30 * Return the private value associated with currently executing script or
31 * module, or undefined if there is no such script.
33 extern JS_PUBLIC_API
JS::Value
GetScriptedCallerPrivate(JSContext
* cx
);
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
40 using ScriptPrivateReferenceHook
= void (*)(const JS::Value
&);
43 * Set the script private finalize hook for the runtime to the given function.
45 extern JS_PUBLIC_API
void SetScriptPrivateReferenceHooks(
46 JSRuntime
* rt
, ScriptPrivateReferenceHook addRefHook
,
47 ScriptPrivateReferenceHook releaseHook
);
51 #endif // js_ScriptPrivate_h