[gjs: 7/10] arg: Refactor value_to_ghashtable_key() to take GITypeTag
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 7/10] arg: Refactor value_to_ghashtable_key() to take GITypeTag
- Date: Sun, 6 Mar 2022 00:46:42 +0000 (UTC)
commit ff2cad0c7f3c568189de80dfd738c5603f274b1c
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Feb 19 16:39:33 2022 -0800
arg: Refactor value_to_ghashtable_key() to take GITypeTag
This function doesn't need the whole GITypeInfo, just the type tag. This
refactor allows reusing it in a separate code path for basic types that
are only identified by their type tag.
gi/arg.cpp | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 4aa64927e..12ecb5346 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -372,13 +372,8 @@ GJS_JSAPI_RETURN_CONVENTION static bool hashtable_int_key(
* possible, otherwise giving the location of an allocated key in @pointer_out.
*/
GJS_JSAPI_RETURN_CONVENTION
-static bool
-value_to_ghashtable_key(JSContext *cx,
- JS::HandleValue value,
- GITypeInfo *type_info,
- gpointer *pointer_out)
-{
- GITypeTag type_tag = g_type_info_get_tag((GITypeInfo*) type_info);
+static bool value_to_ghashtable_key(JSContext* cx, JS::HandleValue value,
+ GITypeTag type_tag, void** pointer_out) {
bool unsupported = false;
g_assert((value.isString() || value.isInt32()) &&
@@ -546,8 +541,7 @@ static bool gjs_object_to_g_hash(JSContext* context, JS::HandleObject props,
if (!JS_IdToValue(context, cur_id, &key_js) ||
// Type check key type.
- !value_to_ghashtable_key(context, key_js, key_param_info,
- &key_ptr) ||
+ !value_to_ghashtable_key(context, key_js, key_tag, &key_ptr) ||
!JS_GetPropertyById(context, props, cur_id, &val_js) ||
// Type check and convert value to a C type
!gjs_value_to_g_argument(context, val_js, val_param_info, nullptr,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]