[gjs/msvc.partial.fix: 1/2] gi/arg-cache.*: static_cast assignment to GjsArgumentFlags




commit 089b25130c2ea1f5391d84d3c4bea36b0f5d3a1a
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Mar 10 16:30:41 2021 +0800

    gi/arg-cache.*: static_cast assignment to GjsArgumentFlags
    
    This avoid using macros, suggested by Philip Chimento, and allowed a unified
    code base for different compilers.

 gi/arg-cache.cpp | 18 ++++++------------
 gi/arg-cache.h   |  3 +--
 2 files changed, 7 insertions(+), 14 deletions(-)
---
diff --git a/gi/arg-cache.cpp b/gi/arg-cache.cpp
index ec37543c..67175425 100644
--- a/gi/arg-cache.cpp
+++ b/gi/arg-cache.cpp
@@ -1249,8 +1249,7 @@ static const GjsArgumentMarshallers caller_allocates_out_marshallers = {
 
 static inline void gjs_arg_cache_set_skip_all(GjsArgumentCache* self) {
     self->marshallers = &skip_all_marshallers;
-    self->flags = CAST_WRAPPED_ENUM_T(GjsArgumentFlags,
-                                      GjsArgumentFlags::SKIP_IN | GjsArgumentFlags::SKIP_OUT);
+    self->flags = static_cast<GjsArgumentFlags>(GjsArgumentFlags::SKIP_IN | GjsArgumentFlags::SKIP_OUT);
 }
 
 bool gjs_arg_cache_build_return(JSContext*, GjsArgumentCache* self,
@@ -1297,8 +1296,7 @@ bool gjs_arg_cache_build_return(JSContext*, GjsArgumentCache* self,
 
     // marshal_in is ignored for the return value, but skip_in is not (it is
     // used in the failure release path)
-    self->flags = CAST_WRAPPED_ENUM_T(GjsArgumentFlags,
-                                      self->flags | GjsArgumentFlags::SKIP_IN);
+    self->flags = static_cast<GjsArgumentFlags>(self->flags | GjsArgumentFlags::SKIP_IN);
     self->marshallers = &return_value_marshallers;
 
     return true;
@@ -1328,11 +1326,9 @@ static void gjs_arg_cache_build_enum_bounds(GjsArgumentCache* self,
     self->contents.enum_type.enum_max = static_cast<uint32_t>(max);
 
     if (min >= 0 && max > std::numeric_limits<int32_t>::max())
-        self->flags = CAST_WRAPPED_ENUM_T(GjsArgumentFlags,
-                                          self->flags | GjsArgumentFlags::UNSIGNED);
+        self->flags = static_cast<GjsArgumentFlags>(self->flags | GjsArgumentFlags::UNSIGNED);
     else
-        self->flags = CAST_WRAPPED_ENUM_T(GjsArgumentFlags,
-                                          self->flags & ~GjsArgumentFlags::UNSIGNED);
+        self->flags = static_cast<GjsArgumentFlags>(self->flags & ~GjsArgumentFlags::UNSIGNED);
 }
 
 static void gjs_arg_cache_build_flags_mask(GjsArgumentCache* self,
@@ -1551,8 +1547,7 @@ static bool gjs_arg_cache_build_normal_in_arg(JSContext* cx,
                 self->marshallers = &string_in_transfer_none_marshallers;
             else
                 self->marshallers = &string_in_marshallers;
-            self->flags = CAST_WRAPPED_ENUM_T(GjsArgumentFlags,
-                                              self->flags | GjsArgumentFlags::FILENAME);
+            self->flags = static_cast<GjsArgumentFlags>(self->flags | GjsArgumentFlags::FILENAME);
             break;
 
         case GI_TYPE_TAG_UTF8:
@@ -1560,8 +1555,7 @@ static bool gjs_arg_cache_build_normal_in_arg(JSContext* cx,
                 self->marshallers = &string_in_transfer_none_marshallers;
             else
                 self->marshallers = &string_in_marshallers;
-            self->flags = CAST_WRAPPED_ENUM_T(GjsArgumentFlags,
-                                              self->flags & ~GjsArgumentFlags::FILENAME);
+            self->flags = static_cast<GjsArgumentFlags>(self->flags & ~GjsArgumentFlags::FILENAME);
             break;
 
         case GI_TYPE_TAG_INTERFACE: {
diff --git a/gi/arg-cache.h b/gi/arg-cache.h
index e6a154bf..97648577 100644
--- a/gi/arg-cache.h
+++ b/gi/arg-cache.h
@@ -122,8 +122,7 @@ struct GjsArgumentCache {
         arg_name = "instance parameter";
         // Some calls accept null for the instance, but generally in an object
         // oriented language it's wrong to call a method on null
-        flags = CAST_WRAPPED_ENUM_T(GjsArgumentFlags,
-                                    GjsArgumentFlags::NONE | GjsArgumentFlags::SKIP_OUT);
+        flags = static_cast<GjsArgumentFlags>(GjsArgumentFlags::NONE | GjsArgumentFlags::SKIP_OUT);
     }
 
     void set_return_value() {


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