[gjs] jsapi-util: Remove the GError argument from gjs_eval_with_scope



commit b2acc3afa9c6d5c7098b20a795c172227c4ddf30
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Jan 15 11:02:57 2014 -0500

    jsapi-util: Remove the GError argument from gjs_eval_with_scope

 gjs/byteArray.cpp  |    2 +-
 gjs/context.cpp    |    8 +++++++-
 gjs/importer.cpp   |    2 +-
 gjs/jsapi-util.cpp |   26 +++++++-------------------
 gjs/jsapi-util.h   |    3 +--
 5 files changed, 17 insertions(+), 24 deletions(-)
---
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index 07f0550..128b15f 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -772,7 +772,7 @@ byte_array_ensure_initialized (JSContext *context)
     if (g_once_init_enter (&initialized)) {
         gjs_eval_with_scope(context, NULL,
                             "imports.byteArray.ByteArray;", 27,
-                            "<internal>", NULL, NULL);
+                            "<internal>", NULL);
         g_once_init_leave (&initialized, 1);
     }
 }
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 5949b10..591a25d 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -765,8 +765,14 @@ gjs_context_eval(GjsContext   *js_context,
     if (!gjs_eval_with_scope(js_context->context,
                              js_context->global,
                              script, script_len, filename,
-                             &retval, error))
+                             &retval)) {
+        gjs_log_exception(js_context->context);
+        g_set_error(error,
+                    GJS_ERROR,
+                    GJS_ERROR_FAILED,
+                    "JS_EvaluateScript() failed");
         goto out;
+    }
 
     if (exit_status_p) {
         if (JSVAL_IS_INT(retval)) {
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index 55a1c4b..a76986f 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -286,7 +286,7 @@ import_file(JSContext  *context,
     full_path = g_file_get_parse_name (file);
 
     if (!gjs_eval_with_scope(context, module_obj, script, script_len,
-                             full_path, NULL, NULL))
+                             full_path, NULL))
         goto out;
 
     ret = JS_TRUE;
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 049f58a..7621e74 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -1226,11 +1226,10 @@ gjs_eval_with_scope(JSContext    *context,
                     const char   *script,
                     gssize        script_len,
                     const char   *filename,
-                    jsval        *retval_p,
-                    GError      **error)
+                    jsval        *retval_p)
 {
     JSBool ret = JS_FALSE;
-    int start_line_number;
+    int start_line_number = 1;
     jsval retval = JSVAL_VOID;
 
     if (script_len < 0)
@@ -1263,29 +1262,18 @@ gjs_eval_with_scope(JSContext    *context,
 
     js::RootedObject rootedObj(context, object);
 
-    if (!JS::Evaluate(context, rootedObj, options, script, script_len, &retval)) {
-        gjs_debug(GJS_DEBUG_CONTEXT,
-                  "Script evaluation failed");
+    if (!JS::Evaluate(context, rootedObj, options, script, script_len, &retval))
+        goto out;
 
-        gjs_log_exception(context);
-        g_set_error(error,
-                    GJS_ERROR,
-                    GJS_ERROR_FAILED,
-                    "JS_EvaluateScript() failed");
+    if (JS_IsExceptionPending(context)) {
+        g_warning("EvaluateScript returned JS_TRUE but exception was pending; "
+                  "did somebody call gjs_throw() without returning JS_FALSE?");
         goto out;
     }
 
     gjs_debug(GJS_DEBUG_CONTEXT,
               "Script evaluation succeeded");
 
-    if (gjs_log_exception(context)) {
-        g_set_error(error,
-                    GJS_ERROR,
-                    GJS_ERROR_FAILED,
-                    "Exception was set even though JS_EvaluateScript() returned true - did you gjs_throw() 
but not return false somewhere perhaps?");
-        goto out;
-    }
-
     ret = JS_TRUE;
     if (retval_p)
         *retval_p = retval;
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 880eb92..15701cc 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -382,8 +382,7 @@ JSBool            gjs_eval_with_scope        (JSContext    *context,
                                               const char   *script,
                                               gssize        script_len,
                                               const char   *filename,
-                                              jsval        *retval_p,
-                                              GError      **error);
+                                              jsval        *retval_p);
 
 typedef enum {
   GJS_STRING_CONSTRUCTOR,


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