[glibmm] member.m4: Add _MEMBER_SET_STR, setter for strings
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] member.m4: Add _MEMBER_SET_STR, setter for strings
- Date: Fri, 2 Mar 2018 09:25:55 +0000 (UTC)
commit d114609bffc5c43667adb0c89ac59c72a3d3eaa6
Author: Pavlo Solntsev <pavlo solntsev gmail com>
Date: Thu Mar 1 18:18:50 2018 +0100
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
tools/m4/member.m4 | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/tools/m4/member.m4 b/tools/m4/member.m4
index acb6c04..9dec2d6 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]