Source code

Revision control

Other Tools

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 jspubtd_h
8
#define jspubtd_h
9
10
/*
11
* JS public API typedefs.
12
*/
13
14
#include "jstypes.h"
15
16
#include "js/ProtoKey.h"
17
#include "js/Result.h"
18
#include "js/TraceKind.h"
19
#include "js/TypeDecls.h"
20
21
#if defined(JS_GC_ZEAL) || defined(DEBUG)
22
# define JSGC_HASH_TABLE_CHECKS
23
#endif
24
25
namespace JS {
26
27
class CallArgs;
28
29
class JS_PUBLIC_API RealmOptions;
30
31
} // namespace JS
32
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_NULL, /* null */
42
JSTYPE_SYMBOL, /* symbol */
43
JSTYPE_BIGINT, /* BigInt */
44
JSTYPE_LIMIT
45
};
46
47
/* Dense index into cached prototypes and class atoms for standard objects. */
48
enum JSProtoKey {
49
#define PROTOKEY_AND_INITIALIZER(name, init, clasp) JSProto_##name,
50
JS_FOR_EACH_PROTOTYPE(PROTOKEY_AND_INITIALIZER)
51
#undef PROTOKEY_AND_INITIALIZER
52
JSProto_LIMIT
53
};
54
55
/* Struct forward declarations. */
56
struct JS_PUBLIC_API JSClass;
57
class JSErrorReport;
58
struct JSExceptionState;
59
struct JSFunctionSpec;
60
struct JSPrincipals;
61
struct JSPropertySpec;
62
struct JSSecurityCallbacks;
63
struct JSStructuredCloneCallbacks;
64
struct JSStructuredCloneReader;
65
struct JSStructuredCloneWriter;
66
class JS_PUBLIC_API JSTracer;
67
68
class JSLinearString;
69
70
template <typename T>
71
struct JSConstScalarSpec;
72
typedef JSConstScalarSpec<double> JSConstDoubleSpec;
73
typedef JSConstScalarSpec<int32_t> JSConstIntegerSpec;
74
75
namespace js {
76
77
inline JS::Realm* GetContextRealm(const JSContext* cx);
78
inline JS::Compartment* GetContextCompartment(const JSContext* cx);
79
inline JS::Zone* GetContextZone(const JSContext* cx);
80
81
// Whether the current thread is permitted access to any part of the specified
82
// runtime or zone.
83
JS_FRIEND_API bool CurrentThreadCanAccessRuntime(const JSRuntime* rt);
84
85
#ifdef DEBUG
86
JS_FRIEND_API bool CurrentThreadIsPerformingGC();
87
#endif
88
89
} // namespace js
90
91
namespace JS {
92
93
struct JS_PUBLIC_API PropertyDescriptor;
94
95
// Decorates the Unlinking phase of CycleCollection so that accidental use
96
// of barriered accessors results in assertions instead of leaks.
97
class MOZ_STACK_CLASS JS_PUBLIC_API AutoEnterCycleCollection {
98
#ifdef DEBUG
99
JSRuntime* runtime_;
100
101
public:
102
explicit AutoEnterCycleCollection(JSRuntime* rt);
103
~AutoEnterCycleCollection();
104
#else
105
public:
106
explicit AutoEnterCycleCollection(JSRuntime* rt) {}
107
~AutoEnterCycleCollection() {}
108
#endif
109
};
110
111
} /* namespace JS */
112
113
extern "C" {
114
115
// Defined in NSPR prio.h.
116
typedef struct PRFileDesc PRFileDesc;
117
}
118
119
#endif /* jspubtd_h */