Bug 898451 - Add const to several more read-only static variables. r=evilpies

This commit is contained in:
Dan Gohman 2013-08-01 13:26:04 -07:00
parent 3d0efdf741
commit d0ed2f474a
11 changed files with 23 additions and 30 deletions

View File

@ -993,7 +993,7 @@ js::testingFunc_bailout(JSContext *cx, unsigned argc, jsval *vp)
return true;
}
static JSFunctionSpecWithHelp TestingFunctions[] = {
static const JSFunctionSpecWithHelp TestingFunctions[] = {
JS_FN_HELP("gc", ::GC, 0, 0,
"gc([obj] | 'compartment')",
" Run the garbage collector. When obj is given, GC only its compartment.\n"

View File

@ -95,7 +95,7 @@ STATIC CHAR *Line;
STATIC CONST char *Prompt;
STATIC CHAR *Yanked;
STATIC char *Screen;
STATIC char NEWLINE[]= CRLF;
STATIC CONST char NEWLINE[]= CRLF;
STATIC HISTORY H;
STATIC int Repeat;
STATIC int End;
@ -105,8 +105,8 @@ STATIC int Point;
STATIC int PushBack;
STATIC int Pushed;
STATIC int Signal;
FORWARD KEYMAP Map[32];
FORWARD KEYMAP MetaMap[16];
FORWARD CONST KEYMAP Map[32];
FORWARD CONST KEYMAP MetaMap[16];
STATIC SIZE_T Length;
STATIC SIZE_T ScreenCount;
STATIC SIZE_T ScreenSize;
@ -808,7 +808,7 @@ STATIC STATUS
meta()
{
unsigned int c;
KEYMAP *kp;
CONST KEYMAP *kp;
if ((int)(c = TTYget()) == EOF)
return CSeof;
@ -847,7 +847,7 @@ emacs(c)
unsigned int c;
{
STATUS s;
KEYMAP *kp;
const KEYMAP *kp;
if (rl_meta_chars && ISMETA(c)) {
Pushed = 1;
@ -998,7 +998,7 @@ readline(prompt)
TTYputs((CONST CHAR *)Prompt);
if ((line = editinput()) != NULL) {
line = (CHAR *)strdup((char *)line);
TTYputs((CHAR *)NEWLINE);
TTYputs((CONST CHAR *)NEWLINE);
TTYflush();
}
rl_ttyset(1);
@ -1288,7 +1288,7 @@ last_argument()
return s;
}
STATIC KEYMAP Map[32] = {
STATIC CONST KEYMAP Map[32] = {
{ CTL('@'), ring_bell },
{ CTL('A'), beg_line },
{ CTL('B'), bk_char },
@ -1321,7 +1321,7 @@ STATIC KEYMAP Map[32] = {
{ 0, NULL }
};
STATIC KEYMAP MetaMap[16]= {
STATIC CONST KEYMAP MetaMap[16]= {
{ CTL('H'), bk_kill_word },
{ DEL, bk_kill_word },
{ ' ', mk_set },

View File

@ -53,14 +53,7 @@ typedef unsigned char CHAR;
#define STATIC /* NULL */
#endif /* !defined(HIDE) */
#if !defined(CONST)
#if defined(__STDC__)
#define CONST const
#else
#define CONST
#endif /* defined(__STDC__) */
#endif /* !defined(CONST) */
#define MEM_INC 64
#define SCREEN_INC 256

View File

@ -24,7 +24,7 @@ class PropertyId;
// This is equal to JSFunction::class_. Use it in places where you don't want
// to #include jsfun.h.
extern JS_FRIEND_DATA(js::Class*) FunctionClassPtr;
extern JS_FRIEND_DATA(js::Class* const) FunctionClassPtr;
static JS_ALWAYS_INLINE jsid
SPECIALID_TO_JSID(const SpecialId &sid);

View File

@ -380,13 +380,13 @@ struct Atom {
// These are equal to |&{Function,Object,OuterWindow}ProxyObject::class_|. Use
// them in places where you don't want to #include vm/ProxyObject.h.
extern JS_FRIEND_DATA(js::Class*) FunctionProxyClassPtr;
extern JS_FRIEND_DATA(js::Class*) ObjectProxyClassPtr;
extern JS_FRIEND_DATA(js::Class*) OuterWindowProxyClassPtr;
extern JS_FRIEND_DATA(js::Class* const) FunctionProxyClassPtr;
extern JS_FRIEND_DATA(js::Class* const) ObjectProxyClassPtr;
extern JS_FRIEND_DATA(js::Class* const) OuterWindowProxyClassPtr;
// This is equal to |&JSObject::class_|. Use it in places where you don't want
// to #include jsobj.h.
extern JS_FRIEND_DATA(js::Class*) ObjectClassPtr;
extern JS_FRIEND_DATA(js::Class* const) ObjectClassPtr;
inline js::Class *
GetObjectClass(JSObject *obj)

View File

@ -507,7 +507,7 @@ Class JSFunction::class_ = {
fun_trace
};
JS_FRIEND_DATA(Class*) js::FunctionClassPtr = &JSFunction::class_;
JS_FRIEND_DATA(Class* const) js::FunctionClassPtr = &JSFunction::class_;
/* Find the body of a function (not including braces). */
static bool

View File

@ -80,7 +80,7 @@ Class JSObject::class_ = {
JS_ConvertStub
};
JS_FRIEND_DATA(Class*) js::ObjectClassPtr = &JSObject::class_;
JS_FRIEND_DATA(Class* const) js::ObjectClassPtr = &JSObject::class_;
JS_FRIEND_API(JSObject *)
JS_ObjectToInnerObject(JSContext *cx, JSObject *objArg)

View File

@ -3140,7 +3140,7 @@ Class js::ObjectProxyObject::class_ = {
}
};
JS_FRIEND_DATA(Class*) js::ObjectProxyClassPtr = &ObjectProxyObject::class_;
JS_FRIEND_DATA(Class* const) js::ObjectProxyClassPtr = &ObjectProxyObject::class_;
Class js::OuterWindowProxyObject::class_ = {
"Proxy",
@ -3199,7 +3199,7 @@ Class js::OuterWindowProxyObject::class_ = {
}
};
JS_FRIEND_DATA(Class*) js::OuterWindowProxyClassPtr = &OuterWindowProxyObject::class_;
JS_FRIEND_DATA(Class* const) js::OuterWindowProxyClassPtr = &OuterWindowProxyObject::class_;
static JSBool
proxy_Call(JSContext *cx, unsigned argc, Value *vp)
@ -3270,7 +3270,7 @@ Class js::FunctionProxyObject::class_ = {
}
};
JS_FRIEND_DATA(Class*) js::FunctionProxyClassPtr = &FunctionProxyObject::class_;
JS_FRIEND_DATA(Class* const) js::FunctionProxyClassPtr = &FunctionProxyObject::class_;
/* static */ ProxyObject *
ProxyObject::New(JSContext *cx, BaseProxyHandler *handler, HandleValue priv, TaggedProto proto_,

View File

@ -4925,7 +4925,7 @@ NewGlobalObject(JSContext *cx, JSObject *sameZoneAs)
}
/* Initialize FakeDOMObject. */
static js::DOMCallbacks DOMcallbacks = {
static const js::DOMCallbacks DOMcallbacks = {
InstanceClassHasProtoAtDepth
};
SetDOMCallbacks(cx->runtime(), &DOMcallbacks);

View File

@ -158,10 +158,10 @@ PropDesc::wrapInto(JSContext *cx, HandleObject obj, const jsid &id, jsid *wrappe
return !obj->is<ProxyObject>() || desc->makeObject(cx);
}
static ObjectElements emptyElementsHeader(0, 0);
static const ObjectElements emptyElementsHeader(0, 0);
/* Objects with no elements share one empty set of elements. */
HeapSlot *js::emptyObjectElements =
HeapSlot *const js::emptyObjectElements =
reinterpret_cast<HeapSlot *>(uintptr_t(&emptyElementsHeader) + sizeof(ObjectElements));
/* static */ bool

View File

@ -1126,7 +1126,7 @@ class ObjectElements
};
/* Shared singleton for objects with no elements. */
extern HeapSlot *emptyObjectElements;
extern HeapSlot *const emptyObjectElements;
struct Class;
struct GCMarker;