[gjs: 9/10] arg: Pass in GITypeTag to gjs_array_to_intarray()




commit b29c309fcc9ac602806183e3ae9a65cae15ac75c
Author: Philip Chimento <philip chimento gmail com>
Date:   Wed Mar 2 22:27:13 2022 -0800

    arg: Pass in GITypeTag to gjs_array_to_intarray()
    
    Only the type tag information is used here, so there's no need to require
    the type info pointer. This allows refactoring to call this function from
    places where we don't have the type info pointer available.

 gi/arg.cpp | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 77e6af418..d2c1149ed 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -675,18 +675,11 @@ gjs_array_to_strv(JSContext   *context,
 }
 
 GJS_JSAPI_RETURN_CONVENTION
-static bool
-gjs_string_to_intarray(JSContext       *context,
-                       JS::HandleString str,
-                       GITypeInfo      *param_info,
-                       void           **arr_p,
-                       size_t          *length)
-{
-    GITypeTag element_type;
+static bool gjs_string_to_intarray(JSContext* context, JS::HandleString str,
+                                   GITypeTag element_type, void** arr_p,
+                                   size_t* length) {
     char16_t *result16;
 
-    element_type = g_type_info_get_tag(param_info);
-
     switch (element_type) {
         case GI_TYPE_TAG_INT8:
         case GI_TYPE_TAG_UINT8: {
@@ -1110,7 +1103,8 @@ bool gjs_array_to_explicit_array(JSContext* context, JS::HandleValue value,
     } else if (value.isString()) {
         /* Allow strings as int8/uint8/int16/uint16 arrays */
         JS::RootedString str(context, value.toString());
-        if (!gjs_string_to_intarray(context, str, param_info, contents, length_p))
+        GITypeTag element_tag = g_type_info_get_tag(param_info);
+        if (!gjs_string_to_intarray(context, str, element_tag, contents, length_p))
             return false;
     } else {
         JS::RootedObject array_obj(context, &value.toObject());


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