[gjs: 2/3] js: Remove unnecessary property getters and setters



commit 78601c0c07f52eeee957ddba8b86c00a46ef6c73
Author: Philip Chimento <philip chimento gmail com>
Date:   Sun Dec 10 01:04:41 2017 -0800

    js: Remove unnecessary property getters and setters
    
    In SpiderMonkey 60, properties that have a value will not be able to have
    C++ getters and setters. The getters and setters are already unnecessary
    in all the cases where we use them, so just remove them.

 gjs/jsapi-dynamic-class.cpp |  7 +++----
 gjs/jsapi-util.cpp          | 24 ++++++++----------------
 gjs/jsapi-util.h            | 16 ++++------------
 modules/system.cpp          |  6 ++----
 4 files changed, 17 insertions(+), 36 deletions(-)
---
diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp
index aca46e5..b787a7b 100644
--- a/gjs/jsapi-dynamic-class.cpp
+++ b/gjs/jsapi-dynamic-class.cpp
@@ -121,18 +121,17 @@ gjs_init_class_dynamic(JSContext              *context,
         /* Have to fake it with JSPROP_RESOLVING, otherwise it will trigger
          * the resolve hook */
         if (!JS_DefineProperty(context, constructor, "prototype", prototype,
-                               JSPROP_PERMANENT | JSPROP_READONLY | JSPROP_RESOLVING,
-                               JS_STUBGETTER, JS_STUBSETTER))
+                               JSPROP_PERMANENT | JSPROP_READONLY | JSPROP_RESOLVING))
             goto out;
         if (!JS_DefineProperty(context, prototype, "constructor", constructor,
-                               JSPROP_RESOLVING, JS_STUBGETTER, JS_STUBSETTER))
+                               JSPROP_RESOLVING))
             goto out;
     }
 
     /* The constructor defined by JS_InitClass has no property attributes, but this
        is a more useful default for gjs */
     if (!JS_DefineProperty(context, in_object, class_name, constructor,
-                           GJS_MODULE_PROP_FLAGS, JS_STUBGETTER, JS_STUBSETTER))
+                           GJS_MODULE_PROP_FLAGS))
         goto out;
 
     res = true;
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 98fe035..816715b 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -85,13 +85,11 @@ gjs_object_define_property(JSContext       *cx,
                            JS::HandleObject obj,
                            GjsConstString   property_name,
                            JS::HandleValue  value,
-                           unsigned         flags,
-                           JSNative         getter,
-                           JSNative         setter)
+                           unsigned         flags)
 {
     return JS_DefinePropertyById(cx, obj,
                                  gjs_context_get_const_string(cx, property_name),
-                                 value, flags, getter, setter);
+                                 value, flags);
 }
 
 bool
@@ -99,13 +97,11 @@ gjs_object_define_property(JSContext       *cx,
                            JS::HandleObject obj,
                            GjsConstString   property_name,
                            JS::HandleObject value,
-                           unsigned         flags,
-                           JSNative         getter,
-                           JSNative         setter)
+                           unsigned         flags)
 {
     return JS_DefinePropertyById(cx, obj,
                                  gjs_context_get_const_string(cx, property_name),
-                                 value, flags, getter, setter);
+                                 value, flags);
 }
 
 bool
@@ -113,13 +109,11 @@ gjs_object_define_property(JSContext       *cx,
                            JS::HandleObject obj,
                            GjsConstString   property_name,
                            JS::HandleString value,
-                           unsigned         flags,
-                           JSNative         getter,
-                           JSNative         setter)
+                           unsigned         flags)
 {
     return JS_DefinePropertyById(cx, obj,
                                  gjs_context_get_const_string(cx, property_name),
-                                 value, flags, getter, setter);
+                                 value, flags);
 }
 
 bool
@@ -127,13 +121,11 @@ gjs_object_define_property(JSContext       *cx,
                            JS::HandleObject obj,
                            GjsConstString   property_name,
                            uint32_t         value,
-                           unsigned         flags,
-                           JSNative         getter,
-                           JSNative         setter)
+                           unsigned         flags)
 {
     return JS_DefinePropertyById(cx, obj,
                                  gjs_context_get_const_string(cx, property_name),
-                                 value, flags, getter, setter);
+                                 value, flags);
 }
 
 static void
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 18cd53e..e2d31f6 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -329,33 +329,25 @@ bool gjs_object_define_property(JSContext       *cx,
                                 JS::HandleObject obj,
                                 GjsConstString   property_name,
                                 JS::HandleValue  value,
-                                unsigned         flags,
-                                JSNative         getter = nullptr,
-                                JSNative         setter = nullptr);
+                                unsigned         flags);
 
 bool gjs_object_define_property(JSContext       *cx,
                                 JS::HandleObject obj,
                                 GjsConstString   property_name,
                                 JS::HandleObject value,
-                                unsigned         flags,
-                                JSNative         getter = nullptr,
-                                JSNative         setter = nullptr);
+                                unsigned         flags);
 
 bool gjs_object_define_property(JSContext       *cx,
                                 JS::HandleObject obj,
                                 GjsConstString   property_name,
                                 JS::HandleString value,
-                                unsigned         flags,
-                                JSNative         getter = nullptr,
-                                JSNative         setter = nullptr);
+                                unsigned         flags);
 
 bool gjs_object_define_property(JSContext       *cx,
                                 JS::HandleObject obj,
                                 GjsConstString   property_name,
                                 uint32_t         value,
-                                unsigned         flags,
-                                JSNative         getter = nullptr,
-                                JSNative         setter = nullptr);
+                                unsigned         flags);
 
 JS::HandleId gjs_context_get_const_string(JSContext     *cx,
                                           GjsConstString string);
diff --git a/modules/system.cpp b/modules/system.cpp
index 4480802..001e94e 100644
--- a/modules/system.cpp
+++ b/modules/system.cpp
@@ -204,14 +204,12 @@ gjs_js_define_system_stuff(JSContext              *context,
     if (!JS_DefineProperty(context, module,
                            "programInvocationName",
                            value,
-                           GJS_MODULE_PROP_FLAGS | JSPROP_READONLY,
-                           JS_STUBGETTER, JS_STUBSETTER))
+                           GJS_MODULE_PROP_FLAGS | JSPROP_READONLY))
         goto out;
 
     if (!JS_DefineProperty(context, module,
                            "version", GJS_VERSION,
-                           GJS_MODULE_PROP_FLAGS | JSPROP_READONLY,
-                           JS_STUBGETTER, JS_STUBSETTER))
+                           GJS_MODULE_PROP_FLAGS | JSPROP_READONLY))
         goto out;
 
     retval = true;


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