add new sigc++2 directory
[ardour.git] / libs / glibmm2 / tools / m4 / member.m4
1 dnl
2 dnl --------------------------- Accessors ----------------------------
3 dnl
4
5
6 dnl Get:
7
8
9 dnl Creates accessors for simple types:
10 dnl _MEMBER_GET(cpp_name, c_name, cpp_type, c_type, deprecated (optional))
11 define(`_MEMBER_GET',`dnl
12 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START  ') dnl
13 $3 get_$1() const;
14 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END  ') dnl
15 _PUSH(SECTION_CC)
16 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START  ') dnl
17 $3 __CPPNAME__::get_$1() const
18 {
19   return _CONVERT($4,$3,`gobj()->$2');
20 }
21 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END  ') dnl
22
23 _POP()')
24
25 dnl Creates two accessors for pointer types, one const and one non-const:
26 define(`_MEMBER_GET_PTR',`dnl
27 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START  ') dnl
28 $3 get_$1();
29   const $3 get_$1() const;
30 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END  ') dnl
31 _PUSH(SECTION_CC)
32 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START  ') dnl
33 $3 __CPPNAME__::get_$1()
34 {
35   return _CONVERT($4,$3,`gobj()->$2');
36 }
37
38 const $3 __CPPNAME__::get_$1() const
39 {
40   return _CONVERT($4,const $3,`gobj()->$2');
41 }
42 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END  ') dnl
43
44 _POP()')
45
46 dnl Creates accessors for GObject-derived types that must be ref()ed.
47 define(`_MEMBER_GET_GOBJECT',`dnl
48 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START  ') dnl
49 Glib::RefPtr<$3> get_$1();
50   Glib::RefPtr<const $3> get_$1() const;
51 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END  ') dnl
52 _PUSH(SECTION_CC)
53 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START  ') dnl
54 Glib::RefPtr<$3> __CPPNAME__::get_$1()
55 {
56   Glib::RefPtr<$3> ref_ptr(_CONVERT($4,Glib::RefPtr<$3>,`gobj()->$2'));
57
58 dnl We could use the bool with Glib::wrap(), but we want to share the m4 type-conversion map.
59   if(ref_ptr)
60     ref_ptr->reference();
61
62   return ref_ptr;
63 }
64
65 Glib::RefPtr<const $3> __CPPNAME__::get_$1() const
66 {
67   Glib::RefPtr<const $3> ref_ptr(_CONVERT($4,Glib::RefPtr<const $3>,`gobj()->$2'));
68
69 dnl We could use the bool with Glib::wrap(), but we want to share the m4 type-conversion map.
70   if(ref_ptr)
71     ref_ptr->reference();
72
73   return ref_ptr;
74 }
75 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END  ') dnl
76
77 _POP()')
78
79
80 dnl Set:
81
82 dnl Creates accessors for simple types:
83 define(`_MEMBER_SET',`dnl
84 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START  ') dnl
85 void set_$1(const $3`'& value);
86 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END  ') dnl
87 _PUSH(SECTION_CC)
88 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START  ') dnl
89 void __CPPNAME__::set_$1(const $3`'& value)
90 {
91   gobj()->$2 = _CONVERT($3,$4,`value');
92 }
93 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END  ') dnl
94
95 _POP()')
96
97 dnl Creates accessors for pointer types:
98 define(`_MEMBER_SET_PTR',`dnl
99 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START  ') dnl
100 void set_$1($3 value);
101 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END  ') dnl
102 _PUSH(SECTION_CC)
103 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START  ') dnl
104 void __CPPNAME__::set_$1($3 value)
105 {
106   gobj()->$2 = _CONVERT($3,$4,`value');
107 }
108 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END  ') dnl
109
110 _POP()')
111
112 dnl Creates accessors for GObject-derived types that must be ref()ed.
113 define(`_MEMBER_SET_GOBJECT',`dnl
114 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START  ') dnl
115 void set_$1(const Glib::RefPtr<$3>& value);
116 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END  ') dnl
117 _PUSH(SECTION_CC)
118 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START  ') dnl
119 void __CPPNAME__::set_$1(const Glib::RefPtr<$3>& value)
120 {
121   Glib::RefPtr<$3> valueOld(_CONVERT($4,Glib::RefPtr<$3>,`gobj()->$2')); //Take possession of the old one, unref-ing it in the destructor.
122
123   if(value)
124     value->reference(); //Ref once for the recipient.
125
126   gobj()->$2 = _CONVERT(const Glib::RefPtr<$3>&,$4,`value');
127 }
128 ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END  ') dnl
129
130 _POP()')
131
132