[gjs] Add a wrapper for JS_GetGlobalObject



commit 4ce69bc02d8022568007c1941abb3bdca4065029
Author: Tim Lunn <tim feathertop org>
Date:   Sat Sep 28 10:06:20 2013 +1000

    Add a wrapper for JS_GetGlobalObject
    
    Context global object is only available through a private api now, create a wrapper that emulates the
    old api. Context globals will be going away in the future.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711046

 gjs/compat.h          |    2 ++
 gjs/jsapi-private.cpp |    5 +++++
 gjs/jsapi-util.h      |    1 +
 3 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/gjs/compat.h b/gjs/compat.h
index 971899b..b5b617f 100644
--- a/gjs/compat.h
+++ b/gjs/compat.h
@@ -51,6 +51,8 @@ G_BEGIN_DECLS
 
 #define JSVAL_IS_OBJECT(obj) (JSVAL_IS_NULL(obj) || !JSVAL_IS_PRIMITIVE(obj))
 
+#define JS_GetGlobalObject(cx) gjs_get_global_object(cx)
+
 static JSBool G_GNUC_UNUSED JS_NewNumberValue(JSContext *cx, double d, jsval *rval)
     {
         *rval = JS_NumberValue(d);
diff --git a/gjs/jsapi-private.cpp b/gjs/jsapi-private.cpp
index 9950ecd..d7713f6 100644
--- a/gjs/jsapi-private.cpp
+++ b/gjs/jsapi-private.cpp
@@ -75,3 +75,8 @@ gjs_error_reporter(JSContext     *context,
 
     g_log(G_LOG_DOMAIN, level, "JS %s: [%s %d]: %s", warning, report->filename, report->lineno, message);
 }
+
+JSObject *
+gjs_get_global_object(JSContext *cx){
+    return js::GetDefaultGlobalForContext(cx);
+}
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 3b026ad..a828873 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -283,6 +283,7 @@ JSBool      gjs_call_function_value          (JSContext       *context,
 void        gjs_error_reporter               (JSContext       *context,
                                               const char      *message,
                                               JSErrorReport   *report);
+JSObject*   gjs_get_global_object            (JSContext *cx);
 JSBool      gjs_get_prop_verbose_stub        (JSContext       *context,
                                               JSObject        *obj,
                                               jsval            id,


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