[gjs/wip/ptomato/mozjs45prep: 13/23] js: setProperty operations with triple result state



commit 41f35c68ea0b998edb141275338f9d0e52dac81c
Author: Philip Chimento <philip endlessm com>
Date:   Sun Mar 19 05:12:53 2017 +0000

    js: setProperty operations with triple result state

 gi/object.cpp     |   15 +++++----------
 gjs/byteArray.cpp |   12 ++++++------
 2 files changed, 11 insertions(+), 16 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 0679d53..4751329 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -498,7 +498,6 @@ static bool
 check_set_field_from_prop(JSContext             *cx,
                           ObjectInstance        *priv,
                           const char            *name,
-                          bool                   strict,
                           JS::MutableHandleValue value_p)
 {
     if (priv->info == NULL)
@@ -518,12 +517,6 @@ check_set_field_from_prop(JSContext             *cx,
         goto out;
     }
 
-    if (strict) {
-        gjs_throw(cx, "Tried to set read-only field %s in strict mode", name);
-        retval = false;
-        goto out;
-    }
-
     /* We have to update value_p because JS caches it as the property's "stored
      * value" 
(https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/Stored_value)
      * and so subsequent gets would get the stored value instead of accessing
@@ -542,8 +535,8 @@ static bool
 object_instance_set_prop(JSContext              *context,
                          JS::HandleObject        obj,
                          JS::HandleId            id,
-                         bool                    strict,
-                         JS::MutableHandleValue  value_p)
+                         JS::MutableHandleValue  value_p,
+                         JS::ObjectOpResult&     result)
 {
     ObjectInstance *priv;
     char *name;
@@ -569,7 +562,9 @@ object_instance_set_prop(JSContext              *context,
     if (g_param_was_set || !ret)
         goto out;
 
-    ret = check_set_field_from_prop(context, priv, name, strict, value_p);
+    ret = check_set_field_from_prop(context, priv, name, value_p);
+    if (ret)
+        ret = result.checkStrict(context, obj, id);
 
     /* note that the prop will also have been set in JS, which I think
      * is OK, since we hook get and set so will always override that
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index 5e86f0c..b51d42b 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -46,8 +46,8 @@ static bool   byte_array_get_prop      (JSContext    *context,
 static bool   byte_array_set_prop      (JSContext    *context,
                                         JS::HandleObject obj,
                                         JS::HandleId id,
-                                        bool                   strict,
-                                        JS::MutableHandleValue value_p);
+                                        JS::MutableHandleValue value_p,
+                                        JS::ObjectOpResult&    result);
 GJS_NATIVE_CONSTRUCTOR_DECLARE(byte_array);
 static void   byte_array_finalize      (JSFreeOp     *fop,
                                         JSObject     *obj);
@@ -59,8 +59,8 @@ struct JSClass gjs_byte_array_class = {
     JSCLASS_BACKGROUND_FINALIZE,
     NULL,  /* addProperty */
     NULL,  /* deleteProperty */
-    (JSPropertyOp)byte_array_get_prop,
-    (JSStrictPropertyOp)byte_array_set_prop,
+    byte_array_get_prop,
+    byte_array_set_prop,
     NULL,  /* enumerate */
     NULL,  /* resolve */
     NULL,  /* convert */
@@ -296,8 +296,8 @@ static bool
 byte_array_set_prop(JSContext *context,
                     JS::HandleObject obj,
                     JS::HandleId id,
-                    bool strict,
-                    JS::MutableHandleValue value_p)
+                    JS::MutableHandleValue value_p,
+                    JS::ObjectOpResult&    result)
 {
     ByteArrayInstance *priv;
 


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