[gjs/master.windows: 12/18] gjs: Avoid ambiguity in smart pointers



commit dba6f0bd19671d1919f5d9a159e1fe3dff88cac5
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Feb 22 15:32:23 2019 +0800

    gjs: Avoid ambiguity in smart pointers
    
    Use the .get() accessor to be concrete enough about things so that
    we avoid the compiler complaining about ambguity.

 gi/arg.cpp            | 2 +-
 gi/object.cpp         | 7 +++----
 gjs/debugger.cpp      | 2 +-
 gjs/importer.cpp      | 2 +-
 gjs/jsapi-util-args.h | 4 ++--
 5 files changed, 8 insertions(+), 9 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 8ab18290..ea56457d 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -1592,7 +1592,7 @@ gjs_value_to_g_argument(JSContext      *context,
 
             GjsAutoBaseInfo interface_info =
                 g_type_info_get_interface(type_info);
-            g_assert(interface_info != NULL);
+            g_assert(interface_info);
 
             GIInfoType interface_type = g_base_info_get_type(interface_info);
             if (interface_type == GI_INFO_TYPE_ENUM ||
diff --git a/gi/object.cpp b/gi/object.cpp
index ce431f74..e9eba75a 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -658,7 +658,7 @@ bool ObjectPrototype::resolve_no_info(JSContext* cx, JS::HandleObject obj,
 
         GjsAutoFunctionInfo method_info =
             g_interface_info_find_method(iface_info, name);
-        if (method_info != NULL) {
+        if (method_info) {
             if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
                 if (!gjs_define_function(cx, obj, m_gtype, method_info)) {
                     g_free(interfaces);
@@ -760,8 +760,7 @@ bool ObjectPrototype::resolve_impl(JSContext* context, JS::HandleObject obj,
         bool defined_by_parent;
         GjsAutoVFuncInfo vfunc = find_vfunc_on_parents(
             m_info, name_without_vfunc_, &defined_by_parent);
-        if (vfunc != NULL) {
-
+        if (vfunc) {
             /* In the event that the vfunc is unchanged, let regular
              * prototypal inheritance take over. */
             if (defined_by_parent && is_vfunc_unchanged(vfunc)) {
@@ -2195,7 +2194,7 @@ bool ObjectPrototype::hook_up_vfunc_impl(JSContext* cx,
                          &field_info))
         return false;
 
-    if (field_info != NULL) {
+    if (field_info) {
         gint offset;
         gpointer method_ptr;
         GjsCallbackTrampoline *trampoline;
diff --git a/gjs/debugger.cpp b/gjs/debugger.cpp
index 47f6e921..43723829 100644
--- a/gjs/debugger.cpp
+++ b/gjs/debugger.cpp
@@ -97,7 +97,7 @@ static bool do_readline(JSContext* cx, unsigned argc, JS::Value* vp) {
             args.rval().setUndefined();
             return true;
         }
-    } while (line && line[0] == '\0');
+    } while (line && line.get()[0] == '\0');
 
     /* Add line to history and convert it to a JSString so that we can pass it
      * back as the return value */
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index aa6b80e9..d1178c2e 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -707,7 +707,7 @@ static bool importer_new_enumerate(JSContext* context, JS::HandleObject object,
             GjsAutoChar filename = g_file_get_basename(file);
 
             /* skip hidden files and directories (.svn, .git, ...) */
-            if (filename[0] == '.')
+            if (filename.get()[0] == '.')
                 continue;
 
             /* skip module init file */
diff --git a/gjs/jsapi-util-args.h b/gjs/jsapi-util-args.h
index b7a982d4..db9e40f2 100644
--- a/gjs/jsapi-util-args.h
+++ b/gjs/jsapi-util-args.h
@@ -399,8 +399,8 @@ GJS_JSAPI_RETURN_CONVENTION static bool gjs_parse_call_args(
     }
 
     GjsAutoStrv parts = g_strsplit(format, "|", 2);
-    fmt_required = parts[0];
-    fmt_optional = parts[1];  /* may be NULL */
+    fmt_required = parts.get()[0];
+    fmt_optional = parts.get()[1];  // may be NULL
 
     retval = parse_call_args_helper(cx, function_name, args,
                                     ignore_trailing_args, fmt_required,


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