[gtkmm] Gdk::Event: Remove _GDKEVENT_INHERITS(), improve _CLASS_GDKEVENT()
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gdk::Event: Remove _GDKEVENT_INHERITS(), improve _CLASS_GDKEVENT()
- Date: Wed, 24 May 2017 14:48:13 +0000 (UTC)
commit 158934e0d0abf92f3c40e9813e08cfb31ad00717
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Wed May 24 16:43:01 2017 +0200
Gdk::Event: Remove _GDKEVENT_INHERITS(), improve _CLASS_GDKEVENT()
* gdk/src/event.hg:
* tools/m4/class_gdkevent.m4:
Remove _GDKEVENT_INHERITS(). _CLASS_GDKEVENT() can take either 2 or 4
parameters, 2 for the base class, 4 for the subclasses.
_CLASS_GDKEVENT(C++ class, C class [, C++ base class, C base class])
Almost like _CLASS_GOBJECT() and _CLASS_GTKOBJECT().
Only the base class, Gdk::Event, has a get_type() function.
Correct Gdk::wrap_event(). Add move constructor and move assignment.
Remove many @c. Bug 135978
gdk/src/event.hg | 151 ++++++++++++++++++-----------------------
tools/m4/class_gdkevent.m4 | 159 ++++++++++++++++++++++++--------------------
2 files changed, 152 insertions(+), 158 deletions(-)
---
diff --git a/gdk/src/event.hg b/gdk/src/event.hg
index 8989eb3..b50d477 100644
--- a/gdk/src/event.hg
+++ b/gdk/src/event.hg
@@ -96,8 +96,7 @@ public:
*/
class EventKey : public Event
{
- _CLASS_GDKEVENT(EventKey, GdkEventKey)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventKey, GdkEventKey, Event, GdkEvent)
public:
@@ -136,7 +135,7 @@ public:
/** Represents a mouse button press or release event.
*
- * @c get_event_type() will return one of @c Gdk::Event::Type::BUTTON_PRESS,
+ * get_event_type() will return one of Gdk::Event::Type::BUTTON_PRESS,
* Gdk::Event::Type::DOUBLE_BUTTON_PRESS, Gdk::Event::Type::TRIPLE_BUTTON_PRESS
* or Gdk::Event::Type::BUTTON_RELEASE.
*
@@ -176,8 +175,7 @@ public:
*/
class EventButton : public Event
{
- _CLASS_GDKEVENT(EventButton, GdkEventButton)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventButton, GdkEventButton, Event, GdkEvent)
public:
@@ -235,16 +233,15 @@ public:
* usually configured to generate button press events for buttons 4 and 5 when
* the wheel is turned.
*
- * @c get_event_type() will return @c Gdk::Event::Type::SCROLL.
+ * get_event_type() will return Gdk::Event::Type::SCROLL.
*
* Some GDK backends can also generate 'smooth' scroll events, which can be
* recognized by the Gdk::ScrollDirection::SMOOTH scroll direction. For these,
- * scroll deltas can be obtained with @c get_delta_x() and @c get_delta_y.
+ * scroll deltas can be obtained with get_delta_x() and get_delta_y().
*/
class EventScroll : public Event
{
- _CLASS_GDKEVENT(EventScroll, GdkEventScroll)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventScroll, GdkEventScroll, Event, GdkEvent)
public:
@@ -280,14 +277,14 @@ public:
_MEMBER_GET(root_y, y_root, double, gdouble)
/**
- * Returns the scroll delta in the X axis. Meaningful only if @c direction()
- * returns @c Gdk::SCROLL_SMOOTH
+ * Returns the scroll delta in the X axis. Meaningful only if get_direction()
+ * returns Gdk::ScrollDirection::SMOOTH
*/
_MEMBER_GET(delta_x, delta_x, double, gdouble)
/**
- * Returns the scroll delta in the Y axis. Meaningful only if @c direction()
- * returns @c Gdk::SCROLL_SMOOTH
+ * Returns the scroll delta in the Y axis. Meaningful only if get_direction()
+ * returns Gdk::ScrollDirection::SMOOTH
*/
_MEMBER_GET(delta_y, delta_y, double, gdouble)
@@ -304,12 +301,11 @@ public:
/** Generated when a mouse pointer is moved.
*
- * @c get_event_type() will return @c Gdk::Event::Type::MOTION_NOTIFY.
+ * get_event_type() will return Gdk::Event::Type::MOTION_NOTIFY.
*/
class EventMotion : public Event
{
- _CLASS_GDKEVENT(EventMotion, GdkEventMotion)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventMotion, GdkEventMotion, Event, GdkEvent)
public:
@@ -351,15 +347,15 @@ public:
/**
* Returns @c true if the event is motion hint.
*
- * Motion hints are received only if @c Gdk::EventMask::POINTER_MOTION_HINT_MASK is set.
- * It is used to reduce the number of @c Gdk::Event::Type::MOTION_NOTIFY events received.
- * Normally a @c Gdk::Event::Type::MOTION_NOTIFY event is received each time the mouse
+ * Motion hints are received only if Gdk::EventMask::POINTER_MOTION_HINT_MASK is set.
+ * It is used to reduce the number of Gdk::Event::Type::MOTION_NOTIFY events received.
+ * Normally a Gdk::Event::Type::MOTION_NOTIFY event is received each time the mouse
* moves. However, if the application spends a lot of time processing the
* event (updating the display, for example), it can lag behind the position
- * of the mouse. When using @c Gdk::EventMask::POINTER_MOTION_HINT_MASK, fewer
- * @c Gdk::Event::Type::MOTION_NOTIFY events will be sent, some of which are marked as a
- * hint To receive more motion events after a motion hint event, the
- * application needs to asks for more, by calling @c request_motions().
+ * of the mouse. When using Gdk::EventMask::POINTER_MOTION_HINT_MASK, fewer
+ * Gdk::Event::Type::MOTION_NOTIFY events will be sent, some of which are marked as a
+ * hint. To receive more motion events after a motion hint event, the
+ * application needs to ask for more, by calling request_motions().
*/
_MEMBER_GET(is_hint, is_hint, bool, gint16)
@@ -373,12 +369,12 @@ public:
/** Generated during an attached touchscreen is touched.
*
- * @c get_event_type() will return one of Gdk::Event::Type::TOUCH_BEGIN,
+ * get_event_type() will return one of Gdk::Event::Type::TOUCH_BEGIN,
* Gdk::Event::Type::TOUCH_UPDATE, Gdk::Event::Type::TOUCH_END or
* Gdk::Event::Type::TOUCH_CANCEL.
*
* Touch events are grouped into sequences by means of the sequence field, which
- * can also be obtained with @c get_event_sequence(). Each sequence
+ * can also be obtained with get_event_sequence(). Each sequence
* begins with a Gdk::Event::Type::TOUCH_BEGIN event, followed by any number of
* Gdk::Event::Type::TOUCH_UPDATE events, and ends with a Gdk::Event::Type::TOUCH_END
* (or Gdk::Event::Type::TOUCH_CANCEL) event. With multitouch devices, there may
@@ -386,8 +382,7 @@ public:
*/
class EventTouch : public Event
{
- _CLASS_GDKEVENT(EventTouch, GdkEventTouch)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventTouch, GdkEventTouch, Event, GdkEvent)
public:
@@ -444,13 +439,12 @@ public:
/** Generated when the mouse pointer leaves or enters the window.
*
- * @c get_event_type() will return one of @c Gdk::Event::Type::LEAVE_NOTIFY or
- * @c Gdk::Event::Type::ENTER_NOTIFY.
+ * get_event_type() will return one of Gdk::Event::Type::LEAVE_NOTIFY or
+ * Gdk::Event::Type::ENTER_NOTIFY.
*/
class EventCrossing : public Event
{
- _CLASS_GDKEVENT(EventCrossing, GdkEventCrossing)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventCrossing, GdkEventCrossing, Event, GdkEvent)
public:
@@ -491,7 +485,7 @@ public:
_MEMBER_GET(root_y, y_root, double, gdouble)
/*** Returns the crossing mode.
- * @c Gdk::CrossingMode::GTK_GRAB, Gdk::CrossingMode::GTK_UNGRAB, and
+ * Gdk::CrossingMode::GTK_GRAB, Gdk::CrossingMode::GTK_UNGRAB, and
* Gdk::CrossingMode::STATE_CHANGED are always synthesized, never native.
*/
_MEMBER_GET(mode, mode, Gdk::CrossingMode, GdkCrossingMode)
@@ -510,12 +504,11 @@ public:
/** Generated when all or part of a window becomes visible and needs to be
* redrawn.
*
- * @c get_event_type() will return one of Gdk::Event::Type::EXPOSE, Gdk::Event::Type::DAMAGE.
+ * get_event_type() will return one of Gdk::Event::Type::EXPOSE, Gdk::Event::Type::DAMAGE.
*/
class EventExpose : public Event
{
- _CLASS_GDKEVENT(EventExpose, GdkEventExpose)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventExpose, GdkEventExpose, Event, GdkEvent)
public:
@@ -543,12 +536,11 @@ public:
// GdkEventVisibility is deprecated. It's not used in gtk+ 4.
/* Generated when the visibility status of a window changes.
*
- * @c get_event_type() will return @c Gdk::Event::Type::VISIBILITY_NOTIFY.
+ * get_event_type() will return Gdk::Event::Type::VISIBILITY_NOTIFY.
*/
//class EventVisibility : public Event
//{
-// _CLASS_GDKEVENT(EventVisibility, GdkEventVisibility)
-// _GDKEVENT_INHERITS(Event, GdkEvent)
+// _CLASS_GDKEVENT(EventVisibility, GdkEventVisibility, Event, GdkEvent)
//public:
/* The new visibility state
*/
@@ -557,12 +549,11 @@ public:
/** Generated when the keyboard focus changes.
*
- * @c get_event_type() will return @c Gdk::Event::Type::FOCUS_CHANGE.
+ * get_event_type() will return Gdk::Event::Type::FOCUS_CHANGE.
*/
class EventFocus : public Event
{
- _CLASS_GDKEVENT(EventFocus, GdkEventFocus)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventFocus, GdkEventFocus, Event, GdkEvent)
public:
@@ -574,12 +565,11 @@ public:
/** Generated when the position or size of a window changes.
*
- * @c get_event_type() will return @c Gdk::Event::Type::CONFIGURE.
+ * get_event_type() will return Gdk::Event::Type::CONFIGURE.
*/
class EventConfigure : public Event
{
- _CLASS_GDKEVENT(EventConfigure, GdkEventConfigure)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventConfigure, GdkEventConfigure, Event, GdkEvent)
public:
@@ -611,12 +601,11 @@ public:
/** Rarely used event. Generated when a property of a window changes.
*
- * @c get_event_type() will return @c Gdk::Event::Type::PROPERTY_NOTIFY.
+ * get_event_type() will return Gdk::Event::Type::PROPERTY_NOTIFY.
*/
class EventProperty : public Event
{
- _CLASS_GDKEVENT(EventProperty, GdkEventProperty)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventProperty, GdkEventProperty, Event, GdkEvent)
public:
@@ -640,13 +629,12 @@ public:
/** Rarely used event. Generated when a selection is requested or ownership of a
* selection is taken over by another client application.
*
- * @c get_event_type() will return one of @c Gdk::Event::Type::SELECTION_CLEAR,
- * @c Gdk::Event::Type::SELECTION_NOTIFY or @c Gdk::Event::Type::SELECTION_REQUEST).
+ * get_event_type() will return one of Gdk::Event::Type::SELECTION_CLEAR,
+ * Gdk::Event::Type::SELECTION_NOTIFY or Gdk::Event::Type::SELECTION_REQUEST).
*/
class EventSelection : public Event
{
- _CLASS_GDKEVENT(EventSelection, GdkEventSelection)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventSelection, GdkEventSelection, Event, GdkEvent)
public:
@@ -674,14 +662,14 @@ public:
/**
* Checks whether there's window on which to place the property. The results
- * are undefined if @c has_requestor() returns @c false and @c get_requestor
+ * are undefined if has_requestor() returns @c false and get_requestor()
* is called.
*/
bool has_requestor() const;
/**
* Returns the window on which to place the property. The results are
- * undefined if @c has_requestor() would return @c false before the call.
+ * undefined if has_requestor() would return @c false before the call.
*/
_MEMBER_GET_GOBJECT(requestor, requestor, Gdk::Window, GdkWindow*)
};
@@ -690,12 +678,11 @@ public:
* this information is only available if the X server supports the XFIXES
* extension.
*
- * @c get_event_type() will return @c Gdk::Event::Type::OWNER_CHANGE.
+ * get_event_type() will return Gdk::Event::Type::OWNER_CHANGE.
*/
class EventOwnerChange : public Event
{
- _CLASS_GDKEVENT(EventOwnerChange, GdkEventOwnerChange)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventOwnerChange, GdkEventOwnerChange, Event, GdkEvent)
public:
@@ -721,29 +708,27 @@ public:
/**
* Checks whether there's new owner of the selection. The results are
- * undefined if @c has_owner() returns @c false and @c get_owner() is
- * called.
+ * undefined if has_owner() returns @c false and get_owner() is called.
*/
bool has_owner() const;
/**
* Returns the window which is the new owner of the selection. The results are
- * undefined if @c has_owner() would return @c false before the call.
+ * undefined if has_owner() would return @c false before the call.
*/
_MEMBER_GET_GOBJECT(owner, owner, Gdk::Window, GdkWindow*)
};
/** Generated during Drag-and-Drop (DND) operations.
*
- * @c get_event_type() will return one of @c Gdk::Event::Type::DRAG_ENTER,
- * @c Gdk::Event::Type::DRAG_LEAVE, @c Gdk::Event::Type::DRAG_MOTION,
- * @c Gdk::Event::Type::DRAG_STATUS, @c Gdk::Event::Type::DROP_START
- * or @c Gdk::Event::Type::DROP_FINISHED.
+ * get_event_type() will return one of Gdk::Event::Type::DRAG_ENTER,
+ * Gdk::Event::Type::DRAG_LEAVE, Gdk::Event::Type::DRAG_MOTION,
+ * Gdk::Event::Type::DRAG_STATUS, Gdk::Event::Type::DROP_START
+ * or Gdk::Event::Type::DROP_FINISHED.
*/
class EventDND : public Event
{
- _CLASS_GDKEVENT(EventDND, GdkEventDND)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventDND, GdkEventDND, Event, GdkEvent)
public:
@@ -754,8 +739,8 @@ public:
/**
* Returns the X coordinate of the pointer relative to the root screen. Only
- * meaningful if @c get_event_type() returns @c Gdk::Event::Type::DRAG_MOTION or
- * @c Gdk::Event::Type::DROP_START.
+ * meaningful if get_event_type() returns Gdk::Event::Type::DRAG_MOTION or
+ * Gdk::Event::Type::DROP_START.
*/
_MEMBER_GET(root_x, x_root, double, gdouble)
@@ -778,13 +763,12 @@ public:
* This event type will be used pretty rarely. It only is important for XInput
* aware programs that are drawing their own cursor.
*
- * @c get_event_type() will return one of @c Gdk::Event::Type::PROXIMITY_IN,
- * @c Gdk::Event::Type::PROXIMITY_OUT.
+ * get_event_type() will return one of Gdk::Event::Type::PROXIMITY_IN,
+ * Gdk::Event::Type::PROXIMITY_OUT.
*/
class EventProximity : public Event
{
- _CLASS_GDKEVENT(EventProximity, GdkEventProximity)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventProximity, GdkEventProximity, Event, GdkEvent)
public:
@@ -801,13 +785,12 @@ public:
/** Generated when the state of the toplevel window changes.
*
- * @c get_event_type() will return one of @c Gdk::Event::Type::WINDOW_STATE,
- * @c Gdk::Event::Type::PROXIMITY_OUT.
+ * get_event_type() will return one of Gdk::Event::Type::WINDOW_STATE,
+ * Gdk::Event::Type::PROXIMITY_OUT.
*/
class EventWindowState : public Event
{
- _CLASS_GDKEVENT(EventWindowState, GdkEventWindowState)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventWindowState, GdkEventWindowState, Event, GdkEvent)
public:
@@ -825,12 +808,11 @@ public:
/** Generated when a setting is modified.
*
- * @c get_event_type() will return @c Gdk::Event::Type::SETTING.
+ * get_event_type() will return Gdk::Event::Type::SETTING.
*/
class EventSetting : public Event
{
- _CLASS_GDKEVENT(EventSetting, GdkEventSetting)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventSetting, GdkEventSetting, Event, GdkEvent)
public:
@@ -852,12 +834,11 @@ public:
* Note that implicit grabs (which are initiated by button presses) can also
* cause Gdk::EventGrabBroken events.
*
- * @c get_event_type() will return @c Gdk::Event::Type::GRAB_BROKEN.
+ * get_event_type() will return Gdk::Event::Type::GRAB_BROKEN.
*/
class EventGrabBroken : public Event
{
- _CLASS_GDKEVENT(EventGrabBroken, GdkEventGrabBroken)
- _GDKEVENT_INHERITS(Event, GdkEvent)
+ _CLASS_GDKEVENT(EventGrabBroken, GdkEventGrabBroken, Event, GdkEvent)
public:
@@ -874,14 +855,14 @@ public:
/**
* Checks whether this event was caused by another grab in the same
- * application. In this case, @c get_grab_window() can be used to acquire the
- * new grab window. The results are undefined if @c has_owner() returns @c
- * false and @c get_grab_window() is called.
+ * application. In this case, get_grab_window() can be used to acquire the
+ * new grab window. The results are undefined if has_grab_window() returns
+ * @c false and get_grab_window() is called.
*/
bool has_grab_window() const;
/**
- * Returns the new grab window. The results are undefined if @c
+ * Returns the new grab window. The results are undefined if
* has_grab_window() would return @c false before the call.
*/
_MEMBER_GET_GOBJECT(grab_window, grab_window, Gdk::Window, GdkWindow*)
diff --git a/tools/m4/class_gdkevent.m4 b/tools/m4/class_gdkevent.m4
index d40b624..bdd46b2 100644
--- a/tools/m4/class_gdkevent.m4
+++ b/tools/m4/class_gdkevent.m4
@@ -1,18 +1,20 @@
-dnl Gdk::Event and subclasses is a specific case where a class hierarchhy
+dnl Gdk::Event and subclasses is a specific case where a class hierarchy
dnl refers to a single pointer to a boxed type in the base class.
dnl
-dnl Add this to Gdk::Event and subclasses (replace Event and GdkEvent with
-dnl the actual name of the class.
+dnl Add this to Gdk::Event (Replace Event and GdkEvent with the actual name
+dnl of the class.)
dnl
dnl _CLASS_GDKEVENT(Event, GdkEvent)
dnl
dnl Add this to any subclass Gdk::Event. This instructs to use the functionality
dnl of the parent class for copying and destruction (note, that creation of new
-dnl events is unsupported). If macro is not defined, gdk_event_copy and
-dnl gdk_event_free are used for these purposes. Replace Event and GdkEvent with
-dnl the identifiers appearing in _CLASS_GDKEVENT of the base class.
+dnl events is unsupported). With only two parameters, gdk_event_copy and
+dnl gdk_event_free are used for these purposes. Replace EventKey and GdkEventKey
+dnl with the actual name of the class, and Event and GdkEvent with the name of
+dnl the base class.
dnl
-dnl _CLASS_GDKEVENT_INHERITS(Event, GdkEvent)
+dnl _CLASS_GDKEVENT(EventKey, GdkEventKey, Event, GdkEvent)
+dnl _CLASS_GDKEVENT(C++ class, C class, C++ base class, C base class)
dnl
define(`_CLASS_GDKEVENT',`dnl
@@ -21,39 +23,30 @@ dnl
dnl Define the args for later macros
define(`__CPPNAME__',`$1')
define(`__CNAME__',`$2')
-
+define(`__CPPPARENT__',`$3')
+define(`__CPARENT__',`$4')
_POP()
_SECTION(SECTION_CLASS2)
') dnl End of _CLASS_GDKEVENT.
-define(`_GDKEVENT_INHERITS',`dnl
-_PUSH()
-dnl Define this macro to be tested for later.
-define(`__GDKEVENT_PARENT_CPPNAME__', `$1')
-define(`__GDKEVENT_PARENT_CNAME__', `$2')
-_POP()
-')
-
dnl
dnl _END_CLASS_GDKEVENT()
dnl denotes the end of a class
dnl
define(`_END_CLASS_GDKEVENT',`
-_SECTION(SECTION_HEADER1)
-
_SECTION(SECTION_HEADER3)
__NAMESPACE_BEGIN__
/**
- * @relates __NAMESPACE__::__CPPNAME__
* @param lhs The left-hand side
* @param rhs The right-hand side
+ *
+ * @relates __NAMESPACE__::__CPPNAME__
*/
-inline void swap(__CPPNAME__& lhs, __CPPNAME__& rhs)
+inline void swap(__CPPNAME__& lhs, __CPPNAME__& rhs) noexcept
{ lhs.swap(rhs); }
-/// @{
/**
* Wraps a C event instance without making unnecessary copy when the ownership
* can not be acquired.
@@ -61,15 +54,21 @@ inline void swap(__CPPNAME__& lhs, __CPPNAME__& rhs)
* The @a event pointer must not be deleted until last usage of the returned
* instance. Note, that this requirement applies to the pointer itself, in
* addition to the object it is pointing to.
+ *
+ * @relates __NAMESPACE__::__CPPNAME__
*/
const __CPPNAME__& wrap_event(const __CNAME__*& event);
+
+/** See wrap_event(const __CNAME__*& event).
+ *
+ * @relates __NAMESPACE__::__CPPNAME__
+ */
__CPPNAME__& wrap_event(__CNAME__*& event);
-/// @}
__NAMESPACE_END__
-namespace Glib {
-
+namespace Glib
+{
ifdef(`__BOOL_NO_WRAP_FUNCTION__',`',`dnl else
/**
@@ -77,7 +76,7 @@ ifdef(`__BOOL_NO_WRAP_FUNCTION__',`',`dnl else
*
* @param object The C instance.
* @param take_copy False if the result should take ownership of the C instance.
- * True if it should take a new copy or ref.
+ * True if it should take a new copy.
* @result A C++ instance that wraps this C instance.
*
* @relates __NAMESPACE__::__CPPNAME__
@@ -107,26 +106,27 @@ __NAMESPACE__::__CPPNAME__ wrap(__CNAME__* object, bool take_copy)
} // namespace Glib
')dnl endif
-
__NAMESPACE_BEGIN__
dnl
dnl The implementation:
dnl
-dnl All events have the same GType
+dnl All events have the same GType. Only the base class need a get_type() method.
+ifelse(__CPPPARENT__,,`dnl
// static
GType __CPPNAME__::get_type()
{
- return gdk_event_get_type();
+ return _GET_TYPE_FUNC(__CNAME__);
}
+')dnl endif not __CPPPARENT__
__CPPNAME__::__CPPNAME__`'()
:
-ifdef(`__GDKEVENT_PARENT_CPPNAME__',`dnl
- __GDKEVENT_PARENT_CPPNAME__`'()
-',`dnl else
+ifelse(__CPPPARENT__,,`dnl base class
gobject_(nullptr)
+',`dnl else, i.e. subclass
+ __CPPPARENT__`'()
')dnl endif
{
}
@@ -136,20 +136,27 @@ __CPPNAME__::__CPPNAME__`'(__CNAME__* gobject, bool make_a_copy)
// For Event wrappers, make_a_copy is false by default. The static
// Event wrappers must not take a copy, thus make_a_copy = false
// ensures identical behaviour if the default argument is used.
-ifdef(`__GDKEVENT_PARENT_CPPNAME__',`dnl
- __GDKEVENT_PARENT_CPPNAME__`'(reinterpret_cast<__GDKEVENT_PARENT_CNAME__*>(gobject), make_a_copy)
-',`dnl else
+ifelse(__CPPPARENT__,,`dnl base class
gobject_((make_a_copy && gobject) ? gdk_event_copy(gobject) : gobject)
+',`dnl else i.e. subclass
+ __CPPPARENT__`'(reinterpret_cast<__CPARENT__*>(gobject), make_a_copy)
')dnl endif
{}
-ifdef(`__GDKEVENT_PARENT_CPPNAME__',`',`dnl We need those functions only for Gdk::Event
+ifelse(__CPPPARENT__,`',`dnl We need those functions only for Gdk::Event
__CPPNAME__::__CPPNAME__`'(const __CPPNAME__& other)
:
gobject_((other.gobject_) ? gdk_event_copy(other.gobject_) : nullptr)
{}
+__CPPNAME__::__CPPNAME__`'(__CPPNAME__&& other) noexcept
+:
+ gobject_(other.gobject_)
+{
+ other.gobject_ = nullptr;
+}
+
__CPPNAME__& __CPPNAME__::operator=(const __CPPNAME__`'& other)
{
__CPPNAME__ temp(other);
@@ -157,49 +164,54 @@ __CPPNAME__& __CPPNAME__::operator=(const __CPPNAME__`'& other)
return *this;
}
-__CPPNAME__::~__CPPNAME__`'()
+__CPPNAME__& __CPPNAME__::operator=(__CPPNAME__`'&& other) noexcept
+{
+ __CPPNAME__ temp(std::move(other));
+ swap(temp);
+ return *this;
+}
+
+__CPPNAME__::~__CPPNAME__`'() noexcept
{
- if(gobject_) {
+ if (gobject_)
gdk_event_free(gobject_);
- }
}
-')dnl endif
+')dnl endif not __CPPPARENT__
-void __CPPNAME__::swap(__CPPNAME__& other)
+void __CPPNAME__::swap(__CPPNAME__& other) noexcept
{
-ifdef(`__GDKEVENT_PARENT_CPPNAME__',`dnl
- __GDKEVENT_PARENT_CPPNAME__::swap(other);
-',`dnl else
+ifelse(__CPPPARENT__,,`dnl base class
__CNAME__ *const temp = gobject_;
gobject_ = other.gobject_;
other.gobject_ = temp;
+',`dnl else i.e. subclass
+ __CPPPARENT__::swap(other);
')dnl endif
}
__CNAME__* __CPPNAME__::gobj_copy() const
{
-ifdef(`__GDKEVENT_PARENT_CPPNAME__',`dnl
- return reinterpret_cast<__CNAME__*>(__GDKEVENT_PARENT_CPPNAME__::gobj_copy());
-',`dnl else
+ifelse(__CPPPARENT__,,`dnl base class
return gdk_event_copy(gobject_);
+',`dnl else i.e. subclass
+ return reinterpret_cast<__CNAME__*>(__CPPPARENT__::gobj_copy());
')dnl endif
}
const __CPPNAME__& wrap_event(const __CNAME__*& event)
{
- return reinterpret_cast<const __CPPNAME__&>(*event);
+ return reinterpret_cast<const __CPPNAME__&>(event);
}
__CPPNAME__& wrap_event(__CNAME__*& event)
{
- return reinterpret_cast<__CPPNAME__&>(*event);
+ return reinterpret_cast<__CPPNAME__&>(event);
}
_IMPORT(SECTION_CC)
__NAMESPACE_END__
-
dnl
dnl
_POP()
@@ -209,18 +221,14 @@ dnl
_IMPORT(SECTION_CLASS1)
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
- typedef __CPPNAME__ CppObjectType;
- typedef __CNAME__ BaseObjectType;
+ using CppObjectType = __CPPNAME__;
+ using BaseObjectType = __CNAME__;
+ifelse(__CPPPARENT__,,`dnl base class
static GType get_type() G_GNUC_CONST;
+')dnl
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
-ifdef(`__GDKEVENT_PARENT_CPPNAME__',`', `dnl else Only add for Gdk::Event
-private:
- __CNAME__* gobject_;
-public:
-')dnl endif
-
/**
* Creates an invalid event object. Calling any member functions is undefined
* behavior.
@@ -229,45 +237,50 @@ public:
/**
* Wraps a C event instance. This constructor either acquires ownership of
- * @c gobject, or copies it.
+ * @a gobject, or copies it.
*
- * @param gobject Event to wrap
- * @param make_a_copy if @c false, the ownership of @c gobject is acquired,
+ * @param gobject %Event to wrap.
+ * @param make_a_copy If @c false, the ownership of @a gobject is acquired,
* otherwise, a copy is made.
*/
explicit __CPPNAME__`'(__CNAME__* gobject, bool make_a_copy = false);
-
-ifdef(`__GDKEVENT_PARENT_CPPNAME__',`', `dnl else Only add for Gdk::Event
+ifelse(__CPPPARENT__,`',`dnl Only add for Gdk::Event
__CPPNAME__`'(const __CPPNAME__& other);
__CPPNAME__& operator=(const __CPPNAME__& other);
-_IMPORT(SECTION_DTOR_DOCUMENTATION)
- ~__CPPNAME__`'();
+ __CPPNAME__`'(__CPPNAME__&& other) noexcept;
+ __CPPNAME__& operator=(__CPPNAME__&& other) noexcept;
+_IMPORT(SECTION_DTOR_DOCUMENTATION)
+ ~__CPPNAME__`'() noexcept;
')dnl endif
- void swap(__CPPNAME__& other);
+ void swap(__CPPNAME__& other) noexcept;
-ifdef(`__GDKEVENT_PARENT_CPPNAME__',`dnl
- /// Provides access to the underlying C instance.
- __CNAME__* gobj() { return reinterpret_cast<__CNAME__*>(__GDKEVENT_PARENT_CPPNAME__::gobj()); }
-
- /// Provides access to the underlying C instance.
- const __CNAME__* gobj() const { return reinterpret_cast<const
__CNAME__*>(__GDKEVENT_PARENT_CPPNAME__::gobj()); }
-',`dnl else
+ifelse(__CPPPARENT__,,`dnl
///Provides access to the underlying C instance.
__CNAME__* gobj() { return gobject_; }
///Provides access to the underlying C instance.
const __CNAME__* gobj() const { return gobject_; }
+',`dnl else
+ /// Provides access to the underlying C instance.
+ __CNAME__* gobj() { return reinterpret_cast<__CNAME__*>(__CPPPARENT__::gobj()); }
+
+ /// Provides access to the underlying C instance.
+ const __CNAME__* gobj() const { return reinterpret_cast<const __CNAME__*>(__CPPPARENT__::gobj()); }
')dnl endif
+
/**
* Provides access to the underlying C instance. The caller is responsible for
- * freeing it with @c gdk_event_free. Use when directly setting fields in structs.
+ * freeing it with gdk_event_free(). Use when directly setting fields in structs.
*/
__CNAME__* gobj_copy() const;
private:
+ifelse(__CPPPARENT__,`',`dnl Only add for Gdk::Event
+ __CNAME__* gobject_;
+')dnl
_IMPORT(SECTION_CLASS2)
')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]