Bug 1306538 - Move js::ReportASCIIErrorWithId to AddonWrapper.cpp. r=arai
authorPawan Sasanka <pass2pawan@gmail.com>
Tue, 13 Dec 2016 14:57:21 +0530
changeset 325855 3561e1497acf6a3288d5a31cc832868d24d3b02d
parent 325854 95e969c0031714d2f6538afbc0cc5e55c203cd35
child 325856 1fd906e69d3572e0f37a16e3ffee139a7b952096
push id31076
push usercbook@mozilla.com
push dateWed, 14 Dec 2016 15:41:53 +0000
treeherdermozilla-central@18b5a7a5d833 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1306538
milestone53.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 1306538 - Move js::ReportASCIIErrorWithId to AddonWrapper.cpp. r=arai
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
js/xpconnect/wrappers/AddonWrapper.cpp
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -1336,31 +1336,16 @@ js::GetAllocationMetadata(JSObject* obj)
 }
 
 JS_FRIEND_API(bool)
 js::ReportIsNotFunction(JSContext* cx, HandleValue v)
 {
     return ReportIsNotFunction(cx, v, -1);
 }
 
-JS_FRIEND_API(void)
-js::ReportASCIIErrorWithId(JSContext* cx, const char* msg, HandleId id)
-{
-    RootedValue idv(cx);
-    if (!JS_IdToValue(cx, id, &idv))
-        return;
-    RootedString idstr(cx, JS::ToString(cx, idv));
-    if (!idstr)
-        return;
-    JSAutoByteString bytes;
-    if (!bytes.encodeUtf8(cx, idstr))
-        return;
-    JS_ReportErrorUTF8(cx, msg, bytes.ptr());
-}
-
 #ifdef DEBUG
 bool
 js::HasObjectMovedOp(JSObject* obj) {
     return !!GetObjectClass(obj)->extObjectMovedOp();
 }
 #endif
 
 JS_FRIEND_API(bool)
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -2768,19 +2768,16 @@ ForwardToNative(JSContext* cx, JSNative 
  * Implemented in proxy/BaseProxyHandler.cpp.
  */
 JS_FRIEND_API(bool)
 SetPropertyIgnoringNamedGetter(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
                                JS::HandleValue v, JS::HandleValue receiver,
                                JS::Handle<JS::PropertyDescriptor> ownDesc,
                                JS::ObjectOpResult& result);
 
-JS_FRIEND_API(void)
-ReportASCIIErrorWithId(JSContext* cx, const char* msg, JS::HandleId id);
-
 // This function is for one specific use case, please don't use this for anything else!
 extern JS_FRIEND_API(bool)
 ExecuteInGlobalAndReturnScope(JSContext* cx, JS::HandleObject obj, JS::HandleScript script,
                               JS::MutableHandleObject scope);
 
 #if defined(XP_WIN) && defined(_WIN64)
 // Parameters use void* types to avoid #including windows.h. The return value of
 // this function is returned from the exception handler.
--- a/js/xpconnect/wrappers/AddonWrapper.cpp
+++ b/js/xpconnect/wrappers/AddonWrapper.cpp
@@ -18,16 +18,31 @@
 
 #include "nsID.h"
 
 using namespace js;
 using namespace JS;
 
 namespace xpc {
 
+static inline void
+ReportASCIIErrorWithId(JSContext* cx, const char* msg, HandleId id)
+{
+    RootedValue idv(cx);
+    if (!JS_IdToValue(cx, id, &idv))
+        return;
+    RootedString idstr(cx, JS::ToString(cx, idv));
+    if (!idstr)
+        return;
+    JSAutoByteString bytes;
+    if (!bytes.encodeUtf8(cx, idstr))
+        return;
+    JS_ReportErrorUTF8(cx, msg, bytes.ptr());
+}
+
 bool
 InterposeProperty(JSContext* cx, HandleObject target, const nsIID* iid, HandleId id,
                   MutableHandle<PropertyDescriptor> descriptor)
 {
     // We only want to do interpostion on DOM instances and
     // wrapped natives.
     RootedObject unwrapped(cx, UncheckedUnwrap(target));
     const js::Class* clasp = js::GetObjectClass(unwrapped);
@@ -226,33 +241,33 @@ AddonWrapper<Base>::defineProperty(JSCon
 {
     Rooted<PropertyDescriptor> interpDesc(cx);
     if (!InterposeProperty(cx, wrapper, nullptr, id, &interpDesc))
         return false;
 
     if (!interpDesc.object())
         return Base::defineProperty(cx, wrapper, id, desc, result);
 
-    js::ReportASCIIErrorWithId(cx, "unable to modify interposed property %s", id);
+    ReportASCIIErrorWithId(cx, "unable to modify interposed property %s", id);
     return false;
 }
 
 template<typename Base>
 bool
 AddonWrapper<Base>::delete_(JSContext* cx, HandleObject wrapper, HandleId id,
                             ObjectOpResult& result) const
 {
     Rooted<PropertyDescriptor> desc(cx);
     if (!InterposeProperty(cx, wrapper, nullptr, id, &desc))
         return false;
 
     if (!desc.object())
         return Base::delete_(cx, wrapper, id, result);
 
-    js::ReportASCIIErrorWithId(cx, "unable to delete interposed property %s", id);
+    ReportASCIIErrorWithId(cx, "unable to delete interposed property %s", id);
     return false;
 }
 
 #define AddonWrapperCC AddonWrapper<CrossCompartmentWrapper>
 #define AddonWrapperXrayXPCWN AddonWrapper<PermissiveXrayXPCWN>
 #define AddonWrapperXrayDOM AddonWrapper<PermissiveXrayDOM>
 
 template<> const AddonWrapperCC AddonWrapperCC::singleton(0);