summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPavlo Solntsev <pavlo.solntsev@gmail.com>2018-03-01 18:18:50 +0100
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2018-03-02 10:24:02 +0100
commitd114609bffc5c43667adb0c89ac59c72a3d3eaa6 (patch)
treee5283f15f2fe523de61f240937f0a44c6404b4be /tools
parent8c4aad91e743414503e7abae0d67bb7fe1be3b41 (diff)
downloadglibmm-d114609bffc5c43667adb0c89ac59c72a3d3eaa6.tar.gz
member.m4: Add _MEMBER_SET_STR, setter for strings
Introduce a macro to generate appropriate setter for a structure which has gchar* as a member. Bug 793778
Diffstat (limited to 'tools')
-rw-r--r--tools/m4/member.m421
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/m4/member.m4 b/tools/m4/member.m4
index acb6c044..9dec2d66 100644
--- a/tools/m4/member.m4
+++ b/tools/m4/member.m4
@@ -94,6 +94,27 @@ ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
_POP()')
+dnl Creates setters for a member which is of char* type:
+dnl The convenient way to use this macro is to pair it with
+dnl _CONVERSION(`Glib::ustring', `const gchar*', `($3).c_str()')
+dnl or similar conversion.
+dnl There is no _MEMBER_GET_STR. With a suitable _CONVERSION,
+dnl _MEMBER_GET can be used as the corresponding getter.
+define(`_MEMBER_SET_STR',`dnl
+ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl
+void set_$1(const $3`'& value);
+ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
+_PUSH(SECTION_CC)
+ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl
+void __CPPNAME__::set_$1(const $3`'& value)
+{
+ g_free((char*)gobj()->$2); // Cast away const, if any
+ gobj()->$2 = g_strdup(_CONVERT($3,$4,`value'));
+}
+ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
+
+_POP()')
+
dnl Creates accessors for pointer types:
define(`_MEMBER_SET_PTR',`dnl
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl