Bug 807161 - Remove extern C and #ifdef __cplusplus from JSAPI (r=luke)
authorBill McCloskey <wmccloskey@mozilla.com>
Tue, 30 Oct 2012 18:28:34 -0700
changeset 119873 d97862fb8e6de0d16f2c8df69b92619583a601e8
parent 119872 8826baca157606ddd86c4b80578e519ef9b284c8
child 119874 b93a413268f7da4ea9ff778a2aa6fe36fce0ebf6
push id1997
push userakeybl@mozilla.com
push dateMon, 07 Jan 2013 21:25:26 +0000
treeherdermozilla-beta@4baf45cdcf21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs807161
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 807161 - Remove extern C and #ifdef __cplusplus from JSAPI (r=luke)
js/public/Utility.h
js/src/ctypes/CTypes.cpp
js/src/jsapi-tests/Makefile.in
js/src/jsapi.h
js/src/jscntxt.h
js/src/jsdbgapi.h
js/src/jsdhash.h
js/src/jsdtoa.h
js/src/jsfriendapi.h
js/src/jsopcode.h
js/src/jsprf.h
js/src/jsproxy.h
js/src/jsprvtd.h
js/src/jspubtd.h
js/src/jsreflect.cpp
js/src/jstypes.h
js/src/jsval.h
js/src/prmjtime.h
--- a/js/public/Utility.h
+++ b/js/public/Utility.h
@@ -16,17 +16,16 @@
 
 #ifdef JS_OOM_DO_BACKTRACES
 #include <stdio.h>
 #include <execinfo.h>
 #endif
 
 #include "jstypes.h"
 
-#ifdef __cplusplus
 # include "js/TemplateLib.h"
 # include "mozilla/Scoped.h"
 
 /* The public JS engine namespace. */
 namespace JS {}
 
 /* The mozilla-shared reusable template/utility namespace. */
 namespace mozilla {}
@@ -34,19 +33,16 @@ namespace mozilla {}
 /* The private JS engine namespace. */
 namespace js {
 
 /* The private namespace is a superset of the public/shared namespaces. */
 using namespace JS;
 using namespace mozilla;
 
 }  /* namespace js */
-#endif  /* __cplusplus */
-
-JS_BEGIN_EXTERN_C
 
 /*
  * Pattern used to overwrite freed memory. If you are accessing an object with
  * this pattern, you probably have a dangling pointer.
  */
 #define JS_FREE_PATTERN 0xDA
 
 #define JS_ASSERT(expr)           MOZ_ASSERT(expr)
@@ -166,16 +162,18 @@ static JS_INLINE void* js_realloc(void* 
 }
 
 static JS_INLINE void js_free(void* p)
 {
     free(p);
 }
 #endif/* JS_USE_CUSTOM_ALLOCATOR */
 
+JS_BEGIN_EXTERN_C
+
 /*
  * Replace bit-scanning code sequences with CPU-specific instructions to
  * speedup calculations of ceiling/floor log2.
  *
  * With GCC 3.4 or later we can use __builtin_clz for that, see bug 327129.
  *
  * SWS: Added MSVC intrinsic bitscan support.  See bugs 349364 and 356856.
  */
@@ -325,16 +323,18 @@ JS_PUBLIC_API(size_t) js_FloorLog2wImpl(
     ((size_t)(JS_BITS_PER_WORD - 1 - js_bitscan_clz64(n)))
 # else
 JS_PUBLIC_API(size_t) js_FloorLog2wImpl(size_t n);
 # endif
 #else
 # error "NOT SUPPORTED"
 #endif
 
+JS_END_EXTERN_C
+
 /*
  * Internal function.
  * Compute the log of the least power of 2 greater than or equal to n. This is
  * a version of JS_CeilingLog2 that operates on unsigned integers with
  * CPU-dependant size.
  */
 #define JS_CEILING_LOG2W(n) ((n) <= 1 ? 0 : 1 + JS_FLOOR_LOG2W((n) - 1))
 
@@ -366,19 +366,16 @@ JS_FLOOR_LOG2W(size_t n)
     defined(_M_X64))
 #include <stdlib.h>
 #pragma intrinsic(_rotl)
 #define JS_ROTATE_LEFT32(a, bits) _rotl(a, bits)
 #else
 #define JS_ROTATE_LEFT32(a, bits) (((a) << (bits)) | ((a) >> (32 - (bits))))
 #endif
 
-JS_END_EXTERN_C
-
-#ifdef __cplusplus
 #include <new>
 
 /*
  * Low-level memory management in SpiderMonkey:
  *
  *  ** Do not use the standard malloc/free/realloc: SpiderMonkey allows these
  *     to be redefined (via JS_USE_CUSTOM_ALLOCATOR) and Gecko even #define's
  *     these symbols.
@@ -898,18 +895,16 @@ inline bool IsPoisonedPtr(T *v)
     return mask == uint32_t(JS_FREE_PATTERN << 24);
 #else
     return false;
 #endif
 }
 
 }
 
-#endif /* defined(__cplusplus) */
-
 /*
  * This is SpiderMonkey's equivalent to |nsMallocSizeOfFun|.
  */
 typedef size_t(*JSMallocSizeOfFun)(const void *p);
 
 /* sixgill annotation defines */
 #ifndef HAVE_STATIC_ANNOTATIONS
 # define HAVE_STATIC_ANNOTATIONS
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -1259,17 +1259,21 @@ bool GetObjectProperty(JSContext *cx, Ha
     JS_ReportError(cx, "missing or non-object field");
     return false;
   }
 
   result.set(JSVAL_TO_OBJECT(val));
   return true;
 }
 
-JS_BEGIN_EXTERN_C
+} /* namespace ctypes */
+} /* namespace js */
+
+using namespace js;
+using namespace js::ctypes;
 
 JS_PUBLIC_API(JSBool)
 JS_InitCTypesClass(JSContext* cx, JSObject *globalArg)
 {
   RootedObject global(cx, globalArg);
 
   // attach ctypes property to global object
   RootedObject ctypes(cx, JS_NewObject(cx, &sCTypesGlobalClass, NULL, NULL));
@@ -1320,17 +1324,18 @@ JS_SetCTypesCallbacks(JSRawObject ctypes
 {
   JS_ASSERT(callbacks);
   JS_ASSERT(IsCTypesGlobal(ctypesObj));
 
   // Set the callbacks on a reserved slot.
   JS_SetReservedSlot(ctypesObj, SLOT_CALLBACKS, PRIVATE_TO_JSVAL(callbacks));
 }
 
-JS_END_EXTERN_C
+namespace js {
+namespace ctypes {
 
 /*******************************************************************************
 ** Type conversion functions
 *******************************************************************************/
 
 // Enforce some sanity checks on type widths and properties.
 // Where the architecture is 64-bit, make sure it's LP64 or LLP64. (ctypes.int
 // autoconverts to a primitive JS number; to support ILP64 architectures, it
--- a/js/src/jsapi-tests/Makefile.in
+++ b/js/src/jsapi-tests/Makefile.in
@@ -55,27 +55,23 @@ CPPSRCS = \
   testResolveRecursion.cpp \
   testSameValue.cpp \
   testScriptInfo.cpp \
   testScriptObject.cpp \
   testSetProperty.cpp \
   testStringBuffer.cpp \
   testTrap.cpp \
   testTypedArrays.cpp \
-  testValueABI.cpp \
   testVersion.cpp \
   testXDR.cpp \
   testProfileStrings.cpp \
   testJSEvaluateScript.cpp \
   testErrorCopying.cpp \
   $(NULL)
 
-CSRCS = \
-  valueABI.c
-
 # Disabled: an entirely unrelated test seems to cause this to fail.  Moreover,
 # given the test's dependence on interactions between the compiler, the GC, and
 # conservative stack scanning, the fix isn't obvious: more investigation
 # needed.
 #CPPSRCS += \
 #  testRegExpInstanceProperties.cpp \
 #  $(NULL)
 
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -9,48 +9,43 @@
 #define jsapi_h___
 /*
  * JavaScript API.
  */
 
 #include "mozilla/Attributes.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/StandardInteger.h"
-#ifdef __cplusplus
-# include "mozilla/RangedPtr.h"
-# include "mozilla/ThreadLocal.h"
-#endif
+#include "mozilla/RangedPtr.h"
+#include "mozilla/ThreadLocal.h"
 
 #include <stddef.h>
 #include <stdio.h>
 #include "js-config.h"
 #include "jspubtd.h"
 #include "jsutil.h"
 #include "jsval.h"
 
 #include "js/Utility.h"
 #include "gc/Root.h"
 
-#ifdef __cplusplus
 #include <limits> /* for std::numeric_limits */
 
 #include "jsalloc.h"
 #include "js/Vector.h"
-#endif
 
 /************************************************************************/
 
 /* JS::Value can store a full int32_t. */
 #define JSVAL_INT_BITS          32
 #define JSVAL_INT_MIN           ((int32_t)0x80000000)
 #define JSVAL_INT_MAX           ((int32_t)0x7fffffff)
 
 /************************************************************************/
 
-#ifdef __cplusplus
 namespace JS {
 
 typedef mozilla::RangedPtr<const jschar> CharPtr;
 
 class StableCharPtr : public CharPtr {
   public:
     StableCharPtr(const StableCharPtr &s) : CharPtr(s) {}
     StableCharPtr(const mozilla::RangedPtr<const jschar> &s) : CharPtr(s) {}
@@ -1591,51 +1586,25 @@ IMPL_TO_JSVAL(jsval_layout l)
     return v;
 }
 
 #ifdef DEBUG
 struct JSValueAlignmentTester { char c; JS::Value v; };
 JS_STATIC_ASSERT(sizeof(JSValueAlignmentTester) == 16);
 #endif /* DEBUG */
 
-#else  /* defined(__cplusplus) */
-
-/*
- * For SpiderMonkey C clients, there is no JS::Value class, only the
- * traditional jsval with the traditional JSVAL_* operations. Since
- * SpiderMonkey itself is always compiled as C++, this relies on the binary
- * compatibility of jsval_layout and JS::Value (statically asserted below).
- */
-typedef union jsval_layout jsval;
-
-static JS_ALWAYS_INLINE jsval_layout
-JSVAL_TO_IMPL(jsval v)
-{
-    return v;
-}
-
-static JS_ALWAYS_INLINE jsval
-IMPL_TO_JSVAL(jsval_layout l)
-{
-    return l;
-}
-
-#endif  /* defined(__cplusplus) */
-
 #ifdef DEBUG
 typedef struct { char c; jsval_layout l; } JSLayoutAlignmentTester;
 JS_STATIC_ASSERT(sizeof(JSLayoutAlignmentTester) == 16);
 #endif /* DEBUG */
 
 JS_STATIC_ASSERT(sizeof(jsval_layout) == sizeof(jsval));
 
 /************************************************************************/
 
-#ifdef __cplusplus
-
 typedef JS::Handle<JSObject*> JSHandleObject;
 typedef JS::Handle<JSString*> JSHandleString;
 typedef JS::Handle<JS::Value> JSHandleValue;
 typedef JS::Handle<jsid> JSHandleId;
 
 typedef JS::MutableHandle<JSObject*>   JSMutableHandleObject;
 typedef JS::MutableHandle<JSFunction*> JSMutableHandleFunction;
 typedef JS::MutableHandle<JSScript*>   JSMutableHandleScript;
@@ -1645,53 +1614,16 @@ typedef JS::MutableHandle<jsid>        J
 
 typedef JS::RawObject   JSRawObject;
 typedef JS::RawFunction JSRawFunction;
 typedef JS::RawScript   JSRawScript;
 typedef JS::RawString   JSRawString;
 typedef JS::RawId       JSRawId;
 typedef JS::RawValue    JSRawValue;
 
-#else
-
-/*
- * Handle support for C API users. Handles must be destroyed in the reverse
- * order that they were created (as in a stack).
- */
-
-typedef struct { JSObject **_; } JSHandleObject;
-typedef struct { JSString **_; } JSHandleString;
-typedef struct { jsval     *_; } JSHandleValue;
-typedef struct { jsid      *_; } JSHandleId;
-
-typedef struct { JSObject   **_; } JSMutableHandleObject;
-typedef struct { JSFunction **_; } JSMutableHandleFunction;
-typedef struct { JSScript   **_; } JSMutableHandleScript;
-typedef struct { JSString   **_; } JSMutableHandleString;
-typedef struct { jsval       *_; } JSMutableHandleValue;
-typedef struct { jsid        *_; } JSMutableHandleId;
-
-typedef JSObject   *JSRawObject;
-typedef JSFunction *JSRawFunction;
-typedef JSScript   *JSRawScript;
-typedef JSString   *JSRawString;
-typedef jsid       *JSRawId;
-typedef jsval      *JSRawValue;
-
-JSBool JS_CreateHandleObject(JSContext *cx, JSObject *obj, JSHandleObject *phandle);
-void JS_DestroyHandleObject(JSContext *cx, JSHandleObject handle);
-
-JSBool JS_CreateMutableHandleObject(JSContext *cx, JSObject *obj, JSMutableHandleObject *phandle);
-void JS_DestroyMutableHandleObject(JSContext *cx, JSMutableHandleObject handle);
-
-JSBool JS_CreateHandleId(JSContext *cx, jsid id, JSHandleId *phandle);
-void JS_DestroyHandleId(JSContext *cx, JSHandleId handle);
-
-#endif
-
 /* JSClass operation signatures. */
 
 /*
  * Add, delete, or get a property named by id in obj.  Note the jsid id
  * type -- id may be a string (Unicode property identifier) or an int (element
  * index).  The *vp out parameter, on success, is the new property value after
  * an add or get.  After a successful delete, *vp is JSVAL_FALSE iff
  * obj[id] can't be deleted (because it's permanent).
@@ -1796,31 +1728,27 @@ typedef JSBool
  * Delegate typeof to an object so it can cloak a primitive or another object.
  */
 typedef JSType
 (* JSTypeOfOp)(JSContext *cx, JSHandleObject obj);
 
 typedef struct JSFreeOp JSFreeOp;
 
 struct JSFreeOp {
-#ifndef __cplusplus
-    JSRuntime   *runtime;
-#else
   private:
     JSRuntime   *runtime_;
 
   protected:
     JSFreeOp(JSRuntime *rt)
       : runtime_(rt) { }
 
   public:
     JSRuntime *runtime() const {
         return runtime_;
     }
-#endif
 };
 
 /*
  * Finalize obj, which the garbage collector has determined to be unreachable
  * from other live objects or from GC roots.  Obviously, finalizers must never
  * store a reference to obj.
  */
 typedef void
@@ -2082,18 +2010,16 @@ typedef JSBool (*WriteStructuredCloneOp)
  * This is called when JS_WriteStructuredClone is given an invalid transferable.
  * To follow HTML5, the application must throw a DATA_CLONE_ERR DOMException
  * with error set to one of the JS_SCERR_* values.
  */
 typedef void (*StructuredCloneErrorOp)(JSContext *cx, uint32_t errorid);
 
 /************************************************************************/
 
-JS_BEGIN_EXTERN_C
-
 /*
  * Silence warning about returning JS::Value (aka jsval) from functions with C
  * linkage. For C JSAPI clients, jsval will be jsval_layout, which should be
  * ABI compatible.
  */
 #ifdef _MSC_VER
 # pragma warning(disable:4190)
 #endif
@@ -2467,18 +2393,16 @@ extern JS_PUBLIC_DATA(jsid) JSID_EMPTY;
  * multiple JSRuntimes without requiring any conversion API.
  */
 static JS_ALWAYS_INLINE JSBool
 JSVAL_IS_UNIVERSAL(jsval v)
 {
     return !JSVAL_IS_GCTHING(v);
 }
 
-#ifdef __cplusplus
-
 namespace JS {
 
 class AutoIdRooter : private AutoGCRooter
 {
   public:
     explicit AutoIdRooter(JSContext *cx, jsid id = INT_TO_JSID(0)
                           JS_GUARD_OBJECT_NOTIFIER_PARAM)
       : AutoGCRooter(cx, ID), id_(id)
@@ -2498,18 +2422,16 @@ class AutoIdRooter : private AutoGCRoote
 
   private:
     jsid id_;
     JS_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 } /* namespace JS */
 
-#endif /* __cplusplus */
-
 /************************************************************************/
 
 /* Property attributes, set in JSPropertySpec and passed to API functions. */
 #define JSPROP_ENUMERATE        0x01    /* property is visible to for/in loop */
 #define JSPROP_READONLY         0x02    /* not settable: assignment is no-op.
                                            This flag is only valid when neither
                                            JSPROP_GETTER nor JSPROP_SETTER is
                                            set. */
@@ -2658,17 +2580,16 @@ extern JS_PUBLIC_API(JSString *)
 JS_ValueToString(JSContext *cx, jsval v);
 
 extern JS_PUBLIC_API(JSString *)
 JS_ValueToSource(JSContext *cx, jsval v);
 
 extern JS_PUBLIC_API(JSBool)
 JS_ValueToNumber(JSContext *cx, jsval v, double *dp);
 
-#ifdef __cplusplus
 namespace js {
 /*
  * DO NOT CALL THIS.  Use JS::ToNumber
  */
 extern JS_PUBLIC_API(bool)
 ToNumberSlow(JSContext *cx, JS::Value v, double *dp);
 
 /*
@@ -2714,17 +2635,16 @@ ToBoolean(const Value &v)
         return !MOZ_DOUBLE_IS_NaN(d) && d != 0;
     }
 
     /* Slow path. Handle Strings. */
     return js::ToBooleanSlow(v);
 }
 
 } /* namespace JS */
-#endif /* __cplusplus */
 
 extern JS_PUBLIC_API(JSBool)
 JS_DoubleIsInt32(double d, int32_t *ip);
 
 extern JS_PUBLIC_API(int32_t)
 JS_DoubleToInt32(double d);
 
 extern JS_PUBLIC_API(uint32_t)
@@ -2746,17 +2666,16 @@ JS_ValueToInt64(JSContext *cx, jsval v, 
 
 /*
  * Convert a value to a number, then to an uint64_t, according to the WebIDL
  * rules for ToUint64: http://dev.w3.org/2006/webapi/WebIDL/#es-unsigned-long-long
  */
 extern JS_PUBLIC_API(JSBool)
 JS_ValueToUint64(JSContext *cx, jsval v, uint64_t *ip);
 
-#ifdef __cplusplus
 namespace js {
 /* DO NOT CALL THIS.  Use JS::ToInt16. */
 extern JS_PUBLIC_API(bool)
 ToUint16Slow(JSContext *cx, const JS::Value &v, uint16_t *out);
 
 /* DO NOT CALL THIS.  Use JS::ToInt32. */
 extern JS_PUBLIC_API(bool)
 ToInt32Slow(JSContext *cx, const JS::Value &v, int32_t *out);
@@ -2861,17 +2780,16 @@ ToUint64(JSContext *cx, const js::Value 
         return true;
     }
 
     return js::ToUint64Slow(cx, v, out);
 }
 
 
 } /* namespace JS */
-#endif /* __cplusplus */
 
 /*
  * Convert a value to a number, then to a uint32_t, according to the ECMA rules
  * for ToUint32.
  */
 extern JS_PUBLIC_API(JSBool)
 JS_ValueToECMAUint32(JSContext *cx, jsval v, uint32_t *ip);
 
@@ -2960,19 +2878,16 @@ extern JS_PUBLIC_API(void)
 JS_BeginRequest(JSContext *cx);
 
 extern JS_PUBLIC_API(void)
 JS_EndRequest(JSContext *cx);
 
 extern JS_PUBLIC_API(JSBool)
 JS_IsInRequest(JSRuntime *rt);
 
-#ifdef __cplusplus
-JS_END_EXTERN_C
-
 namespace JS {
 
 extern mozilla::ThreadLocal<JSRuntime *> TlsRuntime;
 
 inline bool
 IsPoisonedId(jsid iden)
 {
     if (JSID_IS_STRING(iden))
@@ -3036,19 +2951,16 @@ class JSAutoCheckRequest {
 
   private:
 #if defined JS_THREADSAFE && defined DEBUG
     JSContext *mContext;
 #endif
     JS_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
-JS_BEGIN_EXTERN_C
-#endif
-
 extern JS_PUBLIC_API(JSContextCallback)
 JS_SetContextCallback(JSRuntime *rt, JSContextCallback cxCallback);
 
 extern JS_PUBLIC_API(JSContext *)
 JS_NewContext(JSRuntime *rt, size_t stackChunkSize);
 
 extern JS_PUBLIC_API(void)
 JS_DestroyContext(JSContext *cx);
@@ -3249,33 +3161,27 @@ JS_RefreshCrossCompartmentWrappers(JSCon
  *   }
  *
  * Note: these calls must still execute in a LIFO manner w.r.t all other
  * enter/leave calls on the context. Furthermore, only the return value of a
  * JS_EnterCompartment call may be passed as the 'oldCompartment' argument of
  * the corresponding JS_LeaveCompartment call.
  */
 
-#ifdef __cplusplus
-JS_END_EXTERN_C
-
 class JS_PUBLIC_API(JSAutoCompartment)
 {
     JSContext *cx_;
     JSCompartment *oldCompartment_;
   public:
     JSAutoCompartment(JSContext *cx, JSRawObject target);
     JSAutoCompartment(JSContext *cx, JSScript *target);
     JSAutoCompartment(JSContext *cx, JSStackFrame *target);
     ~JSAutoCompartment();
 };
 
-JS_BEGIN_EXTERN_C
-#endif
-
 /* NB: This API is infallible; a NULL return value does not indicate error. */
 extern JS_PUBLIC_API(JSCompartment *)
 JS_EnterCompartment(JSContext *cx, JSRawObject target);
 
 extern JS_PUBLIC_API(void)
 JS_LeaveCompartment(JSContext *cx, JSCompartment *oldCompartment);
 
 typedef void (*JSIterateCompartmentCallback)(JSRuntime *rt, void *data, JSCompartment *compartment);
@@ -3462,24 +3368,22 @@ JS_EnumerateDiagnosticMemoryRegions(JSEn
 #define JS_THIS_OBJECT(cx,vp)   (JSVAL_TO_OBJECT(JS_THIS(cx,vp)))
 #define JS_ARGV(cx,vp)          ((vp) + 2)
 #define JS_RVAL(cx,vp)          (*(vp))
 #define JS_SET_RVAL(cx,vp,v)    (*(vp) = (v))
 
 extern JS_PUBLIC_API(jsval)
 JS_ComputeThis(JSContext *cx, jsval *vp);
 
-#ifdef __cplusplus
 #undef JS_THIS
 static inline jsval
 JS_THIS(JSContext *cx, jsval *vp)
 {
     return JSVAL_IS_PRIMITIVE(vp[1]) ? JS_ComputeThis(cx, vp) : vp[1];
 }
-#endif
 
 /*
  * |this| is passed to functions in ES5 without change.  Functions themselves
  * do any post-processing they desire to box |this|, compute the global object,
  * &c.  Use this macro to retrieve a function's unboxed |this| value.
  *
  * This macro must not be used in conjunction with JS_THIS or JS_THIS_OBJECT,
  * or vice versa.  Either use the provided this value with this macro, or
@@ -4134,18 +4038,16 @@ extern JS_PUBLIC_API(int)
 JS_IdArrayLength(JSContext *cx, JSIdArray *ida);
 
 extern JS_PUBLIC_API(jsid)
 JS_IdArrayGet(JSContext *cx, JSIdArray *ida, int index);
 
 extern JS_PUBLIC_API(void)
 JS_DestroyIdArray(JSContext *cx, JSIdArray *ida);
 
-#ifdef __cplusplus
-
 namespace JS {
 
 class AutoIdArray : private AutoGCRooter {
   public:
     AutoIdArray(JSContext *cx, JSIdArray *ida JS_GUARD_OBJECT_NOTIFIER_PARAM)
       : AutoGCRooter(cx, IDARRAY), context(cx), idArray(ida)
     {
         JS_GUARD_OBJECT_NOTIFIER_INIT;
@@ -4184,18 +4086,16 @@ class AutoIdArray : private AutoGCRooter
 
     /* No copy or assignment semantics. */
     AutoIdArray(AutoIdArray &ida) MOZ_DELETE;
     void operator=(AutoIdArray &ida) MOZ_DELETE;
 };
 
 } /* namespace JS */
 
-#endif /* __cplusplus */
-
 extern JS_PUBLIC_API(JSBool)
 JS_ValueToId(JSContext *cx, jsval v, jsid *idp);
 
 extern JS_PUBLIC_API(JSBool)
 JS_IdToValue(JSContext *cx, jsid id, jsval *vp);
 
 /*
  * JSNewResolveOp flag bits.
@@ -4783,29 +4683,27 @@ struct JSPrincipals {
     /* Don't call "destroy"; use reference counting macros below. */
     int refcount;
 
 #ifdef DEBUG
     /* A helper to facilitate principals debugging. */
     uint32_t    debugToken;
 #endif
 
-#ifdef __cplusplus
     void setDebugToken(uint32_t token) {
 # ifdef DEBUG
         debugToken = token;
 # endif
     }
 
     /*
      * This is not defined by the JS engine but should be provided by the
      * embedding.
      */
     JS_PUBLIC_API(void) dump();
-#endif
 };
 
 extern JS_PUBLIC_API(void)
 JS_HoldPrincipals(JSPrincipals *principals);
 
 extern JS_PUBLIC_API(void)
 JS_DropPrincipals(JSRuntime *rt, JSPrincipals *principals);
 
@@ -5001,19 +4899,16 @@ JS_CompileFunctionForPrincipals(JSContex
                                 const char *filename, unsigned lineno);
 
 extern JS_PUBLIC_API(JSFunction *)
 JS_CompileUCFunction(JSContext *cx, JSObject *obj, const char *name,
                      unsigned nargs, const char **argnames,
                      const jschar *chars, size_t length,
                      const char *filename, unsigned lineno);
 
-#ifdef __cplusplus
-JS_END_EXTERN_C
-
 namespace JS {
 
 /* Options for JavaScript compilation. */
 struct JS_PUBLIC_API(CompileOptions) {
     JSPrincipals *principals;
     JSPrincipals *originPrincipals;
     JSVersion version;
     bool versionSet;
@@ -5064,19 +4959,16 @@ CompileFunction(JSContext *cx, JSHandleO
 
 extern JS_PUBLIC_API(JSFunction *)
 CompileFunction(JSContext *cx, JSHandleObject obj, CompileOptions options,
                 const char *name, unsigned nargs, const char **argnames,
                 const jschar *chars, size_t length);
 
 } /* namespace JS */
 
-JS_BEGIN_EXTERN_C
-#endif /* __cplusplus */
-
 extern JS_PUBLIC_API(JSString *)
 JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, unsigned indent);
 
 /*
  * API extension: OR this into indent to avoid pretty-printing the decompiled
  * source resulting from JS_DecompileFunction{,Body}.
  */
 #define JS_DONT_PRETTY_PRINT    ((unsigned)0x8000)
@@ -5186,53 +5078,44 @@ JS_EvaluateUCScriptForPrincipalsVersion(
 extern JS_PUBLIC_API(JSBool)
 JS_EvaluateUCScriptForPrincipalsVersionOrigin(JSContext *cx, JSObject *obj,
                                               JSPrincipals *principals,
                                               JSPrincipals *originPrincipals,
                                               const jschar *chars, unsigned length,
                                               const char *filename, unsigned lineno,
                                               jsval *rval, JSVersion version);
 
-#ifdef __cplusplus
-JS_END_EXTERN_C
-
 namespace JS {
 
 extern JS_PUBLIC_API(bool)
 Evaluate(JSContext *cx, JSHandleObject obj, CompileOptions options,
          const jschar *chars, size_t length, jsval *rval);
 
 extern JS_PUBLIC_API(bool)
 Evaluate(JSContext *cx, JSHandleObject obj, CompileOptions options,
          const char *bytes, size_t length, jsval *rval);
 
 extern JS_PUBLIC_API(bool)
 Evaluate(JSContext *cx, JSHandleObject obj, CompileOptions options,
          const char *filename, jsval *rval);
 
 } /* namespace JS */
 
-JS_BEGIN_EXTERN_C
-#endif
-
 extern JS_PUBLIC_API(JSBool)
 JS_CallFunction(JSContext *cx, JSObject *obj, JSFunction *fun, unsigned argc,
                 jsval *argv, jsval *rval);
 
 extern JS_PUBLIC_API(JSBool)
 JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, unsigned argc,
                     jsval *argv, jsval *rval);
 
 extern JS_PUBLIC_API(JSBool)
 JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, unsigned argc,
                      jsval *argv, jsval *rval);
 
-#ifdef __cplusplus
-JS_END_EXTERN_C
-
 namespace JS {
 
 static inline bool
 Call(JSContext *cx, JSObject *thisObj, JSFunction *fun, unsigned argc, jsval *argv, jsval *rval) {
     return !!JS_CallFunction(cx, thisObj, fun, argc, argv, rval);
 }
 
 static inline bool
@@ -5250,19 +5133,16 @@ Call(JSContext *cx, jsval thisv, jsval f
 
 static inline bool
 Call(JSContext *cx, jsval thisv, JSObject *funObj, unsigned argc, jsval *argv, jsval *rval) {
     return Call(cx, thisv, OBJECT_TO_JSVAL(funObj), argc, argv, rval);
 }
 
 } /* namespace JS */
 
-JS_BEGIN_EXTERN_C
-#endif /* __cplusplus */
-
 /*
  * These functions allow setting an operation callback that will be called
  * from the JS thread some time after any thread triggered the callback using
  * JS_TriggerOperationCallback(rt).
  *
  * To schedule the GC and for other activities the engine internally triggers
  * operation callbacks. The embedding should thus not rely on callbacks being
  * triggered through the external API only.
@@ -5531,18 +5411,16 @@ JS_GetStringEncodingLength(JSContext *cx
  * encoded into bytes with no error reported. Otherwise it returns the number
  * of bytes that are necessary to encode the string. If that exceeds the
  * length parameter, the string will be cut and only length bytes will be
  * written into the buffer.
  */
 JS_PUBLIC_API(size_t)
 JS_EncodeStringToBuffer(JSString *str, char *buffer, size_t length);
 
-#ifdef __cplusplus
-
 class JSAutoByteString {
   public:
     JSAutoByteString(JSContext *cx, JSString *str JS_GUARD_OBJECT_NOTIFIER_PARAM)
       : mBytes(JS_EncodeString(cx, str)) {
         JS_ASSERT(cx);
         JS_GUARD_OBJECT_NOTIFIER_INIT;
     }
 
@@ -5585,18 +5463,16 @@ class JSAutoByteString {
     char        *mBytes;
     JS_DECL_USE_GUARD_OBJECT_NOTIFIER
 
     /* Copy and assignment are not supported. */
     JSAutoByteString(const JSAutoByteString &another);
     JSAutoByteString &operator=(const JSAutoByteString &another);
 };
 
-#endif
-
 /************************************************************************/
 /*
  * JSON functions
  */
 typedef JSBool (* JSONWriteCallback)(const jschar *buf, uint32_t len, void *data);
 
 /*
  * JSON.stringify as specified by ES5.
@@ -5650,19 +5526,16 @@ JS_PUBLIC_API(JSBool)
 JS_StructuredCloneHasTransferables(const uint64_t *data, size_t nbytes,
                                    JSBool *hasTransferable);
 
 JS_PUBLIC_API(JSBool)
 JS_StructuredClone(JSContext *cx, jsval v, jsval *vp,
                    const JSStructuredCloneCallbacks *optionalCallbacks,
                    void *closure);
 
-#ifdef __cplusplus
-JS_END_EXTERN_C
-
 /* RAII sugar for JS_WriteStructuredClone. */
 class JS_PUBLIC_API(JSAutoStructuredCloneBuffer) {
     uint64_t *data_;
     size_t nbytes_;
     uint32_t version_;
 
   public:
     JSAutoStructuredCloneBuffer()
@@ -5711,19 +5584,16 @@ class JS_PUBLIC_API(JSAutoStructuredClon
     void swap(JSAutoStructuredCloneBuffer &other);
 
   private:
     /* Copy and assignment are not supported. */
     JSAutoStructuredCloneBuffer(const JSAutoStructuredCloneBuffer &other);
     JSAutoStructuredCloneBuffer &operator=(const JSAutoStructuredCloneBuffer &other);
 };
 
-JS_BEGIN_EXTERN_C
-#endif
-
 /* API for implementing custom serialization behavior (for ImageData, File, etc.) */
 
 /* The range of tag values the application may use for its own custom object types. */
 #define JS_SCTAG_USER_MIN  ((uint32_t) 0xFFFF8000)
 #define JS_SCTAG_USER_MAX  ((uint32_t) 0xFFFFFFFF)
 
 #define JS_SCERR_RECURSION 0
 #define JS_SCERR_TRANSFERABLE 1
@@ -6048,36 +5918,30 @@ extern JS_PUBLIC_API(void)
 JS_AbortIfWrongThread(JSRuntime *rt);
 
 extern JS_PUBLIC_API(void)
 JS_ClearRuntimeThread(JSRuntime *rt);
 
 extern JS_PUBLIC_API(void)
 JS_SetRuntimeThread(JSRuntime *rt);
 
-#ifdef __cplusplus
-JS_END_EXTERN_C
-
 class JSAutoSetRuntimeThread
 {
     JSRuntime *runtime;
 
   public:
     JSAutoSetRuntimeThread(JSRuntime *runtime) : runtime(runtime) {
         JS_SetRuntimeThread(runtime);
     }
 
     ~JSAutoSetRuntimeThread() {
         JS_ClearRuntimeThread(runtime);
     }
 };
 
-JS_BEGIN_EXTERN_C
-#endif
-
 /************************************************************************/
 
 /*
  * JS_IsConstructing must be called from within a native given the
  * native's original cx and vp arguments. If JS_IsConstructing is true,
  * JS_THIS must not be used; the constructor should construct and return a
  * new object. Otherwise, the native is called as an ordinary function and
  * JS_THIS may be used.
@@ -6153,11 +6017,9 @@ JS_EncodeInterpretedFunction(JSContext *
 extern JS_PUBLIC_API(JSScript *)
 JS_DecodeScript(JSContext *cx, const void *data, uint32_t length,
                 JSPrincipals *principals, JSPrincipals *originPrincipals);
 
 extern JS_PUBLIC_API(JSObject *)
 JS_DecodeInterpretedFunction(JSContext *cx, const void *data, uint32_t length,
                              JSPrincipals *principals, JSPrincipals *originPrincipals);
 
-JS_END_EXTERN_C
-
 #endif /* jsapi_h___ */
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -37,19 +37,17 @@
 
 #ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(disable:4100) /* Silence unreferenced formal parameter warnings */
 #pragma warning(push)
 #pragma warning(disable:4355) /* Silence warning about "this" used in base member initializer list */
 #endif
 
-JS_BEGIN_EXTERN_C
 struct DtoaState;
-JS_END_EXTERN_C
 
 extern void
 js_ReportOutOfMemory(JSContext *cx);
 
 extern void
 js_ReportAllocationOverflow(JSContext *cx);
 
 namespace js {
--- a/js/src/jsdbgapi.h
+++ b/js/src/jsdbgapi.h
@@ -8,17 +8,16 @@
 #ifndef jsdbgapi_h___
 #define jsdbgapi_h___
 /*
  * JS debugger API.
  */
 #include "jsapi.h"
 #include "jsprvtd.h"
 
-#if defined(__cplusplus)
 namespace JS {
 
 struct FrameDescription
 {
     JSScript *script;
     unsigned lineno;
     JSFunction *fun;
 };
@@ -42,19 +41,16 @@ FormatStackDump(JSContext *cx, char *buf
 
 }
 
 # ifdef DEBUG
 JS_FRIEND_API(void) js_DumpValue(const js::Value &val);
 JS_FRIEND_API(void) js_DumpId(jsid id);
 JS_FRIEND_API(void) js_DumpStackFrame(JSContext *cx, js::StackFrame *start = NULL);
 # endif
-#endif
-
-JS_BEGIN_EXTERN_C
 
 JS_FRIEND_API(void)
 js_DumpBacktrace(JSContext *cx);
 
 extern JS_PUBLIC_API(JSCompartment *)
 JS_EnterCompartmentOfScript(JSContext *cx, JSScript *target);
 
 extern JS_PUBLIC_API(JSString *)
@@ -427,11 +423,9 @@ JS_UnwrapObject(JSObject *obj);
 
 extern JS_PUBLIC_API(JSObject *)
 JS_UnwrapObjectAndInnerize(JSObject *obj);
 
 /* Call the context debug handler on the topmost scripted frame. */
 extern JS_FRIEND_API(JSBool)
 js_CallContextDebugHandler(JSContext *cx);
 
-JS_END_EXTERN_C
-
 #endif /* jsdbgapi_h___ */
--- a/js/src/jsdhash.h
+++ b/js/src/jsdhash.h
@@ -9,18 +9,16 @@
 /*
  * Double hashing, a la Knuth 6.
  *
  * Try to keep this file in sync with xpcom/glue/pldhash.h.
  */
 #include "jstypes.h"
 #include "jsutil.h"
 
-JS_BEGIN_EXTERN_C
-
 #if defined(__GNUC__) && defined(__i386__) && (__GNUC__ >= 3) && !defined(XP_OS2)
 #define JS_DHASH_FASTCALL __attribute__ ((regparm (3),stdcall))
 #elif defined(XP_WIN)
 #define JS_DHASH_FASTCALL __fastcall
 #else
 #define JS_DHASH_FASTCALL
 #endif
 
@@ -593,11 +591,9 @@ JS_DHashMarkTableImmutable(JSDHashTable 
 
 #ifdef JS_DHASHMETER
 #include <stdio.h>
 
 extern JS_PUBLIC_API(void)
 JS_DHashTableDumpMeter(JSDHashTable *table, JSDHashEnumerator dump, FILE *fp);
 #endif
 
-JS_END_EXTERN_C
-
 #endif /* jsdhash_h___ */
--- a/js/src/jsdtoa.h
+++ b/js/src/jsdtoa.h
@@ -6,18 +6,16 @@
 
 #ifndef jsdtoa_h___
 #define jsdtoa_h___
 /*
  * Public interface to portable double-precision floating point to string
  * and back conversion package.
  */
 
-JS_BEGIN_EXTERN_C
-
 struct DtoaState;
 
 DtoaState *
 js_NewDtoaState();
 
 void
 js_DestroyDtoaState(DtoaState *state);
 
@@ -103,11 +101,9 @@ js_dtostr(DtoaState *state, char *buffer
  * not equal to itself).
  *
  * Return NULL if out of memory.  If the result is not NULL, it must be
  * released via js_free().
  */
 char *
 js_dtobasestr(DtoaState *state, int base, double d);
 
-JS_END_EXTERN_C
-
 #endif /* jsdtoa_h___ */
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -11,18 +11,16 @@
 #include "jscpucfg.h"
 #include "jspubtd.h"
 #include "jsprvtd.h"
 
 #include "js/HeapAPI.h"
 
 #include "mozilla/GuardObjects.h"
 
-JS_BEGIN_EXTERN_C
-
 #if JS_STACK_GROWTH_DIRECTION > 0
 # define JS_CHECK_STACK_SIZE(limit, lval)  ((uintptr_t)(lval) < limit)
 #else
 # define JS_CHECK_STACK_SIZE(limit, lval)  ((uintptr_t)(lval) > limit)
 #endif
 
 extern JS_FRIEND_API(void)
 JS_SetGrayGCRootsTracer(JSRuntime *rt, JSTraceDataOp traceOp, void *data);
@@ -143,18 +141,16 @@ js_DumpAtom(JSAtom *atom);
 
 extern JS_FRIEND_API(void)
 js_DumpObject(JSObject *obj);
 
 extern JS_FRIEND_API(void)
 js_DumpChars(const jschar *s, size_t n);
 #endif
 
-#ifdef __cplusplus
-
 extern JS_FRIEND_API(bool)
 JS_CopyPropertiesFrom(JSContext *cx, JSObject *target, JSObject *obj);
 
 extern JS_FRIEND_API(JSBool)
 JS_WrapPropertyDescriptor(JSContext *cx, js::PropertyDescriptor *desc);
 
 extern JS_FRIEND_API(JSBool)
 JS_WrapAutoIdVector(JSContext *cx, JS::AutoIdVector &props);
@@ -175,22 +171,16 @@ struct JSFunctionSpecWithHelp {
 #define JS_FN_HELP(name,call,nargs,flags,usage,help)                          \
     {name, call, nargs, (flags) | JSPROP_ENUMERATE | JSFUN_STUB_GSOPS, usage, help}
 #define JS_FS_HELP_END                                                        \
     {NULL, NULL, 0, 0, NULL, NULL}
 
 extern JS_FRIEND_API(bool)
 JS_DefineFunctionsWithHelp(JSContext *cx, JSObject *obj, const JSFunctionSpecWithHelp *fs);
 
-#endif
-
-JS_END_EXTERN_C
-
-#ifdef __cplusplus
-
 typedef bool (* JS_SourceHook)(JSContext *cx, JSScript *script, jschar **src, uint32_t *length);
 
 extern JS_FRIEND_API(void)
 JS_SetSourceHook(JSRuntime *rt, JS_SourceHook hook);
 
 namespace js {
 
 inline JSRuntime *
@@ -983,18 +973,16 @@ NukeCrossCompartmentWrappers(JSContext* 
 JS_FRIEND_API(void)
 SetListBaseInformation(void *listBaseHandlerFamily, uint32_t listBaseExpandoSlot);
 
 void *GetListBaseHandlerFamily();
 uint32_t GetListBaseExpandoSlot();
 
 } /* namespace js */
 
-#endif
-
 /* Implemented in jsdate.cpp. */
 
 /*
  * Detect whether the internal date value is NaN.  (Because failure is
  * out-of-band for js_DateGet*)
  */
 extern JS_FRIEND_API(JSBool)
 js_DateIsValid(JSObject* obj);
@@ -1021,18 +1009,16 @@ js_GetErrorMessage(void *userRef, const 
 
 /* Implemented in jsclone.cpp. */
 
 extern JS_FRIEND_API(uint64_t)
 js_GetSCOffset(JSStructuredCloneWriter* writer);
 
 /* Typed Array functions, implemented in jstypedarray.cpp */
 
-#ifdef __cplusplus
-
 namespace js {
 namespace ArrayBufferView {
 
 enum ViewType {
     TYPE_INT8 = 0,
     TYPE_UINT8,
     TYPE_INT16,
     TYPE_UINT16,
@@ -1049,19 +1035,16 @@ enum ViewType {
 
     TYPE_MAX
 };
 
 } /* namespace ArrayBufferView */
 } /* namespace js */
 
 typedef js::ArrayBufferView::ViewType JSArrayBufferViewType;
-#else
-typedef uint32_t JSArrayBufferViewType;
-#endif /* __cplusplus */
 
 /*
  * Create a new typed array with nelements elements.
  *
  * These functions (except the WithBuffer variants) fill in the array with zeros.
  */
 
 extern JS_FRIEND_API(JSObject *)
@@ -1389,17 +1372,16 @@ JS_GetDataViewByteLength(JSObject *obj, 
  * |obj| must have passed a JS_IsDataViewObject test, or somehow be known that
  * it would pass such a test: it is a data view or a wrapper of a data view,
  * and the unwrapping will succeed. If cx is NULL, then DEBUG builds may be
  * unable to assert when unwrapping should be disallowed.
  */
 JS_FRIEND_API(void *)
 JS_GetDataViewData(JSObject *obj, JSContext *maybecx);
 
-#ifdef __cplusplus
 /*
  * This struct contains metadata passed from the DOM to the JS Engine for JIT
  * optimizations on DOM property accessors. Eventually, this should be made
  * available to general JSAPI users, but we are not currently ready to do so.
  */
 typedef bool
 (* JSJitPropertyOp)(JSContext *cx, JSHandleObject thisObj,
                     void *specializedThis, JS::Value *vp);
@@ -1425,17 +1407,16 @@ FUNCTION_VALUE_TO_JITINFO(const JS::Valu
 static JS_ALWAYS_INLINE void
 SET_JITINFO(JSFunction * func, const JSJitInfo *info)
 {
     js::shadow::Function *fun = reinterpret_cast<js::shadow::Function *>(func);
     /* JS_ASSERT(func->isNative()). 0x4000 is JSFUN_INTERPRETED */
     JS_ASSERT(!(fun->flags & 0x4000));
     fun->jitinfo = info;
 }
-#endif /* __cplusplus */
 
 /*
  * Engine-internal extensions of jsid.  This code is here only until we
  * eliminate Gecko's dependencies on it!
  */
 
 static JS_ALWAYS_INLINE jsid
 JSID_FROM_BITS(size_t bits)
@@ -1491,18 +1472,16 @@ JSID_IS_ATOM(jsid id, JSAtom *atom)
 static JS_ALWAYS_INLINE JSAtom *
 JSID_TO_ATOM(jsid id)
 {
     return (JSAtom *)JSID_TO_STRING(id);
 }
 
 JS_STATIC_ASSERT(sizeof(jsid) == JS_BYTES_PER_WORD);
 
-#ifdef __cplusplus
-
 namespace js {
 
 static JS_ALWAYS_INLINE Value
 IdToValue(jsid id)
 {
     if (JSID_IS_STRING(id))
         return StringValue(JSID_TO_STRING(id));
     if (JS_LIKELY(JSID_IS_INT(id)))
@@ -1516,11 +1495,9 @@ IdToValue(jsid id)
 static JS_ALWAYS_INLINE jsval
 IdToJsval(jsid id)
 {
     return IdToValue(id);
 }
 
 } /* namespace js */
 
-#endif /* __cplusplus */
-
 #endif /* jsfriendapi_h___ */
--- a/js/src/jsopcode.h
+++ b/js/src/jsopcode.h
@@ -10,18 +10,16 @@
 /*
  * JS bytecode definitions.
  */
 #include <stddef.h>
 #include "jsprvtd.h"
 #include "jspubtd.h"
 #include "jsutil.h"
 
-JS_BEGIN_EXTERN_C
-
 /*
  * JS operation bytecodes.
  */
 typedef enum JSOp {
 #define OPDEF(op,val,name,token,length,nuses,ndefs,prec,format) \
     op = val,
 #include "jsopcode.tbl"
 #undef OPDEF
@@ -327,18 +325,16 @@ js_DecompileToString(JSContext *cx, cons
  */
 extern unsigned
 js_ReconstructStackDepth(JSContext *cx, JSScript *script, jsbytecode *pc);
 
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
 
-JS_END_EXTERN_C
-
 #define JSDVG_IGNORE_STACK      0
 #define JSDVG_SEARCH_STACK      1
 
 /*
  * Get the length of variable-length bytecode like JSOP_TABLESWITCH.
  */
 extern size_t
 js_GetVariableBytecodeLength(jsbytecode *pc);
--- a/js/src/jsprf.h
+++ b/js/src/jsprf.h
@@ -22,18 +22,16 @@
 **      %p - pointer (deals with machine dependent pointer size)
 **      %f - float
 **      %g - float
 */
 #include "jstypes.h"
 #include <stdio.h>
 #include <stdarg.h>
 
-JS_BEGIN_EXTERN_C
-
 /*
 ** sprintf into a fixed size buffer. Guarantees that a NUL is at the end
 ** of the buffer. Returns the length of the written output, NOT including
 ** the NUL, or (uint32_t)-1 if an error occurs.
 */
 extern JS_PUBLIC_API(uint32_t) JS_snprintf(char *out, uint32_t outlen, const char *fmt, ...);
 
 /*
@@ -71,11 +69,9 @@ extern JS_PUBLIC_API(uint32_t) JS_sxprin
 /*
 ** va_list forms of the above.
 */
 extern JS_PUBLIC_API(uint32_t) JS_vsnprintf(char *out, uint32_t outlen, const char *fmt, va_list ap);
 extern JS_PUBLIC_API(char*) JS_vsmprintf(const char *fmt, va_list ap);
 extern JS_PUBLIC_API(char*) JS_vsprintf_append(char *last, const char *fmt, va_list ap);
 extern JS_PUBLIC_API(uint32_t) JS_vsxprintf(JSStuffFunc f, void *arg, const char *fmt, va_list ap);
 
-JS_END_EXTERN_C
-
 #endif /* jsprf_h___ */
--- a/js/src/jsproxy.h
+++ b/js/src/jsproxy.h
@@ -315,16 +315,12 @@ SetProxyExtra(RawObject obj, size_t n, c
 
 JS_FRIEND_API(JSObject *)
 NewProxyObject(JSContext *cx, BaseProxyHandler *handler, const Value &priv,
                JSObject *proto, JSObject *parent,
                JSObject *call = NULL, JSObject *construct = NULL);
 
 } /* namespace js */
 
-JS_BEGIN_EXTERN_C
-
 extern JS_FRIEND_API(JSObject *)
 js_InitProxyClass(JSContext *cx, JSHandleObject obj);
 
-JS_END_EXTERN_C
-
 #endif
--- a/js/src/jsprvtd.h
+++ b/js/src/jsprvtd.h
@@ -24,18 +24,16 @@
 #include "jsapi.h"
 #include "jsutil.h"
 
 #ifdef __cplusplus
 #include "js/HashTable.h"
 #include "js/Vector.h"
 #endif
 
-JS_BEGIN_EXTERN_C
-
 /*
  * Convenience constants.
  */
 #define JS_BITS_PER_UINT32_LOG2 5
 #define JS_BITS_PER_UINT32      32
 
 /* The alignment required of objects stored in GC arenas. */
 static const unsigned JS_GCTHING_ALIGN = 8;
@@ -374,11 +372,10 @@ typedef JSObject *
 
 /*
  * Hook that creates an iterator object for a given object. Returns the
  * iterator object or null if an error or exception was thrown on cx.
  */
 typedef JSObject *
 (* JSIteratorOp)(JSContext *cx, JSHandleObject obj, JSBool keysonly);
 
-JS_END_EXTERN_C
 
 #endif /* jsprvtd_h___ */
--- a/js/src/jspubtd.h
+++ b/js/src/jspubtd.h
@@ -55,18 +55,16 @@ struct jsid
 typedef ptrdiff_t jsid;
 #  define JSID_BITS(id) (id)
 # endif  /* defined(JS_USE_JSID_STRUCT_TYPES) */
 #else  /* defined(__cplusplus) */
 typedef ptrdiff_t jsid;
 # define JSID_BITS(id) (id)
 #endif
 
-JS_BEGIN_EXTERN_C
-
 #ifdef WIN32
 typedef wchar_t   jschar;
 #else
 typedef uint16_t  jschar;
 #endif
 
 /*
  * Run-time version enumeration.  See jsversion.h for compile-time counterparts
@@ -211,18 +209,16 @@ typedef struct JSString                 
 
 #ifdef JS_THREADSAFE
 typedef struct PRCallOnceType    JSCallOnceType;
 #else
 typedef JSBool                   JSCallOnceType;
 #endif
 typedef JSBool                 (*JSInitCallback)(void);
 
-JS_END_EXTERN_C
-
 #ifdef __cplusplus
 
 namespace js {
 
 template <typename T>
 class Rooted;
 
 class SkipRoot;
--- a/js/src/jsreflect.cpp
+++ b/js/src/jsreflect.cpp
@@ -3509,18 +3509,16 @@ reflect_parse(JSContext *cx, uint32_t ar
 }
 
 static JSFunctionSpec static_methods[] = {
     JS_FN("parse", reflect_parse, 1, 0),
     JS_FS_END
 };
 
 
-JS_BEGIN_EXTERN_C
-
 JS_PUBLIC_API(JSObject *)
 JS_InitReflect(JSContext *cx, JSObject *objArg)
 {
     RootedObject obj(cx, objArg);
     RootedObject Reflect(cx, NewObjectWithClassProto(cx, &ObjectClass, NULL, obj));
     if (!Reflect || !JSObject::setSingletonType(cx, Reflect))
         return NULL;
 
@@ -3529,10 +3527,8 @@ JS_InitReflect(JSContext *cx, JSObject *
         return NULL;
     }
 
     if (!JS_DefineFunctions(cx, Reflect, static_methods))
         return NULL;
 
     return Reflect;
 }
-
-JS_END_EXTERN_C
--- a/js/src/jstypes.h
+++ b/js/src/jstypes.h
@@ -176,18 +176,16 @@
 # if defined(__LP64__)
 #  define JS_64BIT
 # endif
 #else
 # error "Implement me"
 #endif
 
 
-JS_BEGIN_EXTERN_C
-
 /************************************************************************
 ** TYPES:       JSBool
 ** DESCRIPTION:
 **  Use JSBool for variables and parameter types. Use JS_FALSE and JS_TRUE
 **      for clarity of target type in assignments and actual arguments. Use
 **      'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans
 **      just as you would C int-valued conditions.
 ************************************************************************/
@@ -277,11 +275,9 @@ typedef int JSBool;
 #ifdef __GNUC__
 # define JS_EXTENSION __extension__
 # define JS_EXTENSION_(s) __extension__ ({ s; })
 #else
 # define JS_EXTENSION
 # define JS_EXTENSION_(s) s
 #endif
 
-JS_END_EXTERN_C
-
 #endif /* jstypes_h___ */
--- a/js/src/jsval.h
+++ b/js/src/jsval.h
@@ -9,18 +9,16 @@
 #define jsvalimpl_h__
 
 /*
  * Implementation details for js::Value in jsapi.h.
  */
 
 #include "js/Utility.h"
 
-JS_BEGIN_EXTERN_C
-
 /*
  * Try to get jsvals 64-bit aligned. We could almost assert that all values are
  * aligned, but MSVC and GCC occasionally break alignment.
  */
 #if defined(__GNUC__) || defined(__xlc__) || defined(__xlC__)
 # define JSVAL_ALIGNMENT        __attribute__((aligned (8)))
 #elif defined(_MSC_VER)
   /*
@@ -830,16 +828,14 @@ JS_CANONICALIZE_NAN(double d)
     if (JS_UNLIKELY(d != d)) {
         jsval_layout l;
         l.asBits = 0x7FF8000000000000LL;
         return l.asDouble;
     }
     return d;
 }
 
-JS_END_EXTERN_C
-
 #ifdef __cplusplus
 static jsval_layout JSVAL_TO_IMPL(JS::Value);
 static JS::Value IMPL_TO_JSVAL(jsval_layout);
 #endif
 
 #endif /* jsvalimpl_h__ */
--- a/js/src/prmjtime.h
+++ b/js/src/prmjtime.h
@@ -78,18 +78,16 @@ class DSTOffsetCache {
     static const int64_t SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR;
 
     static const int64_t RANGE_EXPANSION_AMOUNT = 30 * SECONDS_PER_DAY;
 
   private:
     void sanityCheck();
 };
 
-JS_BEGIN_EXTERN_C
-
 typedef struct PRMJTime       PRMJTime;
 
 /*
  * Broken down form of 64 bit time value.
  */
 struct PRMJTime {
     int32_t tm_usec;            /* microseconds of second (0-999999) */
     int8_t tm_sec;              /* seconds of minute (0-59) */
@@ -122,12 +120,10 @@ PRMJ_NowShutdown(void);
 /* get the difference between this time zone and  gmt timezone in seconds */
 extern int32_t
 PRMJ_LocalGMTDifference(void);
 
 /* Format a time value into a buffer. Same semantics as strftime() */
 extern size_t
 PRMJ_FormatTime(char *buf, int buflen, const char *fmt, PRMJTime *tm);
 
-JS_END_EXTERN_C
-
 #endif /* prmjtime_h___ */