[gjs/arg-inlines: 1/9] arg: Use GIArgument's char pointer to store strings



commit 424c58c30cf0e6164c6793c705cad376974c2085
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Sun May 10 23:01:40 2020 +0200

    arg: Use GIArgument's char pointer to store strings
    
    Since it's defined, better to just reuse instead of doing casts

 gi/arg-inl.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/gi/arg-inl.h b/gi/arg-inl.h
index aafee2bb..e1fbd6a4 100644
--- a/gi/arg-inl.h
+++ b/gi/arg-inl.h
@@ -103,7 +103,7 @@ GJS_USE inline decltype(auto) gjs_g_argument_value<double>(GIArgument* arg) {
 
 template <>
 GJS_USE inline decltype(auto) gjs_g_argument_value<char*>(GIArgument* arg) {
-    return gjs_g_argument_value(arg, &GIArgument::v_pointer);
+    return gjs_g_argument_value(arg, &GIArgument::v_string);
 }
 
 template <>
@@ -127,6 +127,11 @@ inline void gjs_g_argument_value_set<gboolean, GI_TYPE_TAG_BOOLEAN>(
     gjs_g_argument_value<bool>(arg) = !!v;
 }
 
+template <>
+inline void gjs_g_argument_value_set(GIArgument* arg, const char* v) {
+    gjs_g_argument_value<char*>(arg) = const_cast<char*>(v);
+}
+
 template <typename T, GITypeTag TAG = GI_TYPE_TAG_VOID>
 GJS_USE inline T gjs_g_argument_value_get(GIArgument* arg) {
     return gjs_g_argument_value<T, TAG>(arg);


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