Bug 883574 - Add const qualifiers to variables and pointers in the JS tree. r=evilpies

This commit is contained in:
Dan Gohman 2013-06-17 18:31:47 -07:00
Родитель 053882c4b7
Коммит edcdfc8b7d
55 изменённых файлов: 204 добавлений и 207 удалений

Просмотреть файл

@ -172,7 +172,7 @@ strncasecomp (const char* one, const char * two, int n)
}
}
static char file_url_prefix[] = "file:";
static const char file_url_prefix[] = "file:";
#define FILE_URL_PREFIX_LEN (sizeof file_url_prefix - 1)
char*

Просмотреть файл

@ -61,7 +61,7 @@ js::rdtsc(void)
}
#endif
const char* TraceLogging::type_name[] = {
const char* const TraceLogging::type_name[] = {
"start,ion_compile",
"stop,ion_compile",
"start,ion_cannon",

Просмотреть файл

@ -61,7 +61,7 @@ class TraceLogging
int fileno;
FILE *out;
const static char *type_name[];
static const char * const type_name[];
static TraceLogging* _defaultLogger;
public:
TraceLogging();

Просмотреть файл

@ -1203,7 +1203,7 @@ namespace JSC {
{
ASSERT(reg <= 16);
ASSERT(reg >= 0);
static char const * names[] = {
static char const * const names[] = {
"r0", "r1", "r2", "r3",
"r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11",
@ -1216,7 +1216,7 @@ namespace JSC {
{
ASSERT(reg <= 31);
ASSERT(reg >= 0);
static char const * names[] = {
static char const * const names[] = {
"d0", "d1", "d2", "d3",
"d4", "d5", "d6", "d7",
"d8", "d9", "d10", "d11",
@ -1232,7 +1232,7 @@ namespace JSC {
{
ASSERT(reg <= 31);
ASSERT(reg >= 0);
static char const * names[] = {
static char const * const names[] = {
"s0", "s1", "s2", "s3",
"s4", "s5", "s6", "s7",
"s8", "s9", "s10", "s11",
@ -1251,7 +1251,7 @@ namespace JSC {
ASSERT((cc & 0x0fffffff) == 0);
uint32_t ccIndex = cc >> 28;
static char const * names[] = {
static char const * const names[] = {
"eq", "ne",
"cs", "cc",
"mi", "pl",

Просмотреть файл

@ -157,12 +157,12 @@ public:
// Describes an memory operand given by a pointer. For regular load & store
// operations an unwrapped void* will be used, rather than using this.
struct AbsoluteAddress {
explicit AbsoluteAddress(void* ptr)
explicit AbsoluteAddress(const void* ptr)
: m_ptr(ptr)
{
}
void* m_ptr;
const void* m_ptr;
};
// TrustedImmPtr:
@ -408,12 +408,12 @@ public:
{
}
void link(AbstractMacroAssembler<AssemblerType>* masm)
void link(AbstractMacroAssembler<AssemblerType>* masm) const
{
masm->m_assembler.linkJump(m_jmp, masm->m_assembler.label());
}
void linkTo(Label label, AbstractMacroAssembler<AssemblerType>* masm)
void linkTo(Label label, AbstractMacroAssembler<AssemblerType>* masm) const
{
masm->m_assembler.linkJump(m_jmp, label.m_label);
}

Просмотреть файл

@ -1029,7 +1029,7 @@ public:
m_assembler.dtr_u(false, ARMRegisters::S1, ARMRegisters::S0, 0);
}
void load32(void* address, RegisterID dest)
void load32(const void* address, RegisterID dest)
{
m_assembler.ldr_un_imm(ARMRegisters::S0, reinterpret_cast<ARMWord>(address));
m_assembler.dtr_u(true, dest, ARMRegisters::S0, 0);

Просмотреть файл

@ -433,7 +433,7 @@ public:
load32(setupArmAddress(address), dest);
}
void load32(void* address, RegisterID dest)
void load32(const void* address, RegisterID dest)
{
move(ImmPtr(address), addressTempRegister);
m_assembler.ldr(dest, addressTempRegister, ARMThumbImmediate::makeUInt16(0));

Просмотреть файл

@ -156,7 +156,7 @@ public:
void* dataLocation() const { ASSERT_VALID_CODE_POINTER(m_value); return m_value; }
#endif
bool operator!()
bool operator!() const
{
return !m_value;
}

Просмотреть файл

@ -861,7 +861,7 @@ public:
}
}
void load32(void* address, RegisterID dest)
void load32(const void* address, RegisterID dest)
{
/*
li addrTemp, address

Просмотреть файл

@ -1024,7 +1024,7 @@ namespace JSC {
store32(SparcRegisters::g2, address.m_ptr);
}
void load32(void* address, RegisterID dest)
void load32(const void* address, RegisterID dest)
{
m_assembler.move_nocheck((int)address, SparcRegisters::g3);
m_assembler.lduw_r(SparcRegisters::g3, SparcRegisters::g0, dest);

Просмотреть файл

@ -86,7 +86,7 @@ public:
sub32(imm, Address(scratchRegister));
}
void load32(void* address, RegisterID dest)
void load32(const void* address, RegisterID dest)
{
if (dest == X86Registers::eax)
m_assembler.movl_mEAX(address);
@ -105,7 +105,7 @@ public:
void convertInt32ToDouble(AbsoluteAddress src, FPRegisterID dest)
{
move(Imm32(*static_cast<int32_t*>(src.m_ptr)), scratchRegister);
move(Imm32(*static_cast<const int32_t*>(src.m_ptr)), scratchRegister);
m_assembler.cvtsi2sd_rr(scratchRegister, dest);
}
@ -297,7 +297,7 @@ public:
m_assembler.movq_mr(address.offset, address.base, address.index, address.scale, dest);
}
void loadPtr(void* address, RegisterID dest)
void loadPtr(const void* address, RegisterID dest)
{
if (dest == X86Registers::eax)
m_assembler.movq_mEAX(address);

Просмотреть файл

@ -1140,7 +1140,7 @@ namespace JSC {
{
ASSERT(reg <= 31);
ASSERT(reg >= 0);
static char const * names[] = {
static char const * const names[] = {
"%g0", "%g1", "%g2", "%g3",
"%g4", "%g5", "%g6", "%g7",
"%o0", "%o1", "%o2", "%o3",
@ -1157,7 +1157,7 @@ namespace JSC {
{
ASSERT(reg <= 31);
ASSERT(reg >= 0);
static char const * names[] = {
static char const * const names[] = {
"%f0", "%f1", "%f2", "%f3",
"%f4", "%f5", "%f6", "%f7",
"%f8", "%f9", "%f10", "%f11",
@ -1176,7 +1176,7 @@ namespace JSC {
ASSERT(cc >= 0);
uint32_t ccIndex = cc;
static char const * inames[] = {
static char const * const inames[] = {
" ", "e ",
"le ", "l ",
"leu", "cs ",
@ -1195,7 +1195,7 @@ namespace JSC {
ASSERT(cc >= 0);
uint32_t ccIndex = cc;
static char const * fnames[] = {
static char const * const fnames[] = {
" ", "ne ",
" ", "ul ",
"l ", "ug ",

Просмотреть файл

@ -94,7 +94,7 @@ namespace X86Registers {
static const char* nameFPReg(XMMRegisterID fpreg)
{
static const char* xmmnames[16]
static const char* const xmmnames[16]
= { "%xmm0", "%xmm1", "%xmm2", "%xmm3",
"%xmm4", "%xmm5", "%xmm6", "%xmm7",
"%xmm8", "%xmm9", "%xmm10", "%xmm11",
@ -105,20 +105,20 @@ namespace X86Registers {
static const char* nameIReg(int szB, RegisterID reg)
{
static const char* r64names[16]
static const char* const r64names[16]
= { "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
"%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" };
static const char* r32names[16]
static const char* const r32names[16]
= { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
"%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d" };
static const char* r16names[16]
static const char* const r16names[16]
= { "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
"%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w" };
static const char* r8names[16]
static const char* const r8names[16]
= { "%al", "%cl", "%dl", "%bl", "%ah/spl", "%ch/bpl", "%dh/sil", "%bh/dil",
"%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b" };
int off = (RegisterID)reg - (RegisterID)eax;
const char** tab = r64names;
const char* const* tab = r64names;
switch (szB) {
case 1: tab = r8names; break;
case 2: tab = r16names; break;
@ -169,7 +169,7 @@ public:
static const char* nameCC(Condition cc)
{
static const char* names[16]
static const char* const names[16]
= { "o ", "no", "b ", "ae", "e ", "ne", "be", "a ",
"s ", "ns", "p ", "np", "l ", "ge", "le", "g " };
int ix = (int)cc;
@ -460,7 +460,7 @@ public:
// Arithmetic operations:
#if !WTF_CPU_X86_64
void adcl_im(int imm, void* addr)
void adcl_im(int imm, const void* addr)
{
FIXME_INSN_PRINTING;
if (CAN_SIGN_EXTEND_8_32(imm)) {
@ -558,7 +558,7 @@ public:
}
}
#else
void addl_im(int imm, void* addr)
void addl_im(int imm, const void* addr)
{
FIXME_INSN_PRINTING;
if (CAN_SIGN_EXTEND_8_32(imm)) {
@ -649,7 +649,7 @@ public:
}
}
#else
void andl_im(int imm, void* addr)
void andl_im(int imm, const void* addr)
{
FIXME_INSN_PRINTING;
if (CAN_SIGN_EXTEND_8_32(imm)) {
@ -777,7 +777,7 @@ public:
m_formatter.oneByteOp64(OP_GROUP3_Ev, GROUP3_OP_NOT, dst);
}
#else
void orl_im(int imm, void* addr)
void orl_im(int imm, const void* addr)
{
FIXME_INSN_PRINTING;
if (CAN_SIGN_EXTEND_8_32(imm)) {
@ -862,7 +862,7 @@ public:
}
}
#else
void subl_im(int imm, void* addr)
void subl_im(int imm, const void* addr)
{
FIXME_INSN_PRINTING;
if (CAN_SIGN_EXTEND_8_32(imm)) {
@ -1226,13 +1226,13 @@ public:
}
}
#else
void cmpl_rm(RegisterID reg, void* addr)
void cmpl_rm(RegisterID reg, const void* addr)
{
FIXME_INSN_PRINTING;
m_formatter.oneByteOp(OP_CMP_EvGv, reg, addr);
}
void cmpl_im(int imm, void* addr)
void cmpl_im(int imm, const void* addr)
{
spew("cmpl $0x%x, 0x%p", imm, addr);
if (CAN_SIGN_EXTEND_8_32(imm)) {
@ -1483,7 +1483,7 @@ public:
m_formatter.oneByteOp(OP_MOV_EvGv, src, base, index, scale, offset);
}
void movl_mEAX(void* addr)
void movl_mEAX(const void* addr)
{
FIXME_INSN_PRINTING;
m_formatter.oneByteOp(OP_MOV_EAXOv);
@ -1508,7 +1508,7 @@ public:
}
#if WTF_CPU_X86
void movl_mr(void* base, RegisterID index, int scale, RegisterID dst)
void movl_mr(const void* base, RegisterID index, int scale, RegisterID dst)
{
spew("movl %d(%s,%d), %s",
int(base), nameIReg(index), scale, nameIReg(dst));
@ -1581,7 +1581,7 @@ public:
m_formatter.immediate32(imm);
}
void movl_EAXm(void* addr)
void movl_EAXm(const void* addr)
{
FIXME_INSN_PRINTING;
m_formatter.oneByteOp(OP_MOV_OvEAX);
@ -1620,14 +1620,14 @@ public:
m_formatter.oneByteOp64(OP_MOV_EvGv, src, base, index, scale, offset);
}
void movq_mEAX(void* addr)
void movq_mEAX(const void* addr)
{
FIXME_INSN_PRINTING;
m_formatter.oneByteOp64(OP_MOV_EAXOv);
m_formatter.immediate64(reinterpret_cast<int64_t>(addr));
}
void movq_EAXm(void* addr)
void movq_EAXm(const void* addr)
{
FIXME_INSN_PRINTING;
m_formatter.oneByteOp64(OP_MOV_OvEAX);
@ -1721,7 +1721,7 @@ public:
return JmpSrc(m_formatter.size());
}
#else
void movl_rm(RegisterID src, void* addr)
void movl_rm(RegisterID src, const void* addr)
{
spew("movl %s, 0(%p)",
nameIReg(4, src), addr);
@ -1731,7 +1731,7 @@ public:
m_formatter.oneByteOp(OP_MOV_EvGv, src, addr);
}
void movl_mr(void* addr, RegisterID dst)
void movl_mr(const void* addr, RegisterID dst)
{
spew("movl 0(%p), %s",
addr, nameIReg(4, dst));
@ -1741,7 +1741,7 @@ public:
m_formatter.oneByteOp(OP_MOV_GvEv, dst, addr);
}
void movl_i32m(int imm, void* addr)
void movl_i32m(int imm, const void* addr)
{
FIXME_INSN_PRINTING;
m_formatter.oneByteOp(OP_GROUP11_EvIz, GROUP11_MOV, addr);
@ -2170,7 +2170,7 @@ public:
}
#if !WTF_CPU_X86_64
void cvtsi2sd_mr(void* address, XMMRegisterID dst)
void cvtsi2sd_mr(const void* address, XMMRegisterID dst)
{
spew("cvtsi2sd %p, %s",
address, nameFPReg(dst));
@ -2771,7 +2771,7 @@ public:
setInt32(where, value);
}
static void repatchPointer(void* where, void* value)
static void repatchPointer(void* where, const void* value)
{
staticSpew("##repatchPtr ((where=%p)) ((value=%p))",
where, value);
@ -2977,7 +2977,7 @@ private:
}
#if !WTF_CPU_X86_64
void oneByteOp(OneByteOpcodeID opcode, int reg, void* address)
void oneByteOp(OneByteOpcodeID opcode, int reg, const void* address)
{
m_buffer.ensureSpace(maxInstructionSize);
m_buffer.putByteUnchecked(opcode);

Просмотреть файл

@ -64,7 +64,7 @@ namespace js {
namespace selfhosted {
static const %(sources_type)s data[] = { %(sources_data)s };
static const %(sources_type)s *%(sources_name)s = reinterpret_cast<const %(sources_type)s *>(data);
static const %(sources_type)s * const %(sources_name)s = reinterpret_cast<const %(sources_type)s *>(data);
uint32_t GetCompressedSize() {
return %(compressed_total_length)i;

Просмотреть файл

@ -286,7 +286,7 @@ const char js_with_statement_str[] = "with statement";
const char js_finally_block_str[] = "finally block";
const char js_script_str[] = "script";
static const char *statementName[] = {
static const char * const statementName[] = {
"label statement", /* LABEL */
"if statement", /* IF */
"else statement", /* ELSE */
@ -6426,7 +6426,7 @@ CGConstList::finish(ConstArray *array)
* We should try to get rid of offsetBias (always 0 or 1, where 1 is
* JSOP_{NOP,POP}_LENGTH), which is used only by SRC_FOR.
*/
JS_FRIEND_DATA(JSSrcNoteSpec) js_SrcNoteSpec[] = {
JS_FRIEND_DATA(const JSSrcNoteSpec) js_SrcNoteSpec[] = {
/* 0 */ {"null", 0},
/* 1 */ {"if", 0},

Просмотреть файл

@ -374,7 +374,7 @@ NameNode::create(ParseNodeKind kind, JSAtom *atom, FullParseHandler *handler,
const char *
Definition::kindString(Kind kind)
{
static const char *table[] = {
static const char * const table[] = {
"", js_var_str, js_const_str, js_let_str, js_function_str, "argument", "unknown"
};
@ -575,7 +575,7 @@ Parser<FullParseHandler>::cloneLeftHandSide(ParseNode *opn)
#ifdef DEBUG
static const char *parseNodeNames[] = {
static const char * const parseNodeNames[] = {
#define STRINGIFY(name) #name,
FOR_EACH_PARSE_NODE_KIND(STRINGIFY)
#undef STRINGIFY

Просмотреть файл

@ -150,7 +150,7 @@ struct JSSrcNoteSpec {
int8_t arity; /* number of offset operands */
};
extern JS_FRIEND_DATA(JSSrcNoteSpec) js_SrcNoteSpec[];
extern JS_FRIEND_DATA(const JSSrcNoteSpec) js_SrcNoteSpec[];
extern JS_FRIEND_API(unsigned) js_SrcNoteLength(jssrcnote *sn);
/*

Просмотреть файл

@ -278,7 +278,7 @@ struct PhaseInfo
static const Phase PHASE_NO_PARENT = PHASE_LIMIT;
static PhaseInfo phases[] = {
static const PhaseInfo phases[] = {
{ PHASE_GC_BEGIN, "Begin Callback", PHASE_NO_PARENT },
{ PHASE_WAIT_BACKGROUND_THREAD, "Wait Background Thread", PHASE_NO_PARENT },
{ PHASE_MARK_DISCARD_CODE, "Mark Discard Code", PHASE_NO_PARENT },

Просмотреть файл

@ -84,7 +84,7 @@ CodeOffsetJump::fixup(MacroAssembler *masm)
const char *
IonCache::CacheName(IonCache::Kind kind)
{
static const char *names[] =
static const char * const names[] =
{
#define NAME(x) #x,
IONCACHE_KIND_LIST(NAME)

Просмотреть файл

@ -31,7 +31,7 @@ static bool LoggingChecked = false;
static uint32_t LoggingBits = 0;
static uint32_t filteredOutCompilations = 0;
static const char *ChannelNames[] =
static const char * const ChannelNames[] =
{
#define IONSPEW_CHANNEL(name) #name,
IONSPEW_CHANNEL_LIST(IONSPEW_CHANNEL)

Просмотреть файл

@ -170,7 +170,7 @@ LPhi::New(MIRGenerator *gen, MPhi *ins)
void
LInstruction::printName(FILE *fp, Opcode op)
{
static const char *names[] =
static const char * const names[] =
{
#define LIROP(x) #x,
LIR_OPCODE_LIST(LIROP)
@ -188,7 +188,7 @@ LInstruction::printName(FILE *fp)
printName(fp, op());
}
static const char *TypeChars[] =
static const char * const TypeChars[] =
{
"i", // INTEGER
"o", // OBJECT

Просмотреть файл

@ -378,7 +378,7 @@ class VirtualRegister
return false;
return intervals_.append(initial);
}
uint32_t id() {
uint32_t id() const {
return id_;
}
LBlock *block() {
@ -634,7 +634,7 @@ class LiveRangeAllocator : public RegisterAllocator
}
// Finds the first safepoint that is within range of an interval.
size_t findFirstSafepoint(LiveInterval *interval, size_t startFrom)
size_t findFirstSafepoint(const LiveInterval *interval, size_t startFrom) const
{
size_t i = startFrom;
for (; i < graph.numSafepoints(); i++) {

Просмотреть файл

@ -28,7 +28,7 @@ using mozilla::BitwiseCast;
void
MDefinition::PrintOpcodeName(FILE *fp, MDefinition::Opcode op)
{
static const char *names[] =
static const char * const names[] =
{
#define NAME(x) #x,
MIR_OPCODE_LIST(NAME)

Просмотреть файл

@ -325,16 +325,16 @@ class RegisterAllocator
protected:
bool init();
CodePosition outputOf(uint32_t pos) {
CodePosition outputOf(uint32_t pos) const {
return CodePosition(pos, CodePosition::OUTPUT);
}
CodePosition outputOf(LInstruction *ins) {
CodePosition outputOf(const LInstruction *ins) const {
return CodePosition(ins->id(), CodePosition::OUTPUT);
}
CodePosition inputOf(uint32_t pos) {
CodePosition inputOf(uint32_t pos) const {
return CodePosition(pos, CodePosition::INPUT);
}
CodePosition inputOf(LInstruction *ins) {
CodePosition inputOf(const LInstruction *ins) const {
return CodePosition(ins->id(), CodePosition::INPUT);
}
@ -348,11 +348,11 @@ class RegisterAllocator
return getMoveGroupAfter(pos.ins());
}
size_t findFirstNonCallSafepoint(CodePosition from)
size_t findFirstNonCallSafepoint(CodePosition from) const
{
size_t i = 0;
for (; i < graph.numNonCallSafepoints(); i++) {
LInstruction *ins = graph.getNonCallSafepoint(i);
const LInstruction *ins = graph.getNonCallSafepoint(i);
if (from <= inputOf(ins))
break;
}

Просмотреть файл

@ -562,7 +562,7 @@ FilterArguments(JSContext *cx, JSString *str)
if (!chars)
return false;
static jschar arguments[] = {'a', 'r', 'g', 'u', 'm', 'e', 'n', 't', 's'};
static const jschar arguments[] = {'a', 'r', 'g', 'u', 'm', 'e', 'n', 't', 's'};
return !StringHasPattern(chars, str->length(), arguments, mozilla::ArrayLength(arguments));
}

Просмотреть файл

@ -75,8 +75,8 @@ class Registers
typedef RegisterID Code;
static const char *GetName(Code code) {
static const char *Names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "sp", "r14", "pc"};
static const char * const Names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "sp", "r14", "pc"};
return Names[code];
}
@ -181,8 +181,8 @@ class FloatRegisters
typedef FPRegisterID Code;
static const char *GetName(Code code) {
static const char *Names[] = { "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
"d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15"};
static const char * const Names[] = { "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
"d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15"};
return Names[code];
}

Просмотреть файл

@ -36,10 +36,10 @@ class Registers {
typedef JSC::X86Registers::RegisterID Code;
static const char *GetName(Code code) {
static const char *Names[] = { "rax", "rcx", "rdx", "rbx",
"rsp", "rbp", "rsi", "rdi",
"r8", "r9", "r10", "r11",
"r12", "r13", "r14", "r15" };
static const char * const Names[] = { "rax", "rcx", "rdx", "rbx",
"rsp", "rbp", "rsi", "rdi",
"r8", "r9", "r10", "r11",
"r12", "r13", "r14", "r15" };
return Names[code];
}
@ -118,10 +118,10 @@ class FloatRegisters {
typedef JSC::X86Registers::XMMRegisterID Code;
static const char *GetName(Code code) {
static const char *Names[] = { "xmm0", "xmm1", "xmm2", "xmm3",
"xmm4", "xmm5", "xmm6", "xmm7",
"xmm8", "xmm9", "xmm10", "xmm11",
"xmm12", "xmm13", "xmm14", "xmm15" };
static const char * const Names[] = { "xmm0", "xmm1", "xmm2", "xmm3",
"xmm4", "xmm5", "xmm6", "xmm7",
"xmm8", "xmm9", "xmm10", "xmm11",
"xmm12", "xmm13", "xmm14", "xmm15" };
return Names[code];
}

Просмотреть файл

@ -43,8 +43,8 @@ class Registers {
typedef JSC::X86Registers::RegisterID Code;
static const char *GetName(Code code) {
static const char *Names[] = { "eax", "ecx", "edx", "ebx",
"esp", "ebp", "esi", "edi" };
static const char * const Names[] = { "eax", "ecx", "edx", "ebx",
"esp", "ebp", "esi", "edi" };
return Names[code];
}
@ -107,8 +107,8 @@ class FloatRegisters {
typedef JSC::X86Registers::XMMRegisterID Code;
static const char *GetName(Code code) {
static const char *Names[] = { "xmm0", "xmm1", "xmm2", "xmm3",
"xmm4", "xmm5", "xmm6", "xmm7" };
static const char * const Names[] = { "xmm0", "xmm1", "xmm2", "xmm3",
"xmm4", "xmm5", "xmm6", "xmm7" };
return Names[code];
}

Просмотреть файл

@ -30,7 +30,7 @@ static const char STRICT_TWO[] =
static const char STRICT_THREE[] =
"function f() { 'use strict'; return arguments; }";
static const char *CALL_CODES[] =
static const char * const CALL_CODES[] =
{ "f()", "f(0)", "f(0, 1)", "f(0, 1, 2)", "f(0, 1, 2, 3)", "f(0, 1, 2, 3, 4)" };
static const size_t MAX_ELEMS = 6;

Просмотреть файл

@ -169,8 +169,8 @@ class AutoVersionAPI
#endif
#ifdef JS_USE_JSID_STRUCT_TYPES
jsid JSID_VOID = { size_t(JSID_TYPE_VOID) };
jsid JSID_EMPTY = { size_t(JSID_TYPE_OBJECT) };
const jsid JSID_VOID = { size_t(JSID_TYPE_VOID) };
const jsid JSID_EMPTY = { size_t(JSID_TYPE_OBJECT) };
#endif
const jsval JSVAL_NULL = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_NULL, 0));
@ -1806,7 +1806,7 @@ typedef struct JSStdName {
} JSStdName;
static Handle<PropertyName*>
StdNameToPropertyName(JSContext *cx, JSStdName *stdn)
StdNameToPropertyName(JSContext *cx, const JSStdName *stdn)
{
return OFFSET_TO_NAME(cx->runtime(), stdn->atomOffset);
}
@ -1815,7 +1815,7 @@ StdNameToPropertyName(JSContext *cx, JSStdName *stdn)
* Table of class initializers and their atom offsets in rt->atomState.
* If you add a "standard" class, remember to update this table.
*/
static JSStdName standard_class_atoms[] = {
static const JSStdName standard_class_atoms[] = {
{js_InitFunctionClass, EAGER_ATOM_AND_CLASP(Function)},
{js_InitObjectClass, EAGER_ATOM_AND_CLASP(Object)},
{js_InitArrayClass, EAGER_ATOM_AND_CLASP(Array)},
@ -1849,7 +1849,7 @@ static JSStdName standard_class_atoms[] = {
* If you add a "standard" global function or property, remember to update
* this table.
*/
static JSStdName standard_class_names[] = {
static const JSStdName standard_class_names[] = {
{js_InitObjectClass, EAGER_ATOM(eval), CLASP(Object)},
/* Global properties and functions defined by the Number class. */
@ -1900,7 +1900,7 @@ static JSStdName standard_class_names[] = {
{NULL, 0, NULL}
};
static JSStdName object_prototype_names[] = {
static const JSStdName object_prototype_names[] = {
/* Object.prototype properties (global delegates to Object.prototype). */
{js_InitObjectClass, EAGER_ATOM(proto), CLASP(Object)},
#if JS_HAS_TOSOURCE
@ -1932,7 +1932,7 @@ JS_ResolveStandardClass(JSContext *cx, JSObject *objArg, jsid id, JSBool *resolv
RootedObject obj(cx, objArg);
JSRuntime *rt;
JSAtom *atom;
JSStdName *stdnm;
const JSStdName *stdnm;
unsigned i;
AssertHeapIsIdle(cx);
@ -4047,7 +4047,7 @@ JS_DefineObject(JSContext *cx, JSObject *objArg, const char *name, JSClass *jscl
}
JS_PUBLIC_API(JSBool)
JS_DefineConstDoubles(JSContext *cx, JSObject *objArg, JSConstDoubleSpec *cds)
JS_DefineConstDoubles(JSContext *cx, JSObject *objArg, const JSConstDoubleSpec *cds)
{
RootedObject obj(cx, objArg);
JSBool ok;

Просмотреть файл

@ -1309,8 +1309,8 @@ JSID_IS_EMPTY(const jsid id)
#undef id
#ifdef JS_USE_JSID_STRUCT_TYPES
extern JS_PUBLIC_DATA(jsid) JSID_VOID;
extern JS_PUBLIC_DATA(jsid) JSID_EMPTY;
extern JS_PUBLIC_DATA(const jsid) JSID_VOID;
extern JS_PUBLIC_DATA(const jsid) JSID_EMPTY;
#else
# define JSID_VOID ((jsid)JSID_TYPE_VOID)
# define JSID_EMPTY ((jsid)JSID_TYPE_OBJECT)
@ -3193,7 +3193,7 @@ JS_DefineObject(JSContext *cx, JSObject *obj, const char *name, JSClass *clasp,
JSObject *proto, unsigned attrs);
extern JS_PUBLIC_API(JSBool)
JS_DefineConstDoubles(JSContext *cx, JSObject *obj, JSConstDoubleSpec *cds);
JS_DefineConstDoubles(JSContext *cx, JSObject *obj, const JSConstDoubleSpec *cds);
extern JS_PUBLIC_API(JSBool)
JS_DefineProperties(JSContext *cx, JSObject *obj, const JSPropertySpec *ps);

Просмотреть файл

@ -43,7 +43,7 @@ js_AtomToPrintableString(JSContext *cx, JSAtom *atom, JSAutoByteString *bytes)
return js_ValueToPrintable(cx, StringValue(atom), bytes);
}
const char * js::TypeStrings[] = {
const char * const js::TypeStrings[] = {
js_undefined_str,
js_object_str,
js_function_str,

Просмотреть файл

@ -181,7 +181,7 @@ extern const char js_send_str[];
namespace js {
extern const char * TypeStrings[];
extern const char * const TypeStrings[];
/*
* Initialize atom state. Return true on success, false on failure to allocate

Просмотреть файл

@ -543,7 +543,7 @@ Class js::DateClass = {
/* for use by date_parse */
static const char* wtb[] = {
static const char* const wtb[] = {
"am", "pm",
"monday", "tuesday", "wednesday", "thursday", "friday",
"saturday", "sunday",
@ -557,7 +557,7 @@ static const char* wtb[] = {
/* time zone table needs to be expanded */
};
static int ttb[] = {
static const int ttb[] = {
-1, -2, 0, 0, 0, 0, 0, 0, 0, /* AM/PM */
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
10000 + 0, 10000 + 0, 10000 + 0, /* GMT/UT/UTC */
@ -2459,12 +2459,12 @@ date_setYear(JSContext *cx, unsigned argc, Value *vp)
}
/* constants for toString, toUTCString */
static char js_NaN_date_str[] = "Invalid Date";
static const char* days[] =
static const char js_NaN_date_str[] = "Invalid Date";
static const char * const days[] =
{
"Sun","Mon","Tue","Wed","Thu","Fri","Sat"
};
static const char* months[] =
static const char * const months[] =
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};

Просмотреть файл

@ -892,7 +892,7 @@ js::GetErrorTypeName(JSContext* cx, int16_t exnType)
#if defined ( DEBUG_mccabe ) && defined ( PRINTNAMES )
/* For use below... get character strings for error name and exception name */
static struct exnname { char *name; char *exception; } errortoexnname[] = {
static const struct exnname { char *name; char *exception; } errortoexnname[] = {
#define MSG_DEF(name, number, count, exception, format) \
{#name, #exception},
#include "js.msg"

Просмотреть файл

@ -97,7 +97,7 @@ static const uint64_t GC_IDLE_FULL_SPAN = 20 * 1000 * 1000;
static const int IGC_MARK_SLICE_MULTIPLIER = 2;
/* This array should be const, but that doesn't link right under GCC. */
AllocKind gc::slotsToThingKind[] = {
const AllocKind gc::slotsToThingKind[] = {
/* 0 */ FINALIZE_OBJECT0, FINALIZE_OBJECT2, FINALIZE_OBJECT2, FINALIZE_OBJECT4,
/* 4 */ FINALIZE_OBJECT4, FINALIZE_OBJECT8, FINALIZE_OBJECT8, FINALIZE_OBJECT8,
/* 8 */ FINALIZE_OBJECT8, FINALIZE_OBJECT12, FINALIZE_OBJECT12, FINALIZE_OBJECT12,
@ -176,7 +176,7 @@ static const AllocKind FinalizePhaseIonCode[] = {
FINALIZE_IONCODE
};
static const AllocKind* FinalizePhases[] = {
static const AllocKind * const FinalizePhases[] = {
FinalizePhaseStrings,
FinalizePhaseScripts,
FinalizePhaseIonCode
@ -219,7 +219,7 @@ static const AllocKind BackgroundPhaseShapes[] = {
FINALIZE_TYPE_OBJECT
};
static const AllocKind* BackgroundPhases[] = {
static const AllocKind * const BackgroundPhases[] = {
BackgroundPhaseObjects,
BackgroundPhaseStrings,
BackgroundPhaseShapes

Просмотреть файл

@ -51,7 +51,7 @@ namespace gc {
/* Capacity for slotsToThingKind */
const size_t SLOTS_TO_THING_KIND_LIMIT = 17;
extern AllocKind slotsToThingKind[];
extern const AllocKind slotsToThingKind[];
/* Get the best kind to use when making an object with the given slot count. */
static inline AllocKind
@ -77,8 +77,6 @@ GetGCObjectKind(Class *clasp)
static inline AllocKind
GetGCArrayKind(size_t numSlots)
{
extern AllocKind slotsToThingKind[];
/*
* Dense arrays can use their fixed slots to hold their elements array
* (less two Values worth of ObjectElements header), but if more than the
@ -94,8 +92,6 @@ GetGCArrayKind(size_t numSlots)
static inline AllocKind
GetGCObjectFixedSlotsKind(size_t numFixedSlots)
{
extern AllocKind slotsToThingKind[];
JS_ASSERT(numFixedSlots < SLOTS_TO_THING_KIND_LIMIT);
return slotsToThingKind[numFixedSlots];
}

Просмотреть файл

@ -149,9 +149,9 @@ const char *
types::InferSpewColor(TypeConstraint *constraint)
{
/* Type constraints are printed out using foreground colors. */
static const char *colors[] = { "\x1b[31m", "\x1b[32m", "\x1b[33m",
"\x1b[34m", "\x1b[35m", "\x1b[36m",
"\x1b[37m" };
static const char * const colors[] = { "\x1b[31m", "\x1b[32m", "\x1b[33m",
"\x1b[34m", "\x1b[35m", "\x1b[36m",
"\x1b[37m" };
if (!InferSpewColorable())
return "";
return colors[DefaultHasher<TypeConstraint *>::hash(constraint) % 7];
@ -161,9 +161,9 @@ const char *
types::InferSpewColor(TypeSet *types)
{
/* Type sets are printed out using bold colors. */
static const char *colors[] = { "\x1b[1;31m", "\x1b[1;32m", "\x1b[1;33m",
"\x1b[1;34m", "\x1b[1;35m", "\x1b[1;36m",
"\x1b[1;37m" };
static const char * const colors[] = { "\x1b[1;31m", "\x1b[1;32m", "\x1b[1;33m",
"\x1b[1;34m", "\x1b[1;35m", "\x1b[1;36m",
"\x1b[1;37m" };
if (!InferSpewColorable())
return "";
return colors[DefaultHasher<TypeSet *>::hash(types) % 7];

Просмотреть файл

@ -73,7 +73,7 @@ using mozilla::SpecificNaN;
#define M_SQRT1_2 0.70710678118654752440
#endif
static JSConstDoubleSpec math_constants[] = {
static const JSConstDoubleSpec math_constants[] = {
{M_E, "E", 0, {0,0,0}},
{M_LOG2E, "LOG2E", 0, {0,0,0}},
{M_LOG10E, "LOG10E", 0, {0,0,0}},

Просмотреть файл

@ -73,13 +73,13 @@ const JSCodeSpec js_CodeSpec[] = {
#undef OPDEF
};
unsigned js_NumCodeSpecs = JS_ARRAY_LENGTH(js_CodeSpec);
const unsigned js_NumCodeSpecs = JS_ARRAY_LENGTH(js_CodeSpec);
/*
* Each element of the array is either a source literal associated with JS
* bytecode or null.
*/
static const char *CodeToken[] = {
static const char * const CodeToken[] = {
#define OPDEF(op,val,name,token,length,nuses,ndefs,format) \
token,
#include "jsopcode.tbl"
@ -90,7 +90,7 @@ static const char *CodeToken[] = {
* Array of JS bytecode names used by PC count JSON, DEBUG-only js_Disassemble
* and JIT debug spew.
*/
const char *js_CodeName[] = {
const char * const js_CodeName[] = {
#define OPDEF(op,val,name,token,length,nuses,ndefs,format) \
name,
#include "jsopcode.tbl"
@ -172,7 +172,7 @@ js::StackDefs(JSScript *script, jsbytecode *pc)
return op == JSOP_ENTERLET1 ? n + 1 : n;
}
static const char * countBaseNames[] = {
static const char * const countBaseNames[] = {
"interp",
"mjit",
"mjit_calls",
@ -182,7 +182,7 @@ static const char * countBaseNames[] = {
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(countBaseNames) == PCCounts::BASE_LIMIT);
static const char * countAccessNames[] = {
static const char * const countAccessNames[] = {
"infer_mono",
"infer_di",
"infer_poly",
@ -200,7 +200,7 @@ static const char * countAccessNames[] = {
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(countBaseNames) +
JS_ARRAY_LENGTH(countAccessNames) == PCCounts::ACCESS_LIMIT);
static const char * countElementNames[] = {
static const char * const countElementNames[] = {
"id_int",
"id_double",
"id_other",
@ -215,7 +215,7 @@ JS_STATIC_ASSERT(JS_ARRAY_LENGTH(countBaseNames) +
JS_ARRAY_LENGTH(countAccessNames) +
JS_ARRAY_LENGTH(countElementNames) == PCCounts::ELEM_LIMIT);
static const char * countPropertyNames[] = {
static const char * const countPropertyNames[] = {
"prop_static",
"prop_definite",
"prop_other"
@ -225,7 +225,7 @@ JS_STATIC_ASSERT(JS_ARRAY_LENGTH(countBaseNames) +
JS_ARRAY_LENGTH(countAccessNames) +
JS_ARRAY_LENGTH(countPropertyNames) == PCCounts::PROP_LIMIT);
static const char * countArithNames[] = {
static const char * const countArithNames[] = {
"arith_int",
"arith_double",
"arith_other",
@ -2086,7 +2086,8 @@ AppendJSONProperty(StringBuffer &buf, const char *name, MaybeComma comma = COMMA
static void
AppendArrayJSONProperties(JSContext *cx, StringBuffer &buf,
double *values, const char **names, unsigned count, MaybeComma &comma)
double *values, const char * const *names, unsigned count,
MaybeComma &comma)
{
for (unsigned i = 0; i < count; i++) {
if (values[i]) {

Просмотреть файл

@ -215,8 +215,8 @@ struct JSCodeSpec {
};
extern const JSCodeSpec js_CodeSpec[];
extern unsigned js_NumCodeSpecs;
extern const char *js_CodeName[];
extern const unsigned js_NumCodeSpecs;
extern const char * const js_CodeName[];
extern const char js_EscapeMap[];
/* Silence unreferenced formal parameter warnings */
@ -652,7 +652,7 @@ class PCCounts
static const char *countName(JSOp op, size_t which);
double *rawCounts() { return counts; }
double *rawCounts() const { return counts; }
double& get(size_t which) {
JS_ASSERT(which < capacity);

Просмотреть файл

@ -32,7 +32,7 @@ using namespace js::frontend;
using mozilla::ArrayLength;
using mozilla::DebugOnly;
char const *js::aopNames[] = {
char const * const js::aopNames[] = {
"=", /* AOP_ASSIGN */
"+=", /* AOP_PLUS */
"-=", /* AOP_MINUS */
@ -47,7 +47,7 @@ char const *js::aopNames[] = {
"&=" /* AOP_BITAND */
};
char const *js::binopNames[] = {
char const * const js::binopNames[] = {
"==", /* BINOP_EQ */
"!=", /* BINOP_NE */
"===", /* BINOP_STRICTEQ */
@ -71,7 +71,7 @@ char const *js::binopNames[] = {
"instanceof", /* BINOP_INSTANCEOF */
};
char const *js::unopNames[] = {
char const * const js::unopNames[] = {
"delete", /* UNOP_DELETE */
"-", /* UNOP_NEG */
"+", /* UNOP_POS */
@ -81,14 +81,14 @@ char const *js::unopNames[] = {
"void" /* UNOP_VOID */
};
char const *js::nodeTypeNames[] = {
char const * const js::nodeTypeNames[] = {
#define ASTDEF(ast, str, method) str,
#include "jsast.tbl"
#undef ASTDEF
NULL
};
static char const *callbackNames[] = {
static char const * const callbackNames[] = {
#define ASTDEF(ast, str, method) method,
#include "jsast.tbl"
#undef ASTDEF

Просмотреть файл

@ -88,10 +88,10 @@ enum PropKind {
PROP_LIMIT
};
extern char const *aopNames[];
extern char const *binopNames[];
extern char const *unopNames[];
extern char const *nodeTypeNames[];
extern char const * const aopNames[];
extern char const * const binopNames[];
extern char const * const unopNames[];
extern char const * const nodeTypeNames[];
} /* namespace js */

Просмотреть файл

@ -365,8 +365,8 @@ static const JSFunctionSpec string_functions[] = {
JS_FS_END
};
jschar js_empty_ucstr[] = {0};
JSSubString js_EmptySubString = {0, js_empty_ucstr};
const jschar js_empty_ucstr[] = {0};
const JSSubString js_EmptySubString = {0, js_empty_ucstr};
static const unsigned STRING_ELEMENT_ATTRS = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;

Просмотреть файл

@ -60,8 +60,8 @@ struct JSSubString {
const jschar *chars;
};
extern jschar js_empty_ucstr[];
extern JSSubString js_EmptySubString;
extern const jschar js_empty_ucstr[];
extern const JSSubString js_EmptySubString;
/*
* Shorthands for ASCII (7-bit) decimal and hex conversion.

Просмотреть файл

@ -2062,7 +2062,7 @@ DisassWithSrc(JSContext *cx, unsigned argc, jsval *vp)
FILE *file;
char linebuf[LINE_BUF_LEN];
jsbytecode *pc, *end;
static char sep[] = ";-------------------------";
static const char sep[] = ";-------------------------";
bool ok = true;
RootedScript script(cx);
@ -3564,7 +3564,7 @@ GetSelfHostedValue(JSContext *cx, unsigned argc, jsval *vp)
return cx->runtime()->cloneSelfHostedValue(cx, srcName, args.rval());
}
static JSFunctionSpecWithHelp shell_functions[] = {
static const JSFunctionSpecWithHelp shell_functions[] = {
JS_FN_HELP("version", Version, 0, 0,
"version([number])",
" Get or force a script compilation version number."),
@ -3887,7 +3887,7 @@ static JSFunctionSpecWithHelp shell_functions[] = {
JS_FS_HELP_END
};
static JSFunctionSpecWithHelp self_hosting_functions[] = {
static const JSFunctionSpecWithHelp self_hosting_functions[] = {
JS_FN_HELP("getSelfHostedValue", GetSelfHostedValue, 1, 0,
"getSelfHostedValue()",
" Get a self-hosted value by its name. Note that these values don't get \n"

Просмотреть файл

@ -143,10 +143,10 @@ PrintParagraph(const char *text, unsigned startColno, const unsigned limitColno,
static const char *
OptionFlagsToFormatInfo(char shortflag, bool isValued, size_t *length)
{
static const char *fmt[4] = { " -%c --%s ",
" --%s ",
" -%c --%s=%s ",
" --%s=%s " };
static const char * const fmt[4] = { " -%c --%s ",
" --%s ",
" -%c --%s=%s ",
" --%s=%s " };
/* How mny chars w/o longflag? */
size_t lengths[4] = { strlen(fmt[0]) - 3,

Просмотреть файл

@ -34,24 +34,24 @@ namespace JSC { namespace Yarr {
#include <stddef.h>
#include "mozilla/StandardInteger.h"
uint16_t ucs2CharacterSet0[] = { 0x01c4u, 0x01c5u, 0x01c6u, 0 };
uint16_t ucs2CharacterSet1[] = { 0x01c7u, 0x01c8u, 0x01c9u, 0 };
uint16_t ucs2CharacterSet2[] = { 0x01cau, 0x01cbu, 0x01ccu, 0 };
uint16_t ucs2CharacterSet3[] = { 0x01f1u, 0x01f2u, 0x01f3u, 0 };
uint16_t ucs2CharacterSet4[] = { 0x0392u, 0x03b2u, 0x03d0u, 0 };
uint16_t ucs2CharacterSet5[] = { 0x0395u, 0x03b5u, 0x03f5u, 0 };
uint16_t ucs2CharacterSet6[] = { 0x0398u, 0x03b8u, 0x03d1u, 0 };
uint16_t ucs2CharacterSet7[] = { 0x0345u, 0x0399u, 0x03b9u, 0x1fbeu, 0 };
uint16_t ucs2CharacterSet8[] = { 0x039au, 0x03bau, 0x03f0u, 0 };
uint16_t ucs2CharacterSet9[] = { 0x00b5u, 0x039cu, 0x03bcu, 0 };
uint16_t ucs2CharacterSet10[] = { 0x03a0u, 0x03c0u, 0x03d6u, 0 };
uint16_t ucs2CharacterSet11[] = { 0x03a1u, 0x03c1u, 0x03f1u, 0 };
uint16_t ucs2CharacterSet12[] = { 0x03a3u, 0x03c2u, 0x03c3u, 0 };
uint16_t ucs2CharacterSet13[] = { 0x03a6u, 0x03c6u, 0x03d5u, 0 };
uint16_t ucs2CharacterSet14[] = { 0x1e60u, 0x1e61u, 0x1e9bu, 0 };
const uint16_t ucs2CharacterSet0[] = { 0x01c4u, 0x01c5u, 0x01c6u, 0 };
const uint16_t ucs2CharacterSet1[] = { 0x01c7u, 0x01c8u, 0x01c9u, 0 };
const uint16_t ucs2CharacterSet2[] = { 0x01cau, 0x01cbu, 0x01ccu, 0 };
const uint16_t ucs2CharacterSet3[] = { 0x01f1u, 0x01f2u, 0x01f3u, 0 };
const uint16_t ucs2CharacterSet4[] = { 0x0392u, 0x03b2u, 0x03d0u, 0 };
const uint16_t ucs2CharacterSet5[] = { 0x0395u, 0x03b5u, 0x03f5u, 0 };
const uint16_t ucs2CharacterSet6[] = { 0x0398u, 0x03b8u, 0x03d1u, 0 };
const uint16_t ucs2CharacterSet7[] = { 0x0345u, 0x0399u, 0x03b9u, 0x1fbeu, 0 };
const uint16_t ucs2CharacterSet8[] = { 0x039au, 0x03bau, 0x03f0u, 0 };
const uint16_t ucs2CharacterSet9[] = { 0x00b5u, 0x039cu, 0x03bcu, 0 };
const uint16_t ucs2CharacterSet10[] = { 0x03a0u, 0x03c0u, 0x03d6u, 0 };
const uint16_t ucs2CharacterSet11[] = { 0x03a1u, 0x03c1u, 0x03f1u, 0 };
const uint16_t ucs2CharacterSet12[] = { 0x03a3u, 0x03c2u, 0x03c3u, 0 };
const uint16_t ucs2CharacterSet13[] = { 0x03a6u, 0x03c6u, 0x03d5u, 0 };
const uint16_t ucs2CharacterSet14[] = { 0x1e60u, 0x1e61u, 0x1e9bu, 0 };
static const size_t UCS2_CANONICALIZATION_SETS = 15;
uint16_t* characterSetInfo[UCS2_CANONICALIZATION_SETS] = {
const uint16_t* const characterSetInfo[UCS2_CANONICALIZATION_SETS] = {
ucs2CharacterSet0,
ucs2CharacterSet1,
ucs2CharacterSet2,
@ -70,7 +70,7 @@ uint16_t* characterSetInfo[UCS2_CANONICALIZATION_SETS] = {
};
const size_t UCS2_CANONICALIZATION_RANGES = 364;
UCS2CanonicalizationRange rangeInfo[UCS2_CANONICALIZATION_RANGES] = {
const UCS2CanonicalizationRange rangeInfo[UCS2_CANONICALIZATION_RANGES] = {
{ 0x0000u, 0x0040u, 0x0000u, CanonicalizeUnique },
{ 0x0041u, 0x005au, 0x0020u, CanonicalizeRangeLo },
{ 0x005bu, 0x0060u, 0x0000u, CanonicalizeUnique },
@ -438,7 +438,7 @@ UCS2CanonicalizationRange rangeInfo[UCS2_CANONICALIZATION_RANGES] = {
};
const size_t LATIN_CANONICALIZATION_RANGES = 20;
LatinCanonicalizationRange latinRangeInfo[LATIN_CANONICALIZATION_RANGES] = {
const LatinCanonicalizationRange latinRangeInfo[LATIN_CANONICALIZATION_RANGES] = {
{ 0x0000u, 0x0040u, 0x0000u, CanonicalizeLatinSelf },
{ 0x0041u, 0x005au, 0x0000u, CanonicalizeLatinMask0x20 },
{ 0x005bu, 0x0060u, 0x0000u, CanonicalizeLatinSelf },

Просмотреть файл

@ -47,8 +47,8 @@ enum UCS2CanonicalizationType {
};
struct UCS2CanonicalizationRange { uint16_t begin, end, value, type; };
extern const size_t UCS2_CANONICALIZATION_RANGES;
extern uint16_t* characterSetInfo[];
extern UCS2CanonicalizationRange rangeInfo[];
extern const uint16_t* const characterSetInfo[];
extern const UCS2CanonicalizationRange rangeInfo[];
// This table is similar to the full rangeInfo table, however this maps from UCS2 codepoints to
// the set of Latin1 codepoints that could match.
@ -60,17 +60,17 @@ enum LatinCanonicalizationType {
};
struct LatinCanonicalizationRange { uint16_t begin, end, value, type; };
extern const size_t LATIN_CANONICALIZATION_RANGES;
extern LatinCanonicalizationRange latinRangeInfo[];
extern const LatinCanonicalizationRange latinRangeInfo[];
// This searches in log2 time over ~364 entries, so should typically result in 8 compares.
inline UCS2CanonicalizationRange* rangeInfoFor(UChar ch)
inline const UCS2CanonicalizationRange* rangeInfoFor(UChar ch)
{
UCS2CanonicalizationRange* info = rangeInfo;
const UCS2CanonicalizationRange* info = rangeInfo;
size_t entries = UCS2_CANONICALIZATION_RANGES;
while (true) {
size_t candidate = entries >> 1;
UCS2CanonicalizationRange* candidateInfo = info + candidate;
const UCS2CanonicalizationRange* candidateInfo = info + candidate;
if (ch < candidateInfo->begin)
entries = candidate;
else if (ch <= candidateInfo->end)
@ -83,7 +83,7 @@ inline UCS2CanonicalizationRange* rangeInfoFor(UChar ch)
}
// Should only be called for characters that have one canonically matching value.
inline UChar getCanonicalPair(UCS2CanonicalizationRange* info, UChar ch)
inline UChar getCanonicalPair(const UCS2CanonicalizationRange* info, UChar ch)
{
ASSERT(ch >= info->begin && ch <= info->end);
switch (info->type) {
@ -111,12 +111,12 @@ inline bool isCanonicallyUnique(UChar ch)
// Returns true if values are equal, under the canonicalization rules.
inline bool areCanonicallyEquivalent(UChar a, UChar b)
{
UCS2CanonicalizationRange* info = rangeInfoFor(a);
const UCS2CanonicalizationRange* info = rangeInfoFor(a);
switch (info->type) {
case CanonicalizeUnique:
return a == b;
case CanonicalizeSet: {
for (uint16_t* set = characterSetInfo[info->value]; (a = *set); ++set) {
for (const uint16_t* set = characterSetInfo[info->value]; (a = *set); ++set) {
if (a == b)
return true;
}

Просмотреть файл

@ -90,21 +90,21 @@ public:
}
// Add multiple matches, if necessary.
UCS2CanonicalizationRange* info = rangeInfoFor(ch);
const UCS2CanonicalizationRange* info = rangeInfoFor(ch);
if (info->type == CanonicalizeUnique)
addSorted(m_matchesUnicode, ch);
else
putUnicodeIgnoreCase(ch, info);
}
void putUnicodeIgnoreCase(UChar ch, UCS2CanonicalizationRange* info)
void putUnicodeIgnoreCase(UChar ch, const UCS2CanonicalizationRange* info)
{
ASSERT(m_isCaseInsensitive);
ASSERT(ch > 0x7f);
ASSERT(ch >= info->begin && ch <= info->end);
ASSERT(info->type != CanonicalizeUnique);
if (info->type == CanonicalizeSet) {
for (uint16_t* set = characterSetInfo[info->value]; (ch = *set); ++set)
for (const uint16_t* set = characterSetInfo[info->value]; (ch = *set); ++set)
addSorted(m_matchesUnicode, ch);
} else {
addSorted(m_matchesUnicode, ch);
@ -135,7 +135,7 @@ public:
if (!m_isCaseInsensitive)
return;
UCS2CanonicalizationRange* info = rangeInfoFor(lo);
const UCS2CanonicalizationRange* info = rangeInfoFor(lo);
while (true) {
// Handle the range [lo .. end]
UChar end = std::min<UChar>(info->end, hi);
@ -146,7 +146,7 @@ public:
break;
case CanonicalizeSet: {
UChar ch;
for (uint16_t* set = characterSetInfo[info->value]; (ch = *set); ++set)
for (const uint16_t* set = characterSetInfo[info->value]; (ch = *set); ++set)
addSorted(m_matchesUnicode, ch);
break;
}
@ -326,7 +326,7 @@ public:
return;
}
UCS2CanonicalizationRange* info = rangeInfoFor(ch);
const UCS2CanonicalizationRange* info = rangeInfoFor(ch);
if (info->type == CanonicalizeUnique) {
m_alternative->m_terms.append(PatternTerm(ch));
return;

Просмотреть файл

@ -82,12 +82,12 @@ char* xpc_CloneAllAccess()
return (char*)nsMemory::Clone(allAccess, sizeof(allAccess));
}
char * xpc_CheckAccessList(const PRUnichar* wideName, const char* list[])
char * xpc_CheckAccessList(const PRUnichar* wideName, const char* const list[])
{
nsAutoCString asciiName;
CopyUTF16toUTF8(nsDependentString(wideName), asciiName);
for (const char** p = list; *p; p++)
for (const char* const* p = list; *p; p++)
if (!strcmp(*p, asciiName.get()))
return xpc_CloneAllAccess();
@ -1329,7 +1329,7 @@ nsXPCComponents_Results::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
uint32_t enum_op, jsval * statep,
jsid * idp, bool *_retval)
{
void** iter;
const void** iter;
switch (enum_op) {
case JSENUMERATE_INIT:
@ -1346,7 +1346,7 @@ nsXPCComponents_Results::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
case JSENUMERATE_NEXT:
{
const char* name;
iter = (void**) JSVAL_TO_PRIVATE(*statep);
iter = (const void**) JSVAL_TO_PRIVATE(*statep);
if (nsXPCException::IterateNSResults(nullptr, &name, nullptr, iter)) {
JSString* idstr = JS_NewStringCopyZ(cx, name);
if (idstr && JS_ValueToId(cx, STRING_TO_JSVAL(idstr), idp))
@ -1357,7 +1357,7 @@ nsXPCComponents_Results::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
case JSENUMERATE_DESTROY:
default:
iter = (void**) JSVAL_TO_PRIVATE(*statep);
iter = (const void**) JSVAL_TO_PRIVATE(*statep);
delete [] (char*) iter;
*statep = JSVAL_NULL;
return NS_OK;
@ -1378,7 +1378,7 @@ nsXPCComponents_Results::NewResolve(nsIXPConnectWrappedNative *wrapper,
if (JSID_IS_STRING(id) && name.encodeLatin1(cx, JSID_TO_STRING(id))) {
const char* rv_name;
void* iter = nullptr;
const void* iter = nullptr;
nsresult rv;
while (nsXPCException::IterateNSResults(&rv, &rv_name, nullptr, &iter)) {
if (!strcmp(name.ptr(), rv_name)) {
@ -4395,7 +4395,7 @@ nsXPCComponents_Utils::CanCreateWrapper(const nsIID * iid, char **_retval)
NS_IMETHODIMP
nsXPCComponents_Utils::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
static const char* allowed[] = { "lookupMethod", "evalInSandbox", nullptr };
static const char* const allowed[] = { "lookupMethod", "evalInSandbox", nullptr };
*_retval = xpc_CheckAccessList(methodName, allowed);
return NS_OK;
}
@ -4917,7 +4917,7 @@ nsXPCComponents::CanCreateWrapper(const nsIID * iid, char **_retval)
NS_IMETHODIMP
nsXPCComponents::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
static const char* allowed[] = { "isSuccessCode", "lookupMethod", nullptr };
static const char* const allowed[] = { "isSuccessCode", "lookupMethod", nullptr };
*_retval = xpc_CheckAccessList(methodName, allowed);
if (*_retval &&
methodName[0] == 'l' &&
@ -4932,7 +4932,7 @@ nsXPCComponents::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, c
NS_IMETHODIMP
nsXPCComponents::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
static const char* allowed[] = { "interfaces", "interfacesByID", "results", nullptr};
static const char* const allowed[] = { "interfaces", "interfacesByID", "results", nullptr};
*_retval = xpc_CheckAccessList(propertyName, allowed);
if (*_retval &&
propertyName[0] == 'i' &&

Просмотреть файл

@ -19,7 +19,7 @@
* in some more global way at runtime.
*/
static struct ResultMap
static const struct ResultMap
{nsresult rv; const char* name; const char* format;} map[] = {
#define XPC_MSG_DEF(val, format) \
{(val), #val, format},
@ -37,7 +37,7 @@ nsXPCException::NameAndFormatForNSResult(nsresult rv,
const char** format)
{
for (ResultMap* p = map; p->name; p++) {
for (const ResultMap* p = map; p->name; p++) {
if (rv == p->rv) {
if (name) *name = p->name;
if (format) *format = p->format;
@ -48,13 +48,13 @@ nsXPCException::NameAndFormatForNSResult(nsresult rv,
}
// static
void*
const void*
nsXPCException::IterateNSResults(nsresult* rv,
const char** name,
const char** format,
void** iterp)
const void** iterp)
{
ResultMap* p = (ResultMap*) *iterp;
const ResultMap* p = (const ResultMap*) *iterp;
if (!p)
p = map;
else

Просмотреть файл

@ -565,7 +565,7 @@ nsJSIID::CanCreateWrapper(const nsIID * iid, char **_retval)
NS_IMETHODIMP
nsJSIID::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
static const char* allowed[] = {"equals", "toString", nullptr};
static const char* const allowed[] = {"equals", "toString", nullptr};
*_retval = xpc_CheckAccessList(methodName, allowed);
return NS_OK;
@ -575,7 +575,7 @@ nsJSIID::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_r
NS_IMETHODIMP
nsJSIID::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
static const char* allowed[] = {"name", "number", "valid", nullptr};
static const char* const allowed[] = {"name", "number", "valid", nullptr};
*_retval = xpc_CheckAccessList(propertyName, allowed);
return NS_OK;
}

Просмотреть файл

@ -3275,7 +3275,7 @@ void DEBUG_ReportShadowedMembers(XPCNativeSet* set,
// We just want to skip some classes...
if (si) {
// Add any classnames to skip to this (null terminated) array...
static const char* skipClasses[] = {
static const char* const skipClasses[] = {
"Window",
"HTMLDocument",
"HTMLCollection",

Просмотреть файл

@ -3100,10 +3100,10 @@ public:
const char** name,
const char** format);
static void* IterateNSResults(nsresult* rv,
const char** name,
const char** format,
void** iterp);
static const void* IterateNSResults(nsresult* rv,
const char** name,
const char** format,
const void** iterp);
static uint32_t GetNSResultCount();
@ -3589,7 +3589,7 @@ extern char* xpc_CloneAllAccess();
/***************************************************************************/
// Returns access if wideName is in list
extern char * xpc_CheckAccessList(const PRUnichar* wideName, const char* list[]);
extern char * xpc_CheckAccessList(const PRUnichar* wideName, const char* const list[]);
/***************************************************************************/
// in xpcvariant.cpp...