From 00b72e1cb0511cb93f08e07fb28c37f48d48ef13 Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Mon, 25 Oct 2010 16:47:11 -0700 Subject: [PATCH] Bug 607148 - Remove unnamed namespaces from SpiderMonkey code. rs=luke --- js/src/jsarray.cpp | 6 +----- js/src/jsdate.cpp | 6 +----- js/src/jsexn.cpp | 4 ---- js/src/jsfun.cpp | 47 ++++++++++------------------------------------ js/src/jsnum.cpp | 16 ++++------------ js/src/jsstr.cpp | 4 ---- 6 files changed, 16 insertions(+), 67 deletions(-) diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index 02c06b73b71..c95e6499386 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -912,9 +912,7 @@ array_trace(JSTracer *trc, JSObject *obj) } } -namespace { - -JSBool +static JSBool array_fix(JSContext *cx, JSObject *obj, bool *success, AutoIdVector *props) { JS_ASSERT(obj->isDenseArray()); @@ -931,8 +929,6 @@ array_fix(JSContext *cx, JSObject *obj, bool *success, AutoIdVector *props) return true; } -} // namespace - Class js_ArrayClass = { "Array", Class::NON_NATIVE | diff --git a/js/src/jsdate.cpp b/js/src/jsdate.cpp index 3e26e2c17a3..34af443b32c 100644 --- a/js/src/jsdate.cpp +++ b/js/src/jsdate.cpp @@ -2019,10 +2019,8 @@ date_toISOString(JSContext *cx, uintN argc, Value *vp) return date_utc_format(cx, vp, print_iso_string); } -namespace { - /* ES5 15.9.5.44. */ -JSBool +static JSBool date_toJSON(JSContext *cx, uintN argc, Value *vp) { /* Step 1. */ @@ -2068,8 +2066,6 @@ date_toJSON(JSContext *cx, uintN argc, Value *vp) return true; } -} - /* for Date.toLocaleString; interface to PRMJTime date struct. */ static void diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp index fee09a0df88..01c09df5bc4 100644 --- a/js/src/jsexn.cpp +++ b/js/src/jsexn.cpp @@ -259,8 +259,6 @@ GetStackTraceValueBuffer(JSExnPrivate *priv) return (jsval *)(priv->stackElems + priv->stackDepth); } -namespace { - struct CopyTo { Value *dst; @@ -270,8 +268,6 @@ struct CopyTo } }; -} - static JSBool InitExnPrivate(JSContext *cx, JSObject *exnObject, JSString *message, JSString *filename, uintN lineno, JSErrorReport *report) diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp index 56957915143..226aebd41b8 100644 --- a/js/src/jsfun.cpp +++ b/js/src/jsfun.cpp @@ -209,8 +209,6 @@ NewArguments(JSContext *cx, JSObject *parent, uint32 argc, JSObject &callee) return argsobj; } -namespace { - struct STATIC_SKIP_INFERENCE PutArg { PutArg(Value *dst) : dst(dst) {} @@ -222,8 +220,6 @@ struct STATIC_SKIP_INFERENCE PutArg } }; -} - JSObject * js_GetArgsObject(JSContext *cx, JSStackFrame *fp) { @@ -651,9 +647,7 @@ args_enumerate(JSContext *cx, JSObject *obj) return true; } -namespace { - -JSBool +static JSBool StrictArgGetter(JSContext *cx, JSObject *obj, jsid id, Value *vp) { LeaveTrace(cx); @@ -680,7 +674,7 @@ StrictArgGetter(JSContext *cx, JSObject *obj, jsid id, Value *vp) return true; } -JSBool +static JSBool StrictArgSetter(JSContext *cx, JSObject *obj, jsid id, Value *vp) { if (!InstanceOf(cx, obj, &StrictArgumentsClass, NULL)) @@ -707,7 +701,7 @@ StrictArgSetter(JSContext *cx, JSObject *obj, jsid id, Value *vp) js_SetProperty(cx, obj, id, vp, true); } -JSBool +static JSBool strictargs_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp) { JS_ASSERT(obj->isStrictArguments()); @@ -757,7 +751,7 @@ strictargs_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject return true; } -JSBool +static JSBool strictargs_enumerate(JSContext *cx, JSObject *obj) { JS_ASSERT(obj->isStrictArguments()); @@ -789,8 +783,6 @@ strictargs_enumerate(JSContext *cx, JSObject *obj) return true; } -} // namespace - static void args_finalize(JSContext *cx, JSObject *obj) { @@ -1611,8 +1603,6 @@ fun_getProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp) return true; } -namespace { - struct LazyFunctionDataProp { uint16 atomOffset; int8 tinyid; @@ -1626,19 +1616,17 @@ struct PoisonPillProp { /* NB: no sentinels at ends -- use JS_ARRAY_LENGTH to bound loops. */ -const LazyFunctionDataProp lazyFunctionDataProps[] = { +static const LazyFunctionDataProp lazyFunctionDataProps[] = { {ATOM_OFFSET(arity), FUN_ARITY, JSPROP_PERMANENT|JSPROP_READONLY}, {ATOM_OFFSET(name), FUN_NAME, JSPROP_PERMANENT|JSPROP_READONLY}, }; /* Properties censored into [[ThrowTypeError]] in strict mode. */ -const PoisonPillProp poisonPillProps[] = { +static const PoisonPillProp poisonPillProps[] = { {ATOM_OFFSET(arguments), FUN_ARGUMENTS }, {ATOM_OFFSET(caller), FUN_CALLER }, }; -} - static JSBool fun_enumerate(JSContext *cx, JSObject *obj) { @@ -2238,8 +2226,6 @@ js_fun_call(JSContext *cx, uintN argc, Value *vp) return ok; } -namespace { - struct STATIC_SKIP_INFERENCE CopyNonHoleArgs { CopyNonHoleArgs(JSObject *aobj, Value *dst) : aobj(aobj), dst(dst) {} @@ -2254,8 +2240,6 @@ struct STATIC_SKIP_INFERENCE CopyNonHoleArgs } }; -} - /* ES5 15.3.4.3 */ JSBool js_fun_apply(JSContext *cx, uintN argc, Value *vp) @@ -2360,11 +2344,8 @@ js_fun_apply(JSContext *cx, uintN argc, Value *vp) return true; } -namespace { - -JSBool +static JSBool CallOrConstructBoundFunction(JSContext *cx, uintN argc, Value *vp); -} inline bool JSObject::initBoundFunction(JSContext *cx, const Value &thisArg, @@ -2424,10 +2405,8 @@ JSObject::getBoundFunctionArguments(uintN &argslen) const return getSlots() + FUN_CLASS_RESERVED_SLOTS; } -namespace { - /* ES5 15.3.4.5.1 and 15.3.4.5.2. */ -JSBool +static JSBool CallOrConstructBoundFunction(JSContext *cx, uintN argc, Value *vp) { JSObject *obj = &vp[0].toObject(); @@ -2475,7 +2454,7 @@ CallOrConstructBoundFunction(JSContext *cx, uintN argc, Value *vp) } /* ES5 15.3.4.5. */ -JSBool +static JSBool fun_bind(JSContext *cx, uintN argc, Value *vp) { /* Step 1. */ @@ -2534,8 +2513,6 @@ fun_bind(JSContext *cx, uintN argc, Value *vp) return true; } -} - static JSFunctionSpec function_methods[] = { #if JS_HAS_TOSOURCE JS_FN(js_toSource_str, fun_toSource, 0,0), @@ -2766,9 +2743,7 @@ Function(JSContext *cx, uintN argc, Value *vp) filename, lineno); } -namespace { - -JSBool +static JSBool ThrowTypeError(JSContext *cx, uintN argc, Value *vp) { JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, NULL, @@ -2776,8 +2751,6 @@ ThrowTypeError(JSContext *cx, uintN argc, Value *vp) return false; } -} - JSObject * js_InitFunctionClass(JSContext *cx, JSObject *obj) { diff --git a/js/src/jsnum.cpp b/js/src/jsnum.cpp index d9a0ade7bb0..d7859b5d866 100644 --- a/js/src/jsnum.cpp +++ b/js/src/jsnum.cpp @@ -104,14 +104,12 @@ JS_STATIC_ASSERT(uintptr_t(PTRDIFF_MAX) + uintptr_t(1) == uintptr_t(PTRDIFF_MIN) #endif /* JS_HAVE_STDINT_H */ -namespace { - /* * If we're accumulating a decimal number and the number is >= 2^53, then the * fast result from the loop in GetPrefixInteger may be inaccurate. Call * js_strtod_harder to get the correct answer. */ -bool +static bool ComputeAccurateDecimalInteger(JSContext *cx, const jschar *start, const jschar *end, jsdouble *dp) { size_t length = end - start; @@ -186,7 +184,7 @@ class BinaryDigitReader * down. An example occurs when reading the number 0x1000000000000081, which * rounds to 0x1000000000000000 instead of 0x1000000000000100. */ -jsdouble +static jsdouble ComputeAccurateBinaryBaseInteger(JSContext *cx, const jschar *start, const jschar *end, int base) { BinaryDigitReader bdr(base, start, end); @@ -226,8 +224,6 @@ ComputeAccurateBinaryBaseInteger(JSContext *cx, const jschar *start, const jscha return value; } -} // namespace - namespace js { bool @@ -346,9 +342,7 @@ ParseFloat(JSContext* cx, JSString* str) } #endif -namespace { - -bool +static bool ParseIntStringHelper(JSContext *cx, const jschar *ws, const jschar *end, int maybeRadix, bool stripPrefix, jsdouble *dp) { @@ -401,7 +395,7 @@ ParseIntStringHelper(JSContext *cx, const jschar *ws, const jschar *end, int may return true; } -jsdouble +static jsdouble ParseIntDoubleHelper(jsdouble d) { if (!JSDOUBLE_IS_FINITE(d)) @@ -413,8 +407,6 @@ ParseIntDoubleHelper(jsdouble d) return 0; } -} // namespace - /* See ECMA 15.1.2.2. */ static JSBool num_parseInt(JSContext *cx, uintN argc, Value *vp) diff --git a/js/src/jsstr.cpp b/js/src/jsstr.cpp index 972d0b6d12e..483d34cebda 100644 --- a/js/src/jsstr.cpp +++ b/js/src/jsstr.cpp @@ -1229,8 +1229,6 @@ js_BoyerMooreHorspool(const jschar *text, jsuint textlen, return -1; } -namespace { - struct MemCmp { typedef jsuint Extent; static JS_ALWAYS_INLINE Extent computeExtent(const jschar *, jsuint patlen) { @@ -1255,8 +1253,6 @@ struct ManualCmp { } }; -} - template static jsint UnrolledMatch(const jschar *text, jsuint textlen, const jschar *pat, jsuint patlen)