[vlc-commits] objects: make VLC_OBJECT() type-safe in C++

Rémi Denis-Courmont git at videolan.org
Sun Apr 14 20:35:24 CEST 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr 14 21:25:32 2019 +0300| [e6a187504c6785d50db026fbadad0deca5b07051] | committer: Rémi Denis-Courmont

objects: make VLC_OBJECT() type-safe in C++

(again)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e6a187504c6785d50db026fbadad0deca5b07051
---

 include/vlc_objects.h | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/include/vlc_objects.h b/include/vlc_objects.h
index 908d7a3037..47ee06822b 100644
--- a/include/vlc_objects.h
+++ b/include/vlc_objects.h
@@ -64,10 +64,39 @@ struct vlc_common_members
     _Generic((x)->obj, \
         struct vlc_common_members: (vlc_object_t *)(x) \
     )
+# define vlc_object_cast(t)
 #else
-# define VLC_OBJECT(x) ((vlc_object_t *)(x))
+# define vlc_object_cast(t) \
+struct t; \
+static inline struct vlc_object_t *VLC_OBJECT(struct t *d) \
+{ \
+    return (struct vlc_object_t *)d; \
+}
 #endif
 
+vlc_object_cast(vlc_object_t)
+vlc_object_cast(libvlc_int_t)
+vlc_object_cast(intf_thread_t)
+vlc_object_cast(vlc_player_t)
+vlc_object_cast(playlist_t)
+vlc_object_cast(input_thread_t)
+vlc_object_cast(stream_t)
+vlc_object_cast(decoder_t)
+vlc_object_cast(filter_t)
+vlc_object_cast(audio_output)
+vlc_object_cast(vout_thread_t)
+vlc_object_cast(vout_display_t)
+vlc_object_cast(vout_window_t)
+vlc_object_cast(sout_instance_t)
+vlc_object_cast(sout_stream_t)
+vlc_object_cast(sout_access_out_t)
+vlc_object_cast(extensions_manager_t)
+vlc_object_cast(fingerprinter_thread_t)
+vlc_object_cast(demux_meta_t)
+vlc_object_cast(xml_t)
+vlc_object_cast(services_discovery_t)
+vlc_object_cast(vlc_renderer_discovery_t)
+
 /*****************************************************************************
  * The vlc_object_t type. Yes, it's that simple :-)
  *****************************************************************************/



More information about the vlc-commits mailing list