Bug 911043 (part 1) - Move the "inject JS:: names into js::" block into its own file, to reduce dependencies on jsapi.h. r=luke.

--HG--
extra : rebase_source : 2250064bdd316ffeb8126da749bdf94ab9da4418
This commit is contained in:
Nicholas Nethercote 2013-09-01 21:51:02 -07:00
parent 076d9518ae
commit 1a9de23d54
25 changed files with 147 additions and 88 deletions

View File

@ -39,9 +39,9 @@ class JavaScriptParent
JS::MutableHandle<JSPropertyDescriptor> desc, unsigned flags);
bool defineProperty(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
JS::MutableHandle<JSPropertyDescriptor> desc);
bool getOwnPropertyNames(JSContext *cx, JS::HandleObject proxy, js::AutoIdVector &props);
bool getOwnPropertyNames(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props);
bool delete_(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp);
bool enumerate(JSContext *cx, JS::HandleObject proxy, js::AutoIdVector &props);
bool enumerate(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props);
// Derived proxy traps. Implementing these is useful for perfomance.
bool has(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp);
@ -50,7 +50,7 @@ class JavaScriptParent
JS::HandleId id, JS::MutableHandleValue vp);
bool set(JSContext *cx, JS::HandleObject proxy, JS::HandleObject receiver,
JS::HandleId id, bool strict, JS::MutableHandleValue vp);
bool keys(JSContext *cx, JS::HandleObject proxy, js::AutoIdVector &props);
bool keys(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props);
// We use "iterate" provided by the base class here.
// SpiderMonkey Extensions.
@ -82,7 +82,8 @@ class JavaScriptParent
private:
bool makeId(JSContext *cx, JSObject *obj, ObjectId *idp);
bool getPropertyNames(JSContext *cx, JS::HandleObject proxy, uint32_t flags, js::AutoIdVector &props);
bool getPropertyNames(JSContext *cx, JS::HandleObject proxy, uint32_t flags,
JS::AutoIdVector &props);
ObjectId idOf(JSObject *obj);
// Catastrophic IPC failure.

116
js/src/NamespaceImports.h Normal file
View File

@ -0,0 +1,116 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// This file imports some common JS:: names into the js namespace so we can
// make unqualified references to them.
#ifndef NamespaceImports_h
#define NamespaceImports_h
// These includes are needed these for some typedefs (e.g. HandleValue) and
// functions (e.g. NullValue())...
#include "js/CallNonGenericMethod.h"
#include "js/TypeDecls.h"
#include "js/Value.h"
// ... but we do forward declarations of the structs and classes not pulled in
// by the headers included above.
namespace JS {
class Latin1CharsZ;
class StableCharPtr;
class TwoByteChars;
class AutoFunctionVector;
class AutoIdVector;
class AutoObjectVector;
class AutoScriptVector;
class AutoValueVector;
class AutoIdArray;
class AutoGCRooter;
class AutoArrayRooter;
template <typename T> class AutoVectorRooter;
template<typename K, typename V> class AutoHashMapRooter;
template<typename T> class AutoHashSetRooter;
}
// Do the importing.
namespace js {
using JS::Value;
using JS::BooleanValue;
using JS::DoubleValue;
using JS::Int32Value;
using JS::IsPoisonedValue;
using JS::MagicValue;
using JS::NullValue;
using JS::NumberValue;
using JS::ObjectOrNullValue;
using JS::ObjectValue;
using JS::PrivateUint32Value;
using JS::PrivateValue;
using JS::StringValue;
using JS::UndefinedValue;
using JS::IsPoisonedPtr;
using JS::Latin1CharsZ;
using JS::StableCharPtr;
using JS::TwoByteChars;
using JS::AutoFunctionVector;
using JS::AutoIdVector;
using JS::AutoObjectVector;
using JS::AutoScriptVector;
using JS::AutoValueVector;
using JS::AutoIdArray;
using JS::AutoGCRooter;
using JS::AutoArrayRooter;
using JS::AutoHashMapRooter;
using JS::AutoHashSetRooter;
using JS::AutoVectorRooter;
using JS::CallArgs;
using JS::CallNonGenericMethod;
using JS::CallReceiver;
using JS::CompileOptions;
using JS::IsAcceptableThis;
using JS::NativeImpl;
using JS::Rooted;
using JS::RootedFunction;
using JS::RootedId;
using JS::RootedObject;
using JS::RootedScript;
using JS::RootedString;
using JS::RootedValue;
using JS::Handle;
using JS::HandleFunction;
using JS::HandleId;
using JS::HandleObject;
using JS::HandleScript;
using JS::HandleString;
using JS::HandleValue;
using JS::MutableHandle;
using JS::MutableHandleFunction;
using JS::MutableHandleId;
using JS::MutableHandleObject;
using JS::MutableHandleScript;
using JS::MutableHandleString;
using JS::MutableHandleValue;
using JS::Zone;
} /* namespace js */
#endif /* NamespaceImports_h */

View File

@ -9,6 +9,7 @@
#include "jsapi.h"
#include "jsbytecode.h"
#include "NamespaceImports.h"
namespace js {

View File

@ -8,6 +8,7 @@
#define builtin_Intl_h
#include "jsapi.h"
#include "NamespaceImports.h"
#include "js/RootingAPI.h"

View File

@ -8,6 +8,7 @@
#define builtin_TestingFunctions_h
#include "jsapi.h"
#include "NamespaceImports.h"
namespace js {

View File

@ -8,6 +8,7 @@
#define ds_IdValuePair_h
#include "jsapi.h"
#include "NamespaceImports.h"
namespace js {

View File

@ -8,6 +8,7 @@
#define frontend_BytecodeCompiler_h
#include "jsapi.h"
#include "NamespaceImports.h"
class JSLinearString;

View File

@ -8,6 +8,7 @@
#define gc_Barrier_h
#include "jsapi.h"
#include "NamespaceImports.h"
#include "gc/Heap.h"
#include "js/HashTable.h"

View File

@ -21,6 +21,7 @@
// actually run.)
#include "jsapi.h"
#include "NamespaceImports.h"
void breakpoint();

View File

@ -8,6 +8,7 @@
#define jit_AsmJSLink_h
#include "jsapi.h"
#include "NamespaceImports.h"
namespace js {

View File

@ -10,6 +10,7 @@
#ifdef DEBUG
#include "jsapi.h"
#include "NamespaceImports.h"
#include "js/RootingAPI.h"

View File

@ -1358,7 +1358,7 @@ JS_EndRequest(JSContext *cx);
extern JS_PUBLIC_API(bool)
JS_IsInRequest(JSRuntime *rt);
namespace JS {
namespace js {
inline bool
IsPoisonedId(jsid iden)
@ -1370,15 +1370,11 @@ IsPoisonedId(jsid iden)
return false;
}
} /* namespace JS */
namespace js {
template <> struct GCMethods<jsid>
{
static jsid initial() { return JSID_VOID; }
static ThingRootKind kind() { return THING_ROOT_ID; }
static bool poisoned(jsid id) { return JS::IsPoisonedId(id); }
static bool poisoned(jsid id) { return IsPoisonedId(id); }
static bool needsPostBarrier(jsid id) { return false; }
#ifdef JSGC_GENERATIONAL
static void postBarrier(jsid *idp) {}
@ -4586,81 +4582,4 @@ extern JS_PUBLIC_DATA(const Handle<jsid>) JSID_EMPTYHANDLE;
} /* namespace JS */
namespace js {
/*
* Import some JS:: names into the js namespace so we can make unqualified
* references to them.
*/
using JS::Value;
using JS::IsPoisonedValue;
using JS::NullValue;
using JS::UndefinedValue;
using JS::Int32Value;
using JS::DoubleValue;
using JS::StringValue;
using JS::BooleanValue;
using JS::ObjectValue;
using JS::MagicValue;
using JS::NumberValue;
using JS::ObjectOrNullValue;
using JS::PrivateValue;
using JS::PrivateUint32Value;
using JS::IsPoisonedPtr;
using JS::IsPoisonedId;
using JS::StableCharPtr;
using JS::TwoByteChars;
using JS::Latin1CharsZ;
using JS::AutoIdVector;
using JS::AutoValueVector;
using JS::AutoObjectVector;
using JS::AutoFunctionVector;
using JS::AutoScriptVector;
using JS::AutoIdArray;
using JS::AutoGCRooter;
using JS::AutoArrayRooter;
using JS::AutoVectorRooter;
using JS::AutoHashMapRooter;
using JS::AutoHashSetRooter;
using JS::CallArgs;
using JS::IsAcceptableThis;
using JS::NativeImpl;
using JS::CallReceiver;
using JS::CompileOptions;
using JS::CallNonGenericMethod;
using JS::Rooted;
using JS::RootedObject;
using JS::RootedFunction;
using JS::RootedScript;
using JS::RootedString;
using JS::RootedId;
using JS::RootedValue;
using JS::Handle;
using JS::HandleObject;
using JS::HandleFunction;
using JS::HandleScript;
using JS::HandleString;
using JS::HandleId;
using JS::HandleValue;
using JS::MutableHandle;
using JS::MutableHandleObject;
using JS::MutableHandleFunction;
using JS::MutableHandleScript;
using JS::MutableHandleString;
using JS::MutableHandleId;
using JS::MutableHandleValue;
using JS::Zone;
} /* namespace js */
#endif /* jsapi_h */

View File

@ -6,11 +6,13 @@
#ifndef jsbool_h
#define jsbool_h
/*
* JS boolean interface.
*/
#include "jsapi.h"
#include "NamespaceImports.h"
extern JSObject *
js_InitBooleanClass(JSContext *cx, js::HandleObject obj);

View File

@ -12,6 +12,7 @@
#define jsexn_h
#include "jsapi.h"
#include "NamespaceImports.h"
/*
* Initialize the exception constructor/prototype hierarchy.

View File

@ -10,6 +10,7 @@
#include "mozilla/MemoryReporting.h"
#include "jsapi.h"
#include "NamespaceImports.h"
namespace js {

View File

@ -10,6 +10,7 @@
#include "mozilla/FloatingPoint.h"
#include "jsapi.h"
#include "NamespaceImports.h"
#include "vm/NumericConversions.h"

View File

@ -8,6 +8,7 @@
#define json_h
#include "jsapi.h"
#include "NamespaceImports.h"
#include "js/RootingAPI.h"

View File

@ -13,6 +13,7 @@
#include "jsapi.h"
#include "jsbytecode.h"
#include "NamespaceImports.h"
#include "frontend/SourceNotes.h"

View File

@ -12,6 +12,7 @@
#include "jsapi.h"
#include "jsutil.h"
#include "NamespaceImports.h"
#include "js/RootingAPI.h"
#include "vm/Unicode.h"

View File

@ -14,6 +14,7 @@
#include "jsfriendapi.h"
#include "jsinfer.h"
#include "NamespaceImports.h"
#include "gc/Barrier.h"
#include "gc/Heap.h"

View File

@ -36,6 +36,7 @@
#include "mozilla/dom/BindingUtils.h"
using namespace mozilla;
using namespace JS;
using namespace js;
using namespace xpc;

View File

@ -41,6 +41,7 @@
#include "nsGlobalWindow.h"
using namespace mozilla;
using namespace JS;
using namespace js;
using namespace xpc;
@ -3714,7 +3715,7 @@ nsXPCComponents::AttachComponentsObject(JSContext* aCx,
MOZ_ASSERT(js::IsObjectInContextCompartment(global, aCx));
RootedId id(aCx, XPCJSRuntime::Get()->GetStringID(XPCJSRuntime::IDX_COMPONENTS));
return JS_DefinePropertyById(aCx, global, id, js::ObjectValue(*components),
return JS_DefinePropertyById(aCx, global, id, JS::ObjectValue(*components),
nullptr, nullptr, JSPROP_PERMANENT | JSPROP_READONLY);
}

View File

@ -24,6 +24,7 @@
#include "mozilla/dom/BindingUtils.h"
using namespace mozilla;
using namespace JS;
using namespace js;
namespace xpc {

View File

@ -15,6 +15,7 @@
#include "jsapi.h"
using namespace JS;
using namespace js;
namespace xpc {

View File

@ -20,6 +20,7 @@
#include "mozilla/Likely.h"
#include "nsContentUtils.h"
using namespace JS;
using namespace js;
using namespace mozilla;