tests/lib: pass C++ wrapper types to `RunIn` callbacks
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 13 Feb 2024 03:26:22 +0000 (22:26 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 19 Feb 2024 18:10:15 +0000 (13:10 -0500)
Pass C++ wrapper types to `RunInCompClsInitFunc`,
`RunInCompClsQueryFunc` and `RunInMsgIterClsInitFunc` instead of C
library types.

Adjust callers and callees in a trivial way.

Change-Id: I3d6fcee8e0239976483995affcd7e95fb5fa12ef
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11796
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
tests/lib/conds/conds-triggers.cpp
tests/lib/conds/utils.hpp
tests/lib/test-fields-bin.cpp
tests/lib/utils/run-in.cpp
tests/lib/utils/run-in.hpp

index 83182f9ab566a1682680f20c2c685dd61d177a08..5529973737a076b41d068fd33ad5f6af0cb84265 100644 (file)
@@ -26,17 +26,17 @@ static bt_field_class *get_uint_fc(bt_self_component *self_comp)
     return fc;
 }
 
-static void trigger_fc_int_set_field_value_range_n_0(bt_self_component *self_comp)
+static void trigger_fc_int_set_field_value_range_n_0(const bt2::SelfComponent self)
 {
-    bt_field_class_integer_set_field_value_range(get_uint_fc(self_comp), 0);
+    bt_field_class_integer_set_field_value_range(get_uint_fc(self.libObjPtr()), 0);
 }
 
-static void trigger_fc_int_set_field_value_range_n_gt_64(bt_self_component *self_comp)
+static void trigger_fc_int_set_field_value_range_n_gt_64(const bt2::SelfComponent self)
 {
-    bt_field_class_integer_set_field_value_range(get_uint_fc(self_comp), 65);
+    bt_field_class_integer_set_field_value_range(get_uint_fc(self.libObjPtr()), 65);
 }
 
-static void trigger_fc_int_set_field_value_range_null(bt_self_component *)
+static void trigger_fc_int_set_field_value_range_null(bt2::SelfComponent)
 {
     bt_field_class_integer_set_field_value_range(NULL, 23);
 }
index 8d01efec39bbcf5462f868953eb50aa7c95b023e..6ba7401fc66a0f94e167eabf7557e4fdd72190c6 100644 (file)
@@ -9,6 +9,8 @@
 
 #include <babeltrace2/babeltrace.h>
 
+#include "cpp-common/bt2/self-component-port.hpp"
+
 enum cond_trigger_func_type
 {
     COND_TRIGGER_FUNC_TYPE_BASIC,
@@ -22,7 +24,7 @@ enum cond_trigger_type
 };
 
 typedef void (*cond_trigger_basic_func)(void);
-typedef void (*cond_trigger_run_in_comp_cls_init_func)(bt_self_component *);
+typedef void (*cond_trigger_run_in_comp_cls_init_func)(bt2::SelfComponent);
 
 struct cond_trigger
 {
index 0bc8bb3b745564b4f39c37686859d84053b7a2eb..7f2c26d4151e4d6eded79c8655f6023e62f980b5 100644 (file)
@@ -16,10 +16,10 @@ static const int NR_TESTS = 2;
 
 static void test_string_clear()
 {
-    runInMsgIterClsInit([](bt_self_message_iterator * const self) {
+    runInMsgIterClsInit([](const bt2::SelfMessageIterator self) {
         /* Boilerplate to get a string field */
         const auto traceCls =
-            bt_trace_class_create(bt_self_message_iterator_borrow_component(self));
+            bt_trace_class_create(bt_self_message_iterator_borrow_component(self.libObjPtr()));
         const auto streamCls = bt_stream_class_create(traceCls);
         const auto eventCls = bt_event_class_create(streamCls);
         const auto payloadCls = bt_field_class_structure_create(traceCls);
@@ -39,7 +39,7 @@ static void test_string_clear()
 
         const auto trace = bt_trace_create(traceCls);
         const auto stream = bt_stream_create(streamCls, trace);
-        const auto msg = bt_message_event_create(self, eventCls, stream);
+        const auto msg = bt_message_event_create(self.libObjPtr(), eventCls, stream);
         const auto field = bt_field_structure_borrow_member_field_by_name(
             bt_event_borrow_payload_field(bt_message_event_borrow_event(msg)), "str");
 
index 01913872d209e19b303ebbbbd5812e90f02c40d4..3fef7d327b553f8073596869465c0047ec77e1c5 100644 (file)
@@ -7,6 +7,7 @@
 #include <utility>
 
 #include "common/assert.h"
+#include "cpp-common/bt2/wrap.hpp"
 
 #include "run-in.hpp"
 
@@ -37,7 +38,7 @@ bt_component_class_initialize_method_status compClsInit(bt_self_component_source
     auto& data = runInDataFromMethodData(initMethodData);
 
     if (data.compCtxFunc) {
-        data.compCtxFunc(bt_self_component_source_as_self_component(selfComp));
+        data.compCtxFunc(bt2::wrap(bt_self_component_source_as_self_component(selfComp)));
     }
 
     return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
@@ -51,7 +52,8 @@ compClsQuery(bt_self_component_class_source * const selfCompCls, bt_private_quer
     auto& data = runInDataFromMethodData(methodData);
 
     if (data.compClsCtxFunc) {
-        data.compClsCtxFunc(bt_self_component_class_source_as_self_component_class(selfCompCls));
+        data.compClsCtxFunc(
+            bt2::wrap(bt_self_component_class_source_as_self_component_class(selfCompCls)));
     }
 
     *result = bt_value_null;
@@ -66,7 +68,7 @@ msgIterClsInit(bt_self_message_iterator * const selfMsgIter,
         bt_self_component_port_output_as_self_component_port(port)));
 
     if (data.msgIterCtxFunc) {
-        data.msgIterCtxFunc(selfMsgIter);
+        data.msgIterCtxFunc(bt2::wrap(selfMsgIter));
     }
 
     return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
index 0855e05e062ba697b3f9b4b4b51ad3a11833e634..01774f9053f5e424dcea154d84b31d73f3f955c2 100644 (file)
 
 #include <babeltrace2/babeltrace.h>
 
-using RunInCompClsQueryFunc = std::function<void(bt_self_component_class *)>;
-using RunInCompClsInitFunc = std::function<void(bt_self_component *)>;
-using RunInMsgIterClsInitFunc = std::function<void(bt_self_message_iterator *)>;
+#include "cpp-common/bt2/self-component-class.hpp"
+#include "cpp-common/bt2/self-component-port.hpp"
+#include "cpp-common/bt2/self-message-iterator.hpp"
+
+using RunInCompClsQueryFunc = std::function<void(bt2::SelfComponentClass)>;
+using RunInCompClsInitFunc = std::function<void(bt2::SelfComponent)>;
+using RunInMsgIterClsInitFunc = std::function<void(bt2::SelfMessageIterator)>;
 
 /*
  * Runs:
This page took 0.034509 seconds and 4 git commands to generate.