[glibmm/glibmm-2-54] member.m4: Add _MEMBER_SET_STR, setter for strings
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/glibmm-2-54] member.m4: Add _MEMBER_SET_STR, setter for strings
- Date: Fri, 2 Mar 2018 09:32:06 +0000 (UTC)
commit b2461f9e1b9aaf02f16a27d49f43abe1ce84b900
Author: Pavlo Solntsev <pavlo solntsev gmail com>
Date: Fri Mar 2 10:30:07 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]