* SOFTWARE.
*/
-/* For bt_component_class, bt_component_class_filter */
+/*
+ * For bt_component_class, bt_component_class_filter,
+ * __BT_UPCAST_CONST
+ */
#include <babeltrace/types.h>
#ifdef __cplusplus
bt_component_class_filter_as_component_class_const(
const bt_component_class_filter *comp_cls_filter)
{
- return (const void *) comp_cls_filter;
+ return __BT_UPCAST_CONST(bt_component_class, comp_cls_filter);
}
extern void bt_component_class_filter_get_ref(
* bt_port_output, bt_query_executor, bt_self_component_class_filter,
* bt_self_component_filter, bt_self_component_port_input,
* bt_self_component_port_output, bt_value, bt_message_array_const,
- * bt_bool, bt_self_message_iterator
+ * bt_bool, bt_self_message_iterator, __BT_UPCAST
*/
#include <babeltrace/types.h>
bt_component_class *bt_component_class_filter_as_component_class(
bt_component_class_filter *comp_cls_filter)
{
- return (void *) comp_cls_filter;
+ return __BT_UPCAST(bt_component_class, comp_cls_filter);
}
extern
* SOFTWARE.
*/
-/* For bt_component_class, bt_component_class_sink */
+/* For bt_component_class, bt_component_class_sink, __BT_UPCAST_CONST */
#include <babeltrace/types.h>
#ifdef __cplusplus
bt_component_class_sink_as_component_class_const(
const bt_component_class_sink *comp_cls_sink)
{
- return (const void *) comp_cls_sink;
+ return __BT_UPCAST_CONST(bt_component_class, comp_cls_sink);
}
extern void bt_component_class_sink_get_ref(
/*
* For bt_component_class, bt_component_class_sink, bt_port_output,
* bt_query_executor, bt_self_component_class_sink,
- * bt_self_component_sink, bt_self_component_port_input, bt_value
+ * bt_self_component_sink, bt_self_component_port_input, bt_value,
+ * __BT_UPCAST
*/
#include <babeltrace/types.h>
bt_component_class *bt_component_class_sink_as_component_class(
bt_component_class_sink *comp_cls_sink)
{
- return (void *) comp_cls_sink;
+ return __BT_UPCAST(bt_component_class, comp_cls_sink);
}
extern
* SOFTWARE.
*/
-/* For bt_component_class, bt_component_class_source */
+/*
+ * For bt_component_class, bt_component_class_source,
+ * __BT_UPCAST_CONST
+ */
#include <babeltrace/types.h>
#ifdef __cplusplus
bt_component_class_source_as_component_class_const(
const bt_component_class_source *comp_cls_source)
{
- return (const void *) comp_cls_source;
+ return __BT_UPCAST_CONST(bt_component_class, comp_cls_source);
}
extern void bt_component_class_source_get_ref(
* For bt_component_class, bt_component_class_source, bt_port_input,
* bt_query_executor, bt_self_component_class_source,
* bt_self_component_source, bt_self_component_port_output, bt_value,
- * bt_message_array_const, bt_bool, bt_self_message_iterator
+ * bt_message_array_const, bt_bool, bt_self_message_iterator,
+ * __BT_UPCAST
*/
#include <babeltrace/types.h>
bt_component_class *bt_component_class_source_as_component_class(
bt_component_class_source *comp_cls_source)
{
- return (void *) comp_cls_source;
+ return __BT_UPCAST(bt_component_class, comp_cls_source);
}
extern
#include <stdint.h>
-/* For bt_component, bt_component_filter, bt_port_input, bt_port_output */
+/*
+ * For bt_component, bt_component_filter, bt_port_input, bt_port_output,
+ * __BT_UPCAST_CONST
+ */
#include <babeltrace/types.h>
#ifdef __cplusplus
const bt_component *bt_component_filter_as_component_const(
const bt_component_filter *component)
{
- return (const void *) component;
+ return __BT_UPCAST_CONST(bt_component, component);
}
extern uint64_t bt_component_filter_get_input_port_count(
#include <stdint.h>
-/* For bt_component, bt_component_filter, bt_port_input */
+/*
+ * For bt_component, bt_component_filter, bt_port_input,
+ * __BT_UPCAST_CONST
+ */
#include <babeltrace/types.h>
#ifdef __cplusplus
const bt_component *bt_component_sink_as_component_const(
const bt_component_sink *component)
{
- return (const void *) component;
+ return __BT_UPCAST_CONST(bt_component, component);
}
extern uint64_t bt_component_sink_get_input_port_count(
#include <stdint.h>
-/* For bt_component, bt_component_filter, bt_port_output */
+/*
+ * For bt_component, bt_component_filter, bt_port_output,
+ * __BT_UPCAST_CONST
+ */
#include <babeltrace/types.h>
#ifdef __cplusplus
const bt_component *bt_component_source_as_component_const(
const bt_component_source *component)
{
- return (void *) component;
+ return __BT_UPCAST_CONST(bt_component, component);
}
extern uint64_t bt_component_source_get_output_port_count(
* SOFTWARE.
*/
-/* For bt_port, bt_port_input */
+/* For bt_port, bt_port_input, __BT_UPCAST_CONST */
#include <babeltrace/types.h>
#include <stdint.h>
static inline
const bt_port *bt_port_input_as_port_const(const bt_port_input *port_input)
{
- return (const void *) port_input;
+ return __BT_UPCAST_CONST(bt_port, port_input);
}
extern void bt_port_input_get_ref(const bt_port_input *port_input);
* SOFTWARE.
*/
-/* For bt_port, bt_port_output */
+/* For bt_port, bt_port_output, __BT_UPCAST_CONST */
#include <babeltrace/types.h>
#include <stdint.h>
static inline
const bt_port *bt_port_output_as_port_const(const bt_port_output *port_output)
{
- return (const void *) port_output;
+ return __BT_UPCAST_CONST(bt_port, port_output);
}
extern void bt_port_output_get_ref(const bt_port_output *port_output);
/*
* For bt_port, bt_message, bt_message_iterator,
* bt_port_output_message_iterator, bt_graph, bt_port_output,
- * bt_message_array_const, bt_bool
+ * bt_message_array_const, bt_bool, __BT_UPCAST
*/
#include <babeltrace/types.h>
bt_port_output_message_iterator_as_message_iterator(
bt_port_output_message_iterator *iterator)
{
- return (void *) iterator;
+ return __BT_UPCAST(bt_message_iterator, iterator);
}
extern bt_port_output_message_iterator *
* SOFTWARE.
*/
-/* For bt_component_class_filter, bt_self_component_class_filter */
+/*
+ * For bt_component_class_filter, bt_self_component_class_filter,
+ * __BT_UPCAST_CONST
+ */
#include <babeltrace/types.h>
#ifdef __cplusplus
bt_self_component_class_filter_as_component_class_filter(
bt_self_component_class_filter *self_comp_cls_filter)
{
- return (const void *) self_comp_cls_filter;
+ return __BT_UPCAST_CONST(bt_component_class_filter,
+ self_comp_cls_filter);
}
#ifdef __cplusplus
* SOFTWARE.
*/
-/* For bt_component_class_sink, bt_self_component_class_sink */
+/*
+ * For bt_component_class_sink, bt_self_component_class_sink,
+ * __BT_UPCAST_CONST
+ */
#include <babeltrace/types.h>
#ifdef __cplusplus
bt_self_component_class_sink_as_component_class_sink(
bt_self_component_class_sink *self_comp_cls_sink)
{
- return (const void *) self_comp_cls_sink;
+ return __BT_UPCAST_CONST(bt_component_class_sink, self_comp_cls_sink);
}
#ifdef __cplusplus
* SOFTWARE.
*/
-/* For bt_component_class_source, bt_self_component_class_source */
+/*
+ * For bt_component_class_source, bt_self_component_class_source,
+ * __BT_UPCAST_CONST
+ */
#include <babeltrace/types.h>
#ifdef __cplusplus
bt_self_component_class_source_as_component_class_source(
bt_self_component_class_source *self_comp_cls_source)
{
- return (const void *) self_comp_cls_source;
+ return __BT_UPCAST_CONST(bt_component_class_source,
+ self_comp_cls_source);
}
#ifdef __cplusplus
/*
* For bt_component_filter, bt_self_component, bt_self_component_filter,
- * bt_self_component_port_input, bt_self_component_port_output
+ * bt_self_component_port_input, bt_self_component_port_output,
+ * __BT_UPCAST, __BT_UPCAST_CONST
*/
#include <babeltrace/types.h>
bt_self_component *bt_self_component_filter_as_self_component(
bt_self_component_filter *self_comp_filter)
{
- return (void *) self_comp_filter;
+ return __BT_UPCAST(bt_self_component, self_comp_filter);
}
static inline
bt_self_component_filter_as_component_filter(
bt_self_component_filter *self_comp_filter)
{
- return (const void *) self_comp_filter;
+ return __BT_UPCAST_CONST(bt_component_filter, self_comp_filter);
}
extern bt_self_component_port_output *
/*
* For bt_component, bt_message_iterator,
* bt_self_component_port_input_message_iterator,
- * bt_self_component_port_input, bt_message_array_const, bt_bool
+ * bt_self_component_port_input, bt_message_array_const, bt_bool,
+ * __BT_UPCAST
*/
#include <babeltrace/types.h>
bt_self_component_port_input_message_iterator_as_message_iterator(
bt_self_component_port_input_message_iterator *iterator)
{
- return (void *) iterator;
+ return __BT_UPCAST(bt_message_iterator, iterator);
}
extern bt_self_component_port_input_message_iterator *
/*
* For bt_port_input, bt_self_component_port,
- * bt_self_component_port_input
+ * bt_self_component_port_input, __BT_UPCAST, __BT_UPCAST_CONST
*/
#include <babeltrace/types.h>
bt_self_component_port_input_as_self_component_port(
bt_self_component_port_input *self_component_port)
{
- return (void *) self_component_port;
+ return __BT_UPCAST(bt_self_component_port, self_component_port);
}
static inline
const bt_port_input *bt_self_component_port_input_as_port_input(
const bt_self_component_port_input *self_component_port)
{
- return (const void *) self_component_port;
+ return __BT_UPCAST_CONST(bt_port_input, self_component_port);
}
#ifdef __cplusplus
/*
* For bt_port_output, bt_self_component_port,
- * bt_self_component_port_output
+ * bt_self_component_port_output, __BT_UPCAST, __BT_UPCAST_CONST
*/
#include <babeltrace/types.h>
bt_self_component_port_output_as_self_component_port(
bt_self_component_port_output *self_component_port)
{
- return (void *) self_component_port;
+ return __BT_UPCAST(bt_self_component_port, self_component_port);
}
static inline
const bt_port_output *bt_self_component_port_output_as_port_output(
bt_self_component_port_output *self_component_port)
{
- return (const void *) self_component_port;
+ return __BT_UPCAST_CONST(bt_port_output, self_component_port);
}
#ifdef __cplusplus
*/
/*
- * For bt_port, bt_self_component_port, bt_self_component, bt_connection
+ * For bt_port, bt_self_component_port, bt_self_component,
+ * bt_connection, __BT_UPCAST_CONST
*/
#include <babeltrace/types.h>
const bt_port *bt_self_component_port_as_port(
bt_self_component_port *self_port)
{
- return (const void *) self_port;
+ return __BT_UPCAST_CONST(bt_port, self_port);
}
extern bt_self_component *bt_self_component_port_borrow_component(
/*
* For bt_component_sink, bt_self_component, bt_self_component_sink,
- * bt_self_component_port_input
+ * bt_self_component_port_input, __BT_UPCAST, __BT_UPCAST_CONST
*/
#include <babeltrace/types.h>
bt_self_component *bt_self_component_sink_as_self_component(
bt_self_component_sink *self_comp_sink)
{
- return (void *) self_comp_sink;
+ return __BT_UPCAST(bt_self_component, self_comp_sink);
}
static inline
bt_self_component_sink_as_component_sink(
bt_self_component_sink *self_comp_sink)
{
- return (const void *) self_comp_sink;
+ return __BT_UPCAST_CONST(bt_component_sink, self_comp_sink);
}
extern bt_self_component_port_input *
/*
* For bt_component_source, bt_self_component, bt_self_component_source,
- * bt_self_component_port_output
+ * bt_self_component_port_output, __BT_UPCAST, __BT_UPCAST_CONST
*/
#include <babeltrace/types.h>
bt_self_component *bt_self_component_source_as_self_component(
bt_self_component_source *self_comp_source)
{
- return (void *) self_comp_source;
+ return __BT_UPCAST(bt_self_component, self_comp_source);
}
static inline
bt_self_component_source_as_component_source(
bt_self_component_source *self_comp_source)
{
- return (const void *) self_comp_source;
+ return __BT_UPCAST_CONST(bt_component_source, self_comp_source);
}
extern bt_self_component_port_output *
* SOFTWARE.
*/
-/* For bt_component, bt_self_component */
+/* For bt_component, bt_self_component, __BT_UPCAST */
#include <babeltrace/types.h>
#ifdef __cplusplus
const bt_component *bt_self_component_as_component(
bt_self_component *self_component)
{
- return (const void *) self_component;
+ return __BT_UPCAST(bt_component, self_component);
}
extern void *bt_self_component_get_data(
* bt_field_class_enumeration_mapping,
* bt_field_class_unsigned_enumeration_mapping,
* bt_field_class_signed_enumeration_mapping,
- * bt_field_class_enumeration_mapping_label_array
+ * bt_field_class_enumeration_mapping_label_array, __BT_UPCAST_CONST
*/
#include <babeltrace/types.h>
bt_field_class_unsigned_enumeration_mapping_as_mapping_const(
const bt_field_class_unsigned_enumeration_mapping *mapping)
{
- return (const void *) mapping;
+ return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
}
static inline
bt_field_class_signed_enumeration_mapping_as_mapping_const(
const bt_field_class_signed_enumeration_mapping *mapping)
{
- return (const void *) mapping;
+ return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
}
extern const char *bt_field_class_enumeration_mapping_get_label(
#include <stdint.h>
+/* Internal use */
+#ifdef __cplusplus
+# define __BT_UPCAST(_type, _p) static_cast<_type *>(static_cast<void *>(_p))
+# define __BT_UPCAST_CONST(_type, _p) static_cast<const _type *>(static_cast<const void *>(_p))
+#else
+# define __BT_UPCAST(_type, _p) ((_type *) (_p))
+# define __BT_UPCAST_CONST(_type, _p) ((const _type *) (_p))
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif