[gjs] Remove most uses of gjs_runtime_get_context



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

    Remove most uses of gjs_runtime_get_context
    
    Most of these are unnecessary, and we can't support a 1:1 runtime/context
    mapping if we have more than one context.
    
    The one leftover use of gjs_runtime_get_context is in object.cpp and it
    requires a patch to gobject to fix properly.

 gi/closure.cpp  |    8 ++++----
 gi/closure.h    |    2 +-
 gi/function.cpp |    8 +++-----
 gi/function.h   |    2 +-
 gi/value.cpp    |    4 +---
 5 files changed, 10 insertions(+), 14 deletions(-)
---
diff --git a/gi/closure.cpp b/gi/closure.cpp
index e780739..6ec9a51 100644
--- a/gi/closure.cpp
+++ b/gi/closure.cpp
@@ -265,7 +265,7 @@ gjs_closure_invoke(GClosure *closure,
         return;
     }
 
-    context = gjs_runtime_get_context(c->runtime);
+    context = c->context;
     JS_BeginRequest(context);
     global = JS_GetGlobalObject(context);
     JSAutoCompartment ac(context, global);
@@ -309,14 +309,14 @@ gjs_closure_is_valid(GClosure *closure)
     return c->context != NULL;
 }
 
-JSRuntime*
-gjs_closure_get_runtime(GClosure *closure)
+JSContext*
+gjs_closure_get_context(GClosure *closure)
 {
     Closure *c;
 
     c = (Closure*) closure;
 
-    return c->runtime;
+    return c->context;
 }
 
 JSObject*
diff --git a/gi/closure.h b/gi/closure.h
index 8158455..506178a 100644
--- a/gi/closure.h
+++ b/gi/closure.h
@@ -38,7 +38,7 @@ void       gjs_closure_invoke        (GClosure     *closure,
                                       int           argc,
                                       jsval        *argv,
                                       jsval        *retval);
-JSRuntime* gjs_closure_get_runtime   (GClosure     *closure);
+JSContext* gjs_closure_get_context   (GClosure     *closure);
 gboolean   gjs_closure_is_valid      (GClosure     *closure);
 JSObject*  gjs_closure_get_callable  (GClosure     *closure);
 
diff --git a/gi/function.cpp b/gi/function.cpp
index c574af6..7800cf2 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -78,9 +78,7 @@ gjs_callback_trampoline_unref(GjsCallbackTrampoline *trampoline)
 
     trampoline->ref_count--;
     if (trampoline->ref_count == 0) {
-        JSContext *context;
-
-        context = gjs_runtime_get_context(trampoline->runtime);
+        JSContext *context = trampoline->context;
 
         if (!trampoline->is_vfunc) {
             JS_BeginRequest(context);
@@ -181,7 +179,7 @@ gjs_callback_closure(ffi_cif *cif,
     g_assert(trampoline);
     gjs_callback_trampoline_ref(trampoline);
 
-    context = gjs_runtime_get_context(trampoline->runtime);
+    context = trampoline->context;
     JS_BeginRequest(context);
     global = JS_GetGlobalObject(context);
     JSAutoCompartment ac(context, global);
@@ -412,7 +410,7 @@ gjs_callback_trampoline_new(JSContext      *context,
 
     trampoline = g_slice_new(GjsCallbackTrampoline);
     trampoline->ref_count = 1;
-    trampoline->runtime = JS_GetRuntime(context);
+    trampoline->context = context;
     trampoline->info = callable_info;
     g_base_info_ref((GIBaseInfo*)trampoline->info);
     trampoline->js_function = function;
diff --git a/gi/function.h b/gi/function.h
index fa2f485..9b77f0a 100644
--- a/gi/function.h
+++ b/gi/function.h
@@ -42,7 +42,7 @@ typedef enum {
 
 typedef struct {
     gint ref_count;
-    JSRuntime *runtime;
+    JSContext *context;
     GICallableInfo *info;
     jsval js_function;
     ffi_cif cif;
diff --git a/gi/value.cpp b/gi/value.cpp
index 475fc90..dcde4aa 100644
--- a/gi/value.cpp
+++ b/gi/value.cpp
@@ -55,7 +55,6 @@ closure_marshal(GClosure        *closure,
                 gpointer         invocation_hint,
                 gpointer         marshal_data)
 {
-    JSRuntime *runtime;
     JSContext *context;
     JSObject *global;
 
@@ -74,8 +73,7 @@ closure_marshal(GClosure        *closure,
         return;
     }
 
-    runtime = gjs_closure_get_runtime(closure);
-    context = gjs_runtime_get_context(runtime);
+    context = gjs_closure_get_context(closure);
     JS_BeginRequest(context);
     global = JS_GetGlobalObject(context);
     JSAutoCompartment ac(context, global);


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