static
bt_component_class_init_method_status component_class_source_init(
bt_self_component_source *self_component_source,
+ bt_self_component_source_configuration *config,
const bt_value *params, void *init_method_data)
{
bt_self_component *self_component = bt_self_component_source_as_self_component(self_component_source);
static
bt_component_class_init_method_status component_class_filter_init(
bt_self_component_filter *self_component_filter,
+ bt_self_component_filter_configuration *config,
const bt_value *params, void *init_method_data)
{
bt_self_component *self_component = bt_self_component_filter_as_self_component(self_component_filter);
static
bt_component_class_init_method_status component_class_sink_init(
bt_self_component_sink *self_component_sink,
+ bt_self_component_sink_configuration *config,
const bt_value *params, void *init_method_data)
{
bt_self_component *self_component = bt_self_component_sink_as_self_component(self_component_sink);
}
static
-bt_bool component_class_can_seek_beginning(
- bt_self_message_iterator *self_message_iterator)
+bt_component_class_message_iterator_can_seek_beginning_method_status
+component_class_can_seek_beginning(
+ bt_self_message_iterator *self_message_iterator, bt_bool *can_seek)
{
PyObject *py_iter;
PyObject *py_result = NULL;
- bt_bool can_seek_beginning = false;
-
+ bt_component_class_message_iterator_can_seek_beginning_method_status status;
py_iter = bt_self_message_iterator_get_data(self_message_iterator);
BT_ASSERT(py_iter);
- py_result = PyObject_GetAttrString(py_iter, "_bt_can_seek_beginning_from_native");
+ py_result = PyObject_CallMethod(py_iter,
+ "_bt_can_seek_beginning_from_native", NULL);
BT_ASSERT(!py_result || PyBool_Check(py_result));
if (py_result) {
- can_seek_beginning = PyObject_IsTrue(py_result);
+ *can_seek = PyObject_IsTrue(py_result);
+ status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK;
} else {
- /*
- * Once can_seek_beginning can report errors, convert the
- * exception to a status. For now, log and return false;
- */
- loge_exception_message_iterator(self_message_iterator);
- PyErr_Clear();
+ status = py_exc_to_status_message_iterator(self_message_iterator);
+ BT_ASSERT(status != __BT_FUNC_STATUS_OK);
}
Py_XDECREF(py_result);
- return can_seek_beginning;
+ return status;
}
static
return status;
}
+static
+bt_component_class_message_iterator_can_seek_ns_from_origin_method_status
+component_class_can_seek_ns_from_origin(
+ bt_self_message_iterator *self_message_iterator,
+ int64_t ns_from_origin, bt_bool *can_seek)
+{
+ PyObject *py_iter;
+ PyObject *py_result = NULL;
+ bt_component_class_message_iterator_can_seek_ns_from_origin_method_status status;
+ py_iter = bt_self_message_iterator_get_data(self_message_iterator);
+ BT_ASSERT(py_iter);
+
+ py_result = PyObject_CallMethod(py_iter,
+ "_bt_can_seek_ns_from_origin_from_native", "L", ns_from_origin);
+
+ BT_ASSERT(!py_result || PyBool_Check(py_result));
+
+ if (py_result) {
+ *can_seek = PyObject_IsTrue(py_result);
+ status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK;
+ } else {
+ status = py_exc_to_status_message_iterator(self_message_iterator);
+ BT_ASSERT(status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK);
+ }
+
+ Py_XDECREF(py_result);
+
+ return status;
+}
+
+static
+bt_component_class_message_iterator_seek_ns_from_origin_method_status
+component_class_seek_ns_from_origin(
+ bt_self_message_iterator *self_message_iterator,
+ int64_t ns_from_origin)
+{
+ PyObject *py_iter;
+ PyObject *py_result;
+ bt_component_class_message_iterator_seek_ns_from_origin_method_status status;
+
+ py_iter = bt_self_message_iterator_get_data(self_message_iterator);
+ BT_ASSERT(py_iter);
+ py_result = PyObject_CallMethod(py_iter,
+ "_bt_seek_ns_from_origin_from_native", "L", ns_from_origin);
+ BT_ASSERT(!py_result || py_result == Py_None);
+ status = py_exc_to_status_message_iterator(self_message_iterator);
+ Py_XDECREF(py_result);
+ return status;
+}
+
static
bt_component_class_port_connected_method_status component_class_port_connected(
bt_self_component *self_component,
py_object, py_params_ptr,
method_data ? method_data : Py_None);
if (!py_results_addr) {
- BT_LOG_WRITE_CUR_LVL(BT_LOG_WARNING, log_level, BT_LOG_TAG,
- "Failed to call Python class's _bt_query_from_native() method: "
- "py-cls-addr=%p", py_cls);
status = py_exc_to_status_component_class(self_component_class,
log_level);
+ if (status < 0) {
+ static const char *fmt =
+ "Failed to call Python class's _bt_query_from_native() method: py-cls-addr=%p";
+ BT_LOG_WRITE_CUR_LVL(BT_LOG_WARNING, log_level, BT_LOG_TAG,
+ fmt, py_cls);
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT_CLASS(
+ self_component_class, fmt, py_cls);
+ }
goto end;
}
BT_ASSERT(ret == 0);
ret = bt_component_class_source_set_message_iterator_seek_beginning_method(component_class_source,
component_class_seek_beginning);
+ ret = bt_component_class_source_set_message_iterator_can_seek_ns_from_origin_method(
+ component_class_source, component_class_can_seek_ns_from_origin);
+ BT_ASSERT(ret == 0);
+ ret = bt_component_class_source_set_message_iterator_seek_ns_from_origin_method(
+ component_class_source, component_class_seek_ns_from_origin);
BT_ASSERT(ret == 0);
ret = bt_component_class_source_set_output_port_connected_method(component_class_source,
component_class_source_output_port_connected);
ret = bt_component_class_filter_set_message_iterator_seek_beginning_method(component_class_filter,
component_class_seek_beginning);
BT_ASSERT(ret == 0);
+ ret = bt_component_class_filter_set_message_iterator_can_seek_ns_from_origin_method(
+ component_class_filter, component_class_can_seek_ns_from_origin);
+ BT_ASSERT(ret == 0);
+ ret = bt_component_class_filter_set_message_iterator_seek_ns_from_origin_method(
+ component_class_filter, component_class_seek_ns_from_origin);
ret = bt_component_class_filter_set_input_port_connected_method(component_class_filter,
component_class_filter_input_port_connected);
BT_ASSERT(ret == 0);