[gjs/wip/xulrunner-1.9.3-rebase2: 8/8] xulrunner 1.9.3: Drop use of JS_PushArgumentsVA



commit d9ba5d4bbb06f4740cf763a2cefdd5eb321f2380
Author: Maxim Ermilov <zaspire rambler ru>
Date:   Sat Sep 18 16:41:12 2010 -0400

    xulrunner 1.9.3: Drop use of JS_PushArgumentsVA
    
    It was removed in 1.9.3; since it was only used in one
    function, inline the single caller.
    
    Separated from a larger patch and refactored by
    Colin Walters <walters verbum org>

 gi/closure.c       |   39 ---------------------------------------
 gi/closure.h       |    5 -----
 modules/debugger.c |   43 +++++++++++++++++++++++++++++++++++--------
 3 files changed, 35 insertions(+), 52 deletions(-)
---
diff --git a/gi/closure.c b/gi/closure.c
index 68a7d4c..289538c 100644
--- a/gi/closure.c
+++ b/gi/closure.c
@@ -286,45 +286,6 @@ gjs_closure_invoke(GClosure *closure,
     JS_EndRequest(context);
 }
 
-gboolean
-gjs_closure_invoke_simple(JSContext   *context,
-                          GClosure    *closure,
-                          jsval       *retval,
-                          const gchar *format,
-                          ...)
-{
-    va_list ap;
-    int argc;
-    void *stack_space;
-    jsval *argv;
-    int i;
-
-    JS_BeginRequest(context);
-
-    va_start(ap, format);
-    argv = JS_PushArgumentsVA(context, &stack_space, format, ap);
-    va_end(ap);
-    if (!argv)
-        return FALSE;
-
-    argc = (int)strlen(format);
-    for (i = 0; i < argc; i++)
-        JS_AddValueRoot(context, &argv[i]);
-    JS_AddValueRoot(context, retval);
-
-    gjs_closure_invoke(closure, argc, argv, retval);
-
-    for (i = 0; i < argc; i++)
-        JS_RemoveValueRoot(context, &argv[i]);
-    JS_RemoveValueRoot(context, retval);
-
-    JS_PopArguments(context, stack_space);
-
-    JS_EndRequest(context);
-
-    return TRUE;
-}
-
 JSContext*
 gjs_closure_get_context(GClosure *closure)
 {
diff --git a/gi/closure.h b/gi/closure.h
index 0a4c1a4..1ec452c 100644
--- a/gi/closure.h
+++ b/gi/closure.h
@@ -37,11 +37,6 @@ void       gjs_closure_invoke        (GClosure     *closure,
                                       int           argc,
                                       jsval        *argv,
                                       jsval        *retval);
-gboolean   gjs_closure_invoke_simple (JSContext    *context,
-                                      GClosure     *closure,
-                                      jsval        *retval,
-                                      const gchar  *format,
-                                      ...);
 JSContext* gjs_closure_get_context   (GClosure     *closure);
 JSObject*  gjs_closure_get_callable  (GClosure     *closure);
 
diff --git a/modules/debugger.c b/modules/debugger.c
index b2c60a5..da48ee1 100644
--- a/modules/debugger.c
+++ b/modules/debugger.c
@@ -48,15 +48,18 @@ gjs_debugger_debug_error_hook(JSContext     *context,
                               void          *user_data)
 {
     const char *filename = NULL;
-    static gboolean running = FALSE;
+    static gboolean recursion_guard = FALSE;
     guint line = 0, pos = 0, flags = 0, errnum = 0;
     jsval retval = JSVAL_NULL, exc;
     GClosure *closure = (GClosure*)user_data;
+    jsval argv[7];
+    JSString *str;
+    int i;
 
-    if (running)
+    if (recursion_guard)
         return JS_FALSE;
 
-    running = TRUE;
+    recursion_guard = TRUE;
     if (report) {
         filename = report->filename;
         line = report->lineno;
@@ -71,12 +74,36 @@ gjs_debugger_debug_error_hook(JSContext     *context,
         exc = JSVAL_NULL;
     }
 
-    if (!gjs_closure_invoke_simple(context, closure, &retval, "ssiiiiv",
-                                   message, filename, line, pos,
-                                   flags, errnum, exc))
-        return JS_FALSE;
-
-    running = FALSE;
+    str = JS_NewStringCopyZ(context, message);
+    if (!str)
+        goto out;
+    argv[0] = STRING_TO_JSVAL(str);
+    str = JS_NewStringCopyZ(context, filename);
+    if (!str)
+        goto out;
+    argv[1] = STRING_TO_JSVAL(str);
+    if (!JS_NewNumberValue(context, line, &argv[2]))
+        goto out;
+    if (!JS_NewNumberValue(context, pos, &argv[3]))
+        goto out;
+    if (!JS_NewNumberValue(context, flags, &argv[4]))
+        goto out;
+    if (!JS_NewNumberValue(context, errnum, &argv[5]))
+        goto out;
+    argv[6] = exc;
+
+    for (i = 0; i < 7; i++)
+        JS_AddValueRoot(context, &argv[i]);
+    JS_AddValueRoot(context, &retval);
+
+    gjs_closure_invoke(closure, 7, argv, &retval);
+
+ out:
+    for (i = 0; i < 7; i++)
+        JS_RemoveValueRoot(context, &argv[i]);
+    JS_RemoveValueRoot(context, &retval);
+
+    recursion_guard = FALSE;
     return JS_TRUE;
 }
 



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