[gjs] byteArray: Remove prototype checks from func implementations



commit cd83effd8d225236e837c120f67149fb5873cc37
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Jan 2 18:55:46 2013 -0500

    byteArray: Remove prototype checks from func implementations
    
    As we don't use JSCLASS_CONSTRUCT_PROTOTYPE anymore, we don't
    have a private on the prototype, which means that all instances
    of a NULL priv are the prototype. As far as I can tell, the
    "wrong class" case is impossible, as all of these functions
    are only installed on an object with a JSClass of ByteArray.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=690982

 gjs/byteArray.c |   16 +++-------------
 1 files changed, 3 insertions(+), 13 deletions(-)
---
diff --git a/gjs/byteArray.c b/gjs/byteArray.c
index 38ab65d..278c411 100644
--- a/gjs/byteArray.c
+++ b/gjs/byteArray.c
@@ -216,8 +216,6 @@ byte_array_get_prop(JSContext *context,
     priv = priv_from_js(context, obj);
 
     if (priv == NULL)
-        return JS_FALSE; /* wrong class passed in */
-    if (priv->array == NULL && priv->bytes == NULL)
         return JS_TRUE; /* prototype, not an instance. */
 
     if (!JS_IdToValue(context, id, &id_value))
@@ -250,8 +248,6 @@ byte_array_length_getter(JSContext *context,
     priv = priv_from_js(context, obj);
 
     if (priv == NULL)
-        return JS_FALSE; /* wrong class passed in */
-    if (priv->array == NULL && priv->bytes == NULL)
         return JS_TRUE; /* prototype, not an instance. */
 
     if (priv->array != NULL)
@@ -274,9 +270,7 @@ byte_array_length_setter(JSContext *context,
     priv = priv_from_js(context, obj);
 
     if (priv == NULL)
-        return JS_FALSE; /* wrong class passed in */
-    if (priv->array == NULL && priv->bytes == NULL)
-        return JS_TRUE; /* prototype, not an instance. */
+        return JS_TRUE; /* prototype, not instance */
 
     byte_array_ensure_array(priv);
 
@@ -338,8 +332,6 @@ byte_array_set_prop(JSContext *context,
     priv = priv_from_js(context, obj);
 
     if (priv == NULL)
-        return JS_FALSE; /* wrong class passed in */
-    if (priv->array == NULL && priv->bytes == NULL)
         return JS_TRUE; /* prototype, not an instance. */
 
     if (!JS_IdToValue(context, id, &id_value))
@@ -395,8 +387,6 @@ byte_array_new_resolve(JSContext *context,
     priv = priv_from_js(context, *objp);
 
     if (priv == NULL)
-        return JS_FALSE; /* wrong class passed in */
-    if (priv->array == NULL && priv->bytes == NULL)
         return JS_TRUE; /* prototype, not an instance. */
 
     if (!JS_IdToValue(context, id, &id_val))
@@ -524,7 +514,7 @@ to_string_func(JSContext *context,
     priv = priv_from_js(context, object);
 
     if (priv == NULL)
-        return JS_FALSE; /* wrong class passed in */
+        return JS_TRUE; /* prototype, not instance */
 
     byte_array_ensure_array(priv);
 
@@ -620,7 +610,7 @@ to_gbytes_func(JSContext *context,
 
     priv = priv_from_js(context, object);
     if (priv == NULL)
-        return JS_FALSE; /* wrong class passed in */
+        return JS_TRUE; /* prototype, not instance */
     
     byte_array_ensure_gbytes(priv);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]