]> git.sesse.net Git - vlc/commitdiff
Use the cpp to auto-update libvlc_event_type_name()'s dictionary.
authorJP Dinger <jpd@videolan.org>
Mon, 3 Aug 2009 11:50:15 +0000 (13:50 +0200)
committerJP Dinger <jpd@videolan.org>
Tue, 1 Sep 2009 15:59:52 +0000 (17:59 +0200)
This breaks the new python bindings' trawling of the source.

include/vlc/libvlc_events.h
src/control/event.c

index 649fffa2d627623cfb5f9cac234a5364b318f8e4..021ad9a5df14f415d05d4a6093501f45563509ce 100644 (file)
@@ -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
index 724bd5dd058f3bd9b82af2413e430bccd913ab16..c368c1a0d7b1b66d89596456745428a211d59da9 100644 (file)
  * 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];
 }