summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPavlo Solntsev <pavlo.solntsev@gmail.com>2018-03-02 10:30:07 +0100
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2018-03-02 10:30:07 +0100
commitb2461f9e1b9aaf02f16a27d49f43abe1ce84b900 (patch)
treec5934616172f7a787d130110245119c3c2306e1d /tools
parent97746f01a83708922eddbb5c834dc0a8d0c91fb6 (diff)
downloadglibmm-b2461f9e1b9aaf02f16a27d49f43abe1ce84b900.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