1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 2 * vim: set ts=8 sts=4 et sw=4 tw=99: 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 // This file imports some common JS:: names into the js namespace so we can 8 // make unqualified references to them. 9 10 #ifndef NamespaceImports_h 11 #define NamespaceImports_h 12 13 // These includes are needed these for some typedefs (e.g. HandleValue) and 14 // functions (e.g. NullValue())... 15 #include "js/CallNonGenericMethod.h" 16 #include "js/TraceableVector.h" 17 #include "js/TypeDecls.h" 18 #include "js/Value.h" 19 20 // ... but we do forward declarations of the structs and classes not pulled in 21 // by the headers included above. 22 namespace JS { 23 24 class Latin1Chars; 25 class Latin1CharsZ; 26 class ConstTwoByteChars; 27 class TwoByteChars; 28 class TwoByteCharsZ; 29 class UTF8Chars; 30 class UTF8CharsZ; 31 32 template <typename T> 33 class AutoVectorRooter; 34 typedef AutoVectorRooter<Value> AutoValueVector; 35 typedef AutoVectorRooter<jsid> AutoIdVector; 36 typedef AutoVectorRooter<JSObject*> AutoObjectVector; 37 typedef AutoVectorRooter<JSScript*> AutoVector; 38 39 using ValueVector = js::TraceableVector<JS::Value>; 40 using IdVector = js::TraceableVector<jsid>; 41 using ScriptVector = js::TraceableVector<JSScript*>; 42 43 template <typename T> class AutoVectorRooter; 44 template<typename K, typename V> class AutoHashMapRooter; 45 template<typename T> class AutoHashSetRooter; 46 47 class MOZ_STACK_CLASS SourceBufferHolder; 48 49 class HandleValueArray; 50 51 class ObjectOpResult; 52 53 class Symbol; 54 enum class SymbolCode: uint32_t; 55 56 } // namespace JS 57 58 // Do the importing. 59 namespace js { 60 61 using JS::Value; 62 using JS::BooleanValue; 63 using JS::DoubleValue; 64 using JS::Float32Value; 65 using JS::Int32Value; 66 using JS::MagicValue; 67 using JS::NullValue; 68 using JS::NumberValue; 69 using JS::ObjectOrNullValue; 70 using JS::ObjectValue; 71 using JS::PrivateUint32Value; 72 using JS::PrivateValue; 73 using JS::StringValue; 74 using JS::UndefinedValue; 75 76 using JS::Latin1Char; 77 using JS::Latin1Chars; 78 using JS::Latin1CharsZ; 79 using JS::ConstTwoByteChars; 80 using JS::TwoByteChars; 81 using JS::TwoByteCharsZ; 82 using JS::UTF8Chars; 83 using JS::UTF8CharsZ; 84 85 using JS::AutoVectorRooter; 86 typedef AutoVectorRooter<Value> AutoValueVector; 87 typedef AutoVectorRooter<jsid> AutoIdVector; 88 typedef AutoVectorRooter<JSObject*> AutoObjectVector; 89 90 using JS::ValueVector; 91 using JS::IdVector; 92 using JS::ScriptVector; 93 94 using JS::AutoHashMapRooter; 95 using JS::AutoHashSetRooter; 96 97 using JS::CallArgs; 98 using JS::CallNonGenericMethod; 99 using JS::CallReceiver; 100 using JS::CompileOptions; 101 using JS::IsAcceptableThis; 102 using JS::NativeImpl; 103 using JS::OwningCompileOptions; 104 using JS::ReadOnlyCompileOptions; 105 using JS::SourceBufferHolder; 106 using JS::TransitiveCompileOptions; 107 108 using JS::Rooted; 109 using JS::RootedFunction; 110 using JS::RootedId; 111 using JS::RootedObject; 112 using JS::RootedScript; 113 using JS::RootedString; 114 using JS::RootedSymbol; 115 using JS::RootedValue; 116 117 using JS::PersistentRooted; 118 using JS::PersistentRootedFunction; 119 using JS::PersistentRootedId; 120 using JS::PersistentRootedObject; 121 using JS::PersistentRootedScript; 122 using JS::PersistentRootedString; 123 using JS::PersistentRootedSymbol; 124 using JS::PersistentRootedValue; 125 126 using JS::Handle; 127 using JS::HandleFunction; 128 using JS::HandleId; 129 using JS::HandleObject; 130 using JS::HandleScript; 131 using JS::HandleString; 132 using JS::HandleSymbol; 133 using JS::HandleValue; 134 135 using JS::MutableHandle; 136 using JS::MutableHandleFunction; 137 using JS::MutableHandleId; 138 using JS::MutableHandleObject; 139 using JS::MutableHandleScript; 140 using JS::MutableHandleString; 141 using JS::MutableHandleSymbol; 142 using JS::MutableHandleValue; 143 144 using JS::NullHandleValue; 145 using JS::UndefinedHandleValue; 146 using JS::TrueHandleValue; 147 using JS::FalseHandleValue; 148 149 using JS::HandleValueArray; 150 151 using JS::ObjectOpResult; 152 153 using JS::Zone; 154 155 using JS::Symbol; 156 using JS::SymbolCode; 157 158 } /* namespace js */ 159 160 #endif /* NamespaceImports_h */ 161