}
}
+/* Typemaps used for user data attached to self component ports. */
+
+/*
+ * The user data Python object is kept as the user data of the port, we pass
+ * the PyObject pointer directly to the port creation function.
+ */
+%typemap(in) void *PY_SELF_PORT_USER_DATA {
+ $1 = $input;
+}
+
+/*
+ * The port, if created successfully, now owns a reference to the Python object,
+ * we reflect that here.
+ */
+%typemap(argout) void *PY_SELF_PORT_USER_DATA {
+ if (PyLong_AsLong($result) == BT_SELF_COMPONENT_STATUS_OK) {
+ Py_INCREF($1);
+ }
+}
+
/* From component-const.h */
extern const char *bt_component_get_name(const bt_component *component);
const bt_component *bt_component_source_as_component_const(
const bt_component_source *component);
+extern const bt_component_class_source *
+bt_component_source_borrow_class_const(
+ const bt_component_source *component);
+
extern uint64_t bt_component_source_get_output_port_count(
const bt_component_source *component);
const bt_component *bt_component_filter_as_component_const(
const bt_component_filter *component);
+extern const bt_component_class_filter *
+bt_component_filter_borrow_class_const(
+ const bt_component_filter *component);
+
extern uint64_t bt_component_filter_get_input_port_count(
const bt_component_filter *component);
const bt_component *bt_component_sink_as_component_const(
const bt_component_sink *component);
+extern const bt_component_class_sink *
+bt_component_sink_borrow_class_const(
+ const bt_component_sink *component);
+
extern uint64_t bt_component_sink_get_input_port_count(
const bt_component_sink *component);
extern bt_self_component_status
bt_self_component_source_add_output_port(
bt_self_component_source *self_component,
- const char *name, void *user_data,
+ const char *name, void *PY_SELF_PORT_USER_DATA,
bt_self_component_port_output **OUT);
/* From self-component-filter.h */
extern bt_self_component_status
bt_self_component_filter_add_output_port(
bt_self_component_filter *self_component,
- const char *name, void *data,
+ const char *name, void *PY_SELF_PORT_USER_DATA,
bt_self_component_port_output **OUT);
extern bt_self_component_port_input *
extern bt_self_component_status
bt_self_component_filter_add_input_port(
bt_self_component_filter *self_component,
- const char *name, void *data,
+ const char *name, void *PY_SELF_PORT_USER_DATA,
bt_self_component_port_input **OUT);
/* From self-component-sink.h */
extern bt_self_component_status
bt_self_component_sink_add_input_port(
bt_self_component_sink *self_component,
- const char *name, void *user_data,
+ const char *name, void *PY_SELF_PORT_USER_DATA,
bt_self_component_port_input **OUT);