[vlc-devel] commit: Use the cpp to auto-update libvlc_event_type_name()'s dictionary. ( JP Dinger )
git version control
git at videolan.org
Tue Sep 1 18:00:22 CEST 2009
vlc | branch: master | JP Dinger <jpd at videolan.org> | Mon Aug 3 13:50:15 2009 +0200| [96a96f60bb0d1f2506e68b356897ceca6f6b586d] | committer: JP Dinger
Use the cpp to auto-update libvlc_event_type_name()'s dictionary.
This breaks the new python bindings' trawling of the source.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=96a96f60bb0d1f2506e68b356897ceca6f6b586d
---
include/vlc/libvlc_events.h | 131 +++++++++++++++++++++++--------------------
src/control/event.c | 60 ++++----------------
2 files changed, 82 insertions(+), 109 deletions(-)
diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index 649fffa..021ad9a 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -17,9 +17,9 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef LIBVLC_EVENTS_H
@@ -44,70 +44,81 @@ extern "C" {
* @{
*/
+ /* Append new event types at the end. Do not remove, insert or
+ * re-order any entry. The cpp will prepend libvlc_ to the symbols. */
+#define DEFINE_LIBVLC_EVENT_TYPES \
+ DEF( MediaMetaChanged ), \
+ DEF( MediaSubItemAdded ), \
+ DEF( MediaDurationChanged ), \
+ DEF( MediaPreparsedChanged ), \
+ DEF( MediaFreed ), \
+ DEF( MediaStateChanged ), \
+ \
+ DEF( MediaPlayerNothingSpecial ), \
+ DEF( MediaPlayerOpening ), \
+ DEF( MediaPlayerBuffering ), \
+ DEF( MediaPlayerPlaying ), \
+ DEF( MediaPlayerPaused ), \
+ DEF( MediaPlayerStopped ), \
+ DEF( MediaPlayerForward ), \
+ DEF( MediaPlayerBackward ), \
+ DEF( MediaPlayerEndReached ), \
+ DEF( MediaPlayerEncounteredError ), \
+ DEF( MediaPlayerTimeChanged ), \
+ DEF( MediaPlayerPositionChanged ), \
+ DEF( MediaPlayerSeekableChanged ), \
+ DEF( MediaPlayerPausableChanged ), \
+ \
+ DEF( MediaListItemAdded ), \
+ DEF( MediaListWillAddItem ), \
+ DEF( MediaListItemDeleted ), \
+ DEF( MediaListWillDeleteItem ), \
+ \
+ DEF( MediaListViewItemAdded ), \
+ DEF( MediaListViewWillAddItem ), \
+ DEF( MediaListViewItemDeleted ), \
+ DEF( MediaListViewWillDeleteItem ), \
+ \
+ DEF( MediaListPlayerPlayed ), \
+ DEF( MediaListPlayerNextItemSet ), \
+ DEF( MediaListPlayerStopped ), \
+ \
+ DEF( MediaDiscovererStarted ), \
+ DEF( MediaDiscovererEnded ), \
+ \
+ DEF( MediaPlayerTitleChanged ), \
+ DEF( MediaPlayerSnapshotTaken ), \
+ DEF( MediaPlayerLengthChanged ), \
+ \
+ DEF( VlmMediaAdded ), \
+ DEF( VlmMediaRemoved ), \
+ DEF( VlmMediaChanged ), \
+ DEF( VlmMediaInstanceStarted ), \
+ DEF( VlmMediaInstanceStopped ), \
+ DEF( VlmMediaInstanceStatusInit ), \
+ DEF( VlmMediaInstanceStatusOpening ), \
+ DEF( VlmMediaInstanceStatusPlaying ), \
+ DEF( VlmMediaInstanceStatusPause ), \
+ DEF( VlmMediaInstanceStatusEnd ), \
+ DEF( VlmMediaInstanceStatusError ), \
+ /* New event types HERE */
+
#ifdef __cplusplus
enum libvlc_event_type_e {
#else
enum libvlc_event_type_t {
#endif
- /* Append new event types at the end.
- * Do not remove, insert or re-order any entry. */
- libvlc_MediaMetaChanged,
- libvlc_MediaSubItemAdded,
- libvlc_MediaDurationChanged,
- libvlc_MediaPreparsedChanged,
- libvlc_MediaFreed,
- libvlc_MediaStateChanged,
-
- libvlc_MediaPlayerNothingSpecial,
- libvlc_MediaPlayerOpening,
- libvlc_MediaPlayerBuffering,
- libvlc_MediaPlayerPlaying,
- libvlc_MediaPlayerPaused,
- libvlc_MediaPlayerStopped,
- libvlc_MediaPlayerForward,
- libvlc_MediaPlayerBackward,
- libvlc_MediaPlayerEndReached,
- libvlc_MediaPlayerEncounteredError,
- libvlc_MediaPlayerTimeChanged,
- libvlc_MediaPlayerPositionChanged,
- libvlc_MediaPlayerSeekableChanged,
- libvlc_MediaPlayerPausableChanged,
-
- libvlc_MediaListItemAdded,
- libvlc_MediaListWillAddItem,
- libvlc_MediaListItemDeleted,
- libvlc_MediaListWillDeleteItem,
-
- libvlc_MediaListViewItemAdded,
- libvlc_MediaListViewWillAddItem,
- libvlc_MediaListViewItemDeleted,
- libvlc_MediaListViewWillDeleteItem,
-
- libvlc_MediaListPlayerPlayed,
- libvlc_MediaListPlayerNextItemSet,
- libvlc_MediaListPlayerStopped,
-
- libvlc_MediaDiscovererStarted,
- libvlc_MediaDiscovererEnded,
-
- libvlc_MediaPlayerTitleChanged,
- libvlc_MediaPlayerSnapshotTaken,
- libvlc_MediaPlayerLengthChanged,
-
- libvlc_VlmMediaAdded,
- libvlc_VlmMediaRemoved,
- libvlc_VlmMediaChanged,
- libvlc_VlmMediaInstanceStarted,
- libvlc_VlmMediaInstanceStopped,
- libvlc_VlmMediaInstanceStatusInit,
- libvlc_VlmMediaInstanceStatusOpening,
- libvlc_VlmMediaInstanceStatusPlaying,
- libvlc_VlmMediaInstanceStatusPause,
- libvlc_VlmMediaInstanceStatusEnd,
- libvlc_VlmMediaInstanceStatusError,
- /* New event types HERE */
+#define DEF(a) libvlc_##a
+ DEFINE_LIBVLC_EVENT_TYPES
+ libvlc_num_event_types
+#undef DEF
};
+/* Implementing libvlc_event_type_name() needs the definition too. */
+#ifndef LIBVLC_EVENT_TYPES_KEEP_DEFINE
+#undef DEFINE_LIBVLC_EVENT_TYPES
+#endif
+
/**
* An Event
* \param type the even type
diff --git a/src/control/event.c b/src/control/event.c
index 724bd5d..c368c1a 100644
--- a/src/control/event.c
+++ b/src/control/event.c
@@ -17,15 +17,16 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#define LIBVLC_EVENT_TYPES_KEEP_DEFINE
#include <vlc/libvlc.h>
#include "libvlc_internal.h"
@@ -250,58 +251,19 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,
*
* Get the char * name of an event type.
**************************************************************************/
-static const char event_type_to_name[][35] =
+static const char event_type_to_name[][libvlc_num_event_types] =
{
-#define EVENT(a) [a]=#a
- EVENT(libvlc_MediaMetaChanged),
- EVENT(libvlc_MediaSubItemAdded),
- EVENT(libvlc_MediaDurationChanged),
- EVENT(libvlc_MediaPreparsedChanged),
- EVENT(libvlc_MediaFreed),
- EVENT(libvlc_MediaStateChanged),
-
- EVENT(libvlc_MediaPlayerNothingSpecial),
- EVENT(libvlc_MediaPlayerOpening),
- EVENT(libvlc_MediaPlayerBuffering),
- EVENT(libvlc_MediaPlayerPlaying),
- EVENT(libvlc_MediaPlayerPaused),
- EVENT(libvlc_MediaPlayerStopped),
- EVENT(libvlc_MediaPlayerForward),
- EVENT(libvlc_MediaPlayerBackward),
- EVENT(libvlc_MediaPlayerEndReached),
- EVENT(libvlc_MediaPlayerTimeChanged),
- EVENT(libvlc_MediaPlayerTitleChanged),
- EVENT(libvlc_MediaPlayerPositionChanged),
- EVENT(libvlc_MediaPlayerSeekableChanged),
- EVENT(libvlc_MediaPlayerPausableChanged),
-
- EVENT(libvlc_MediaListItemAdded),
- EVENT(libvlc_MediaListWillAddItem),
- EVENT(libvlc_MediaListItemDeleted),
- EVENT(libvlc_MediaListWillDeleteItem),
-
- EVENT(libvlc_MediaListViewItemAdded),
- EVENT(libvlc_MediaListViewWillAddItem),
- EVENT(libvlc_MediaListViewItemDeleted),
- EVENT(libvlc_MediaListViewWillDeleteItem),
-
- EVENT(libvlc_MediaListPlayerPlayed),
- EVENT(libvlc_MediaListPlayerNextItemSet),
- EVENT(libvlc_MediaListPlayerStopped),
-
- EVENT(libvlc_MediaDiscovererStarted),
- EVENT(libvlc_MediaDiscovererEnded),
-
- EVENT(libvlc_MediaPlayerSnapshotTaken),
-#undef EVENT
+#define DEF(a) [libvlc_##a]=#a
+ DEFINE_LIBVLC_EVENT_TYPES
+#undef DEF
};
-static const char unkwown_event_name[] = "Unknown Event";
+static const char unknown_event_name[] = "Unknown Event";
const char * libvlc_event_type_name( libvlc_event_type_t event_type )
{
- if( event_type >= sizeof(event_type_to_name)/sizeof(event_type_to_name[0]))
- return unkwown_event_name;
+ if( event_type >= libvlc_num_event_types )
+ return unknown_event_name;
return event_type_to_name[event_type];
}
More information about the vlc-devel
mailing list