[gjs/msvc.partial.fix: 3/3] arg-cache.*: Use the type cast macros as needed




commit 7269dedad46f44933cff73fc6421ddb4b9390f80
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Mar 8 17:01:31 2021 +0800

    arg-cache.*: Use the type cast macros as needed
    
    Use the macros we added in the previous commit so that we can still
    convert between the underlying type of a class enumeration to the class
    enumeration itself.

 gi/arg-cache.cpp | 18 ++++++++++++------
 gi/arg-cache.h   |  3 ++-
 2 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/gi/arg-cache.cpp b/gi/arg-cache.cpp
index 937f1ade..ec37543c 100644
--- a/gi/arg-cache.cpp
+++ b/gi/arg-cache.cpp
@@ -1249,7 +1249,8 @@ 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 = (GjsArgumentFlags::SKIP_IN | GjsArgumentFlags::SKIP_OUT);
+    self->flags = CAST_WRAPPED_ENUM_T(GjsArgumentFlags,
+                                      GjsArgumentFlags::SKIP_IN | GjsArgumentFlags::SKIP_OUT);
 }
 
 bool gjs_arg_cache_build_return(JSContext*, GjsArgumentCache* self,
@@ -1296,7 +1297,8 @@ 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 = (self->flags | GjsArgumentFlags::SKIP_IN);
+    self->flags = CAST_WRAPPED_ENUM_T(GjsArgumentFlags,
+                                      self->flags | GjsArgumentFlags::SKIP_IN);
     self->marshallers = &return_value_marshallers;
 
     return true;
@@ -1326,9 +1328,11 @@ 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 = (self->flags | GjsArgumentFlags::UNSIGNED);
+        self->flags = CAST_WRAPPED_ENUM_T(GjsArgumentFlags,
+                                          self->flags | GjsArgumentFlags::UNSIGNED);
     else
-        self->flags = (self->flags & ~GjsArgumentFlags::UNSIGNED);
+        self->flags = CAST_WRAPPED_ENUM_T(GjsArgumentFlags,
+                                          self->flags & ~GjsArgumentFlags::UNSIGNED);
 }
 
 static void gjs_arg_cache_build_flags_mask(GjsArgumentCache* self,
@@ -1547,7 +1551,8 @@ 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 = (self->flags | GjsArgumentFlags::FILENAME);
+            self->flags = CAST_WRAPPED_ENUM_T(GjsArgumentFlags,
+                                              self->flags | GjsArgumentFlags::FILENAME);
             break;
 
         case GI_TYPE_TAG_UTF8:
@@ -1555,7 +1560,8 @@ 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 = (self->flags & ~GjsArgumentFlags::FILENAME);
+            self->flags = CAST_WRAPPED_ENUM_T(GjsArgumentFlags,
+                                              self->flags & ~GjsArgumentFlags::FILENAME);
             break;
 
         case GI_TYPE_TAG_INTERFACE: {
diff --git a/gi/arg-cache.h b/gi/arg-cache.h
index 54159df9..e6a154bf 100644
--- a/gi/arg-cache.h
+++ b/gi/arg-cache.h
@@ -122,7 +122,8 @@ 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 = GjsArgumentFlags::NONE | GjsArgumentFlags::SKIP_OUT;
+        flags = CAST_WRAPPED_ENUM_T(GjsArgumentFlags,
+                                    GjsArgumentFlags::NONE | GjsArgumentFlags::SKIP_OUT);
     }
 
     void set_return_value() {


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