From 707e64c06295ced92eddff882a2e16167ca992b1 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 7 Dec 2023 20:26:27 +0000 Subject: [PATCH] src/cpp-common/bt2: wrap dynamic array with length field loc. FC API This patch adds what's needed to the C++ libbabeltrace2 wrappers to wrap: * bt_field_class_array_dynamic_with_length_field_borrow_length_field_location_const() * bt_field_class_array_dynamic_without_length_field_location_create() * bt_field_class_array_dynamic_with_length_field_location_create() Signed-off-by: Philippe Proulx Change-Id: I7d731807165e22de9ec97d9cd83ec75e02c759b1 Reviewed-on: https://review.lttng.org/c/babeltrace/+/8017 Reviewed-on: https://review.lttng.org/c/babeltrace/+/12700 Tested-by: jenkins CI-Build: Simon Marchi --- src/cpp-common/bt2/field-class.hpp | 8 ++++++++ src/cpp-common/bt2/trace-ir.hpp | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/cpp-common/bt2/field-class.hpp b/src/cpp-common/bt2/field-class.hpp index 71e32e41..a60b1332 100644 --- a/src/cpp-common/bt2/field-class.hpp +++ b/src/cpp-common/bt2/field-class.hpp @@ -19,6 +19,7 @@ #include "borrowed-object-iterator.hpp" #include "borrowed-object.hpp" #include "exc.hpp" +#include "field-location.hpp" #include "field-path.hpp" #include "integer-range-set.hpp" #include "internal/utils.hpp" @@ -1425,6 +1426,13 @@ public: this->libObjPtr())}; } + ConstFieldLocation lengthFieldLocation() const noexcept + { + return ConstFieldLocation { + bt_field_class_array_dynamic_with_length_field_borrow_length_field_location_const( + this->libObjPtr())}; + } + Shared shared() const noexcept { return Shared::createWithRef(*this); diff --git a/src/cpp-common/bt2/trace-ir.hpp b/src/cpp-common/bt2/trace-ir.hpp index 8972bd22..67b381c4 100644 --- a/src/cpp-common/bt2/trace-ir.hpp +++ b/src/cpp-common/bt2/trace-ir.hpp @@ -1852,6 +1852,30 @@ public: return DynamicArrayWithLengthFieldClass::Shared::createWithoutRef(libObjPtr); } + ArrayFieldClass::Shared + createDynamicArrayWithoutLengthFieldLocationFieldClass(const FieldClass elementFieldClass) const + { + static_assert(!std::is_const::value, "Not available with `bt2::ConstTraceClass`."); + + const auto libObjPtr = bt_field_class_array_dynamic_without_length_field_location_create( + this->libObjPtr(), elementFieldClass.libObjPtr()); + + internal::validateCreatedObjPtr(libObjPtr); + return ArrayFieldClass::Shared::createWithoutRef(libObjPtr); + } + + DynamicArrayWithLengthFieldClass::Shared createDynamicArrayWithLengthFieldLocationFieldClass( + const FieldClass elementFieldClass, const ConstFieldLocation lengthFieldLocation) const + { + static_assert(!std::is_const::value, "Not available with `bt2::ConstTraceClass`."); + + const auto libObjPtr = bt_field_class_array_dynamic_with_length_field_location_create( + this->libObjPtr(), elementFieldClass.libObjPtr(), lengthFieldLocation.libObjPtr()); + + internal::validateCreatedObjPtr(libObjPtr); + return DynamicArrayWithLengthFieldClass::Shared::createWithoutRef(libObjPtr); + } + StructureFieldClass::Shared createStructureFieldClass() const { static_assert(!std::is_const::value, "Not available with `bt2::ConstTraceClass`."); -- 2.34.1