Bug 807179 - Add a constructor for JSPropertyDescriptor. r=luke
authorBobby Holley <bobbyholley@gmail.com>
Mon, 05 Nov 2012 17:49:44 -0800
changeset 112373 e5b6c62c62ad6cda5a3bb331bbfda3cfbc4858dc
parent 112372 0aa8d7cd5b8f3d697a0d334713e96a1bcf5a99bd
child 112374 f54fd962cf8714c8a58c791cbba83bfc752abbb6
push id23812
push useremorley@mozilla.com
push dateTue, 06 Nov 2012 14:01:34 +0000
treeherdermozilla-central@f4aeed115e54 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs807179
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 807179 - Add a constructor for JSPropertyDescriptor. r=luke
js/src/jsapi.h
js/xpconnect/wrappers/AccessCheck.cpp
js/xpconnect/wrappers/ChromeObjectWrapper.cpp
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -4408,16 +4408,20 @@ JS_LookupPropertyWithFlagsById(JSContext
 
 struct JSPropertyDescriptor {
     JSObject           *obj;
     unsigned           attrs;
     unsigned           shortid;
     JSPropertyOp       getter;
     JSStrictPropertyOp setter;
     jsval              value;
+
+    JSPropertyDescriptor() : obj(NULL), attrs(0), shortid(0), getter(NULL),
+                             setter(NULL), value(JSVAL_VOID)
+    {}
 };
 
 /*
  * Like JS_GetPropertyAttrsGetterAndSetterById but will return a property on
  * an object on the prototype chain (returned in objp). If data->obj is null,
  * then this property was not found on the prototype chain.
  */
 extern JS_PUBLIC_API(JSBool)
--- a/js/xpconnect/wrappers/AccessCheck.cpp
+++ b/js/xpconnect/wrappers/AccessCheck.cpp
@@ -409,17 +409,16 @@ ExposedPropertiesOnly::check(JSContext *
         return false;
     }
 
     JSObject *hallpass = &exposedProps.toObject();
 
     Access access = NO_ACCESS;
 
     JSPropertyDescriptor desc;
-    memset(&desc, 0, sizeof(desc));
     if (!JS_GetPropertyDescriptorById(cx, hallpass, id, JSRESOLVE_QUALIFIED, &desc)) {
         return false; // Error
     }
     if (!desc.obj || !(desc.attrs & JSPROP_ENUMERATE))
         return false;
 
     if (!JSVAL_IS_STRING(desc.value)) {
         JS_ReportError(cx, "property must be a string");
--- a/js/xpconnect/wrappers/ChromeObjectWrapper.cpp
+++ b/js/xpconnect/wrappers/ChromeObjectWrapper.cpp
@@ -67,32 +67,30 @@ ChromeObjectWrapper::has(JSContext *cx, 
     if (!JS_GetPrototype(cx, wrapper, &wrapperProto))
 	return false;
     if (*bp || !wrapperProto)
         return true;
 
     // Try the prototype if that failed.
     MOZ_ASSERT(js::IsObjectInContextCompartment(wrapper, cx));
     JSPropertyDescriptor desc;
-    memset(&desc, 0, sizeof(desc));
     if (!JS_GetPropertyDescriptorById(cx, wrapperProto, id, 0, &desc))
         return false;
     *bp = !!desc.obj;
     return true;
 }
 
 bool
 ChromeObjectWrapper::get(JSContext *cx, JSObject *wrapper, JSObject *receiver,
                          jsid id, js::Value *vp)
 {
     // Start with a call to getPropertyDescriptor. We unfortunately need to do
     // this because the call signature of ::get doesn't give us any way to
     // determine the object upon which the property was found.
     JSPropertyDescriptor desc;
-    memset(&desc, 0, sizeof(desc));
     if (!ChromeObjectWrapperBase::getPropertyDescriptor(cx, wrapper, id, false,
                                                         &desc)) {
         return false;
     }
 
     // Only call through to the get trap on the underlying object if we'll find
     // something, and if what we'll find is not on a standard prototype.
     vp->setUndefined();