Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / js / src / jspubtd.h
blobc3c5d38bd679ce53e01aa5d6d93db202d8e42770
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 jspubtd_h
8 #define jspubtd_h
11 * JS public API typedefs.
14 #include "jstypes.h"
16 #include "js/ProtoKey.h"
17 #include "js/Result.h"
18 #include "js/TraceKind.h"
19 #include "js/TypeDecls.h"
21 #if defined(JS_GC_ZEAL) || defined(DEBUG)
22 # define JSGC_HASH_TABLE_CHECKS
23 #endif
25 namespace JS {
27 class CallArgs;
29 class JS_PUBLIC_API RealmOptions;
31 } // namespace JS
33 /* Result of typeof operator enumeration. */
34 enum JSType {
35 JSTYPE_UNDEFINED, /* undefined */
36 JSTYPE_OBJECT, /* object */
37 JSTYPE_FUNCTION, /* function */
38 JSTYPE_STRING, /* string */
39 JSTYPE_NUMBER, /* number */
40 JSTYPE_BOOLEAN, /* boolean */
41 JSTYPE_SYMBOL, /* symbol */
42 JSTYPE_BIGINT, /* BigInt */
43 #ifdef ENABLE_RECORD_TUPLE
44 JSTYPE_RECORD, /* record */
45 JSTYPE_TUPLE, /* tuple */
46 #endif
47 JSTYPE_LIMIT
50 /* Dense index into cached prototypes and class atoms for standard objects. */
51 enum JSProtoKey {
52 #define PROTOKEY_AND_INITIALIZER(name, clasp) JSProto_##name,
53 JS_FOR_EACH_PROTOTYPE(PROTOKEY_AND_INITIALIZER)
54 #undef PROTOKEY_AND_INITIALIZER
55 JSProto_LIMIT
58 /* Struct forward declarations. */
59 struct JSClass;
60 class JSErrorReport;
61 struct JSFunctionSpec;
62 struct JSPrincipals;
63 struct JSPropertySpec;
64 struct JSSecurityCallbacks;
65 struct JSStructuredCloneCallbacks;
66 struct JSStructuredCloneReader;
67 struct JSStructuredCloneWriter;
68 class JS_PUBLIC_API JSTracer;
70 class JSLinearString;
72 template <typename T>
73 struct JSConstScalarSpec;
74 using JSConstDoubleSpec = JSConstScalarSpec<double>;
75 using JSConstIntegerSpec = JSConstScalarSpec<int32_t>;
77 namespace js {
79 inline JS::Realm* GetContextRealm(const JSContext* cx);
80 inline JS::Compartment* GetContextCompartment(const JSContext* cx);
81 inline JS::Zone* GetContextZone(const JSContext* cx);
83 // Whether the current thread is permitted access to any part of the specified
84 // runtime or zone.
85 JS_PUBLIC_API bool CurrentThreadCanAccessRuntime(const JSRuntime* rt);
87 #ifdef DEBUG
88 JS_PUBLIC_API bool CurrentThreadIsMainThread();
89 JS_PUBLIC_API bool CurrentThreadIsPerformingGC();
90 #endif
92 } // namespace js
94 namespace JS {
96 class JS_PUBLIC_API PropertyDescriptor;
98 // Decorates the Unlinking phase of CycleCollection so that accidental use
99 // of barriered accessors results in assertions instead of leaks.
100 class MOZ_STACK_CLASS JS_PUBLIC_API AutoEnterCycleCollection {
101 #ifdef DEBUG
102 JSRuntime* runtime_;
104 public:
105 explicit AutoEnterCycleCollection(JSRuntime* rt);
106 ~AutoEnterCycleCollection();
107 #else
108 public:
109 explicit AutoEnterCycleCollection(JSRuntime* rt) {}
110 ~AutoEnterCycleCollection() {}
111 #endif
114 } /* namespace JS */
116 extern "C" {
118 // Defined in NSPR prio.h.
119 using PRFileDesc = struct PRFileDesc;
122 #endif /* jspubtd_h */