[gjs] fundamental: Root constructor name



commit 48dc12c0af0a0fd252e861ff11d822488eb16f63
Author: Philip Chimento <philip endlessm com>
Date:   Tue Feb 7 14:50:22 2017 -0800

    fundamental: Root constructor name
    
    This did not cause any problems so far, but we should be rooting the
    constructor name jsid output parameter while finding the correct jsid to
    fill it with.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779293

 gi/fundamental.cpp        |   10 +++++-----
 gjs/jsapi-util-string.cpp |   13 +++++--------
 2 files changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index 2a2d516..7a3b5ec 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -203,9 +203,9 @@ associate_js_instance_to_fundamental(JSContext       *context,
 
 /* Find the first constructor */
 static GIFunctionInfo *
-find_fundamental_constructor(JSContext    *context,
-                             GIObjectInfo *info,
-                             jsid         *constructor_name)
+find_fundamental_constructor(JSContext          *context,
+                             GIObjectInfo       *info,
+                             JS::MutableHandleId constructor_name)
 {
     int i, n_methods;
 
@@ -222,7 +222,7 @@ find_fundamental_constructor(JSContext    *context,
             const char *name;
 
             name = g_base_info_get_name((GIBaseInfo *) func_info);
-            *constructor_name = gjs_intern_string_to_id(context, name);
+            constructor_name.set(gjs_intern_string_to_id(context, name));
 
             return func_info;
         }
@@ -662,7 +662,7 @@ gjs_define_fundamental_class(JSContext              *context,
                              JS::MutableHandleObject prototype)
 {
     const char *constructor_name;
-    jsid js_constructor_name = JSID_VOID;
+    JS::RootedId js_constructor_name(context);
     JS::RootedObject parent_proto(context);
     Fundamental *priv;
     GType parent_gtype;
diff --git a/gjs/jsapi-util-string.cpp b/gjs/jsapi-util-string.cpp
index 3157ab9..c9776e5 100644
--- a/gjs/jsapi-util-string.cpp
+++ b/gjs/jsapi-util-string.cpp
@@ -394,14 +394,11 @@ gjs_unichar_from_string (JSContext *context,
 }
 
 jsid
-gjs_intern_string_to_id (JSContext  *context,
-                         const char *string)
+gjs_intern_string_to_id(JSContext  *cx,
+                        const char *string)
 {
-    JSString *str;
-    jsid id;
-    JS_BeginRequest(context);
-    str = JS_InternString(context, string);
-    id = INTERNED_STRING_TO_JSID(context, str);
-    JS_EndRequest(context);
+    JSAutoRequest ar(cx);
+    JS::RootedString str(cx, JS_InternString(cx, string));
+    JS::RootedId id(cx, INTERNED_STRING_TO_JSID(cx, str));
     return id;
 }


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