| 1 |
dnl Copyright 2008 The gstreamermm Development Team |
| 2 |
|
| 3 |
dnl |
| 4 |
dnl _CLASS_BOXEDTYPE_EXTRA(Region, GdkRegion, gdk_region_new, gdk_region_copy, gdk_region_destroy) |
| 5 |
dnl |
| 6 |
|
| 7 |
define(`_CLASS_BOXEDTYPE_EXTRA',`dnl |
| 8 |
_PUSH() |
| 9 |
dnl |
| 10 |
dnl Define the args for later macros |
| 11 |
define(`__CPPNAME__',`$1') |
| 12 |
define(`__CNAME__',`$2') |
| 13 |
define(`__BOXEDTYPE_FUNC_NEW',`$3') |
| 14 |
define(`__BOXEDTYPE_FUNC_COPY',`$4') |
| 15 |
define(`__BOXEDTYPE_FUNC_FREE',`$5') |
| 16 |
|
| 17 |
define(`_CUSTOM_DEFAULT_CTOR',`dnl |
| 18 |
_PUSH() |
| 19 |
dnl Define this macro to be tested for later. |
| 20 |
define(`__BOOL_CUSTOM_DEFAULT_CTOR__',`$1') |
| 21 |
_POP() |
| 22 |
') |
| 23 |
|
| 24 |
|
| 25 |
_POP() |
| 26 |
_SECTION(SECTION_CLASS2) |
| 27 |
') dnl End of _CLASS_BOXEDTYPE_EXTRA. |
| 28 |
|
| 29 |
dnl Some of the Gdk types are unions - e.g. GdkEvent. |
| 30 |
define(`_CUSTOM_STRUCT_PROTOTYPE',`dnl |
| 31 |
_PUSH() |
| 32 |
dnl Define this macro to be tested for later. |
| 33 |
define(`__BOOL_CUSTOM_STRUCT_PROTOTYPE__',`$1') |
| 34 |
_POP() |
| 35 |
') |
| 36 |
|
| 37 |
dnl |
| 38 |
dnl _END_CLASS_BOXEDTYPE_EXTRA() |
| 39 |
dnl denotes the end of a class |
| 40 |
dnl |
| 41 |
define(`_END_CLASS_BOXEDTYPE_EXTRA',` |
| 42 |
_SECTION(SECTION_HEADER1) |
| 43 |
ifdef(`__BOOL_CUSTOM_STRUCT_PROTOTYPE__',`dnl |
| 44 |
',`dnl |
| 45 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 46 |
extern "C" { typedef struct _`'__CNAME__ __CNAME__; } |
| 47 |
#endif |
| 48 |
')dnl |
| 49 |
|
| 50 |
_SECTION(SECTION_HEADER3) |
| 51 |
|
| 52 |
__NAMESPACE_BEGIN__ |
| 53 |
|
| 54 |
/** @relates __NAMESPACE__::__CPPNAME__ |
| 55 |
* @param lhs The left-hand side |
| 56 |
* @param rhs The right-hand side |
| 57 |
*/ |
| 58 |
inline void swap(__CPPNAME__& lhs, __CPPNAME__& rhs) |
| 59 |
{ lhs.swap(rhs); } |
| 60 |
|
| 61 |
__NAMESPACE_END__ |
| 62 |
|
| 63 |
namespace Glib |
| 64 |
{ |
| 65 |
ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl |
| 66 |
',`dnl else |
| 67 |
|
| 68 |
/** A Glib::wrap() method for this object. The method has a non-standard name because otherwise it would collide with the wrap method for Gst::Structure because both Gst::TagList and Gst::Structure wrap the same underlying C type. |
| 69 |
* |
| 70 |
* @param object The C instance. |
| 71 |
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. |
| 72 |
* @result A C++ instance that wraps this C instance. |
| 73 |
* |
| 74 |
* @relates __NAMESPACE__::__CPPNAME__ |
| 75 |
*/ |
| 76 |
__NAMESPACE__::__CPPNAME__ wrap_taglist(__CNAME__* object, bool take_copy = false); |
| 77 |
')dnl endif __BOOL_NO_WRAP_FUNCTION__ |
| 78 |
|
| 79 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 80 |
template <> |
| 81 |
class Value<__NAMESPACE__::__CPPNAME__> : public Glib::Value_Boxed<__NAMESPACE__::__CPPNAME__> |
| 82 |
{}; |
| 83 |
#endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 84 |
|
| 85 |
} // namespace Glib |
| 86 |
|
| 87 |
_SECTION(SECTION_SRC_GENERATED) |
| 88 |
|
| 89 |
ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl |
| 90 |
',`dnl else |
| 91 |
namespace Glib |
| 92 |
{ |
| 93 |
|
| 94 |
__NAMESPACE__::__CPPNAME__ wrap_taglist(__CNAME__* object, bool take_copy) |
| 95 |
{ |
| 96 |
return __NAMESPACE__::__CPPNAME__`'(object, take_copy); |
| 97 |
} |
| 98 |
|
| 99 |
} // namespace Glib |
| 100 |
')dnl endif |
| 101 |
|
| 102 |
|
| 103 |
__NAMESPACE_BEGIN__ |
| 104 |
|
| 105 |
dnl |
| 106 |
dnl The implementation: |
| 107 |
dnl |
| 108 |
|
| 109 |
// static |
| 110 |
GType __CPPNAME__::get_type() |
| 111 |
{ |
| 112 |
return _GET_TYPE_FUNC(__CNAME__); |
| 113 |
} |
| 114 |
|
| 115 |
ifdef(`__BOOL_CUSTOM_DEFAULT_CTOR__',`dnl |
| 116 |
',`dnl else |
| 117 |
__CPPNAME__::__CPPNAME__`'() |
| 118 |
: |
| 119 |
ifelse(__BOXEDTYPE_FUNC_NEW,NONE,`dnl |
| 120 |
gobject_ (0) // Allows creation of invalid wrapper, e.g. for output arguments to methods. |
| 121 |
',`dnl else |
| 122 |
gobject_ (__BOXEDTYPE_FUNC_NEW`'()) |
| 123 |
')dnl |
| 124 |
{} |
| 125 |
')dnl endif __BOOL_CUSTOM_DEFAULT_CTOR__ |
| 126 |
|
| 127 |
__CPPNAME__::__CPPNAME__`'(const __CPPNAME__& other) |
| 128 |
: |
| 129 |
gobject_ ((other.gobject_) ? __BOXEDTYPE_FUNC_COPY`'(other.gobject_) : 0) |
| 130 |
{} |
| 131 |
|
| 132 |
__CPPNAME__::__CPPNAME__`'(__CNAME__* gobject, bool make_a_copy) |
| 133 |
: |
| 134 |
// For BoxedType wrappers, make_a_copy is true by default. The static |
| 135 |
// BoxedType wrappers must always take a copy, thus make_a_copy = true |
| 136 |
// ensures identical behaviour if the default argument is used. |
| 137 |
gobject_ ((make_a_copy && gobject) ? __BOXEDTYPE_FUNC_COPY`'(gobject) : gobject) |
| 138 |
{} |
| 139 |
|
| 140 |
__CPPNAME__& __CPPNAME__::operator=(const __CPPNAME__`'& other) |
| 141 |
{ |
| 142 |
__CPPNAME__ temp (other); |
| 143 |
swap(temp); |
| 144 |
return *this; |
| 145 |
} |
| 146 |
|
| 147 |
__CPPNAME__::~__CPPNAME__`'() |
| 148 |
{ |
| 149 |
dnl This could be a free or an unref, we do not need to know. |
| 150 |
if(gobject_) |
| 151 |
__BOXEDTYPE_FUNC_FREE`'(gobject_); |
| 152 |
} |
| 153 |
|
| 154 |
void __CPPNAME__::swap(__CPPNAME__& other) |
| 155 |
{ |
| 156 |
__CNAME__ *const temp = gobject_; |
| 157 |
gobject_ = other.gobject_; |
| 158 |
other.gobject_ = temp; |
| 159 |
} |
| 160 |
|
| 161 |
__CNAME__* __CPPNAME__::gobj_copy() const |
| 162 |
{ |
| 163 |
return __BOXEDTYPE_FUNC_COPY`'(gobject_); |
| 164 |
} |
| 165 |
|
| 166 |
_IMPORT(SECTION_CC) |
| 167 |
|
| 168 |
__NAMESPACE_END__ |
| 169 |
|
| 170 |
|
| 171 |
dnl |
| 172 |
dnl |
| 173 |
dnl |
| 174 |
dnl |
| 175 |
_POP() |
| 176 |
dnl |
| 177 |
dnl |
| 178 |
dnl The actual class, e.g. Pango::FontDescription, declaration: |
| 179 |
dnl |
| 180 |
_IMPORT(SECTION_CLASS1) |
| 181 |
public: |
| 182 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 183 |
typedef __CPPNAME__ CppObjectType; |
| 184 |
typedef __CNAME__ BaseObjectType; |
| 185 |
|
| 186 |
static GType get_type() G_GNUC_CONST; |
| 187 |
#endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 188 |
|
| 189 |
ifdef(`__BOOL_CUSTOM_DEFAULT_CTOR__',`dnl |
| 190 |
',`dnl else |
| 191 |
__CPPNAME__`'(); |
| 192 |
')dnl |
| 193 |
|
| 194 |
explicit __CPPNAME__`'(__CNAME__* gobject, bool make_a_copy = true); |
| 195 |
|
| 196 |
__CPPNAME__`'(const __CPPNAME__& other); |
| 197 |
__CPPNAME__& operator=(const __CPPNAME__& other); |
| 198 |
|
| 199 |
~__CPPNAME__`'(); |
| 200 |
|
| 201 |
void swap(__CPPNAME__& other); |
| 202 |
|
| 203 |
///Provides access to the underlying C instance. |
| 204 |
__CNAME__* gobj() { return gobject_; } |
| 205 |
|
| 206 |
///Provides access to the underlying C instance. |
| 207 |
const __CNAME__* gobj() const { return gobject_; } |
| 208 |
|
| 209 |
///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs. |
| 210 |
__CNAME__* gobj_copy() const; |
| 211 |
|
| 212 |
protected: |
| 213 |
__CNAME__* gobject_; |
| 214 |
|
| 215 |
private: |
| 216 |
_IMPORT(SECTION_CLASS2) |
| 217 |
') |
| 218 |
|