Skip to content

Commit

Permalink
replaced _UZ by c++23 UZ
Browse files Browse the repository at this point in the history
Signed-off-by: Ralph J. Steinhagen <[email protected]>
  • Loading branch information
RalphSteinhagen committed Dec 5, 2023
1 parent f324c82 commit 3ff579c
Show file tree
Hide file tree
Showing 19 changed files with 152 additions and 182 deletions.
4 changes: 2 additions & 2 deletions blocks/basic/include/gnuradio-4.0/basic/clock_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ ClockSource Documentation -- add here
work::Status
processBulk(PublishableSpan auto &output) noexcept {
if (n_samples_max > 0 && n_samples_produced >= n_samples_max) {
output.publish(0_UZ);
output.publish(0UZ);
return work::Status::DONE;
}

Expand All @@ -102,7 +102,7 @@ ClockSource Documentation -- add here
}
const auto writableSamples = static_cast<std::uint32_t>(output.size());
if (writableSamples < chunk_size) {
output.publish(0_UZ);
output.publish(0UZ);
return work::Status::INSUFFICIENT_OUTPUT_ITEMS;
}

Expand Down
12 changes: 5 additions & 7 deletions blocks/basic/include/gnuradio-4.0/basic/common_blocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include <gnuradio-4.0/Graph.hpp>
#include <gnuradio-4.0/reflection.hpp>

using namespace gr::literals;

template<typename T>
class builtin_multiply : public gr::Block<builtin_multiply<T>> {
T _factor = static_cast<T>(1.0f);
Expand Down Expand Up @@ -42,8 +40,8 @@ class builtin_counter : public gr::Block<builtin_counter<T>> {
public:
static std::size_t s_event_count;

gr::PortIn<T> in;
gr::PortOut<T> out;
gr::PortIn<T> in;
gr::PortOut<T> out;

[[nodiscard]] constexpr auto
processOne(T a) const noexcept {
Expand Down Expand Up @@ -132,12 +130,12 @@ class multi_adder : public gr::BlockModel {

[[nodiscard]] constexpr std::size_t
availableInputSamples(std::vector<std::size_t> &) const noexcept override {
return 0_UZ;
return 0UZ;
}

[[nodiscard]] constexpr std::size_t
availableOutputSamples(std::vector<std::size_t> &) const noexcept override {
return 0_UZ;
return 0UZ;
}

// TODO: integrate with Block::work
Expand All @@ -153,7 +151,7 @@ class multi_adder : public gr::BlockModel {
}

if (available_samples == 0) {
return { requested_work, 0_UZ, gr::work::Status::OK };
return { requested_work, 0UZ, gr::work::Status::OK };
}

std::vector<std::span<const double>> readers;
Expand Down
4 changes: 2 additions & 2 deletions blocks/basic/include/gnuradio-4.0/basic/selector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ struct Selector : Block<Selector<T>, SelectorDoc> {
const std::vector<output_writer_t *> &outs) {
if (_internalMapping.empty()) {
if (backPressure) {
std::for_each(ins.begin(), ins.end(), [](auto *input) { std::ignore = input->consume(0_UZ); });
std::for_each(ins.begin(), ins.end(), [](auto *input) { std::ignore = input->consume(0UZ); });
} else {
// make the implicit consume all available behaviour explicit
std::for_each(ins.begin(), ins.end(), [](auto *input) { std::ignore = input->consume(input->available()); });
Expand Down Expand Up @@ -191,7 +191,7 @@ struct Selector : Block<Selector<T>, SelectorDoc> {
if (used_inputs.contains(src_port)) continue;

if (backPressure) {
std::ignore = ins[src_port]->consume(0_UZ);
std::ignore = ins[src_port]->consume(0UZ);

} else {
// make the implicit consume all available behaviour explicit
Expand Down
21 changes: 10 additions & 11 deletions blocks/basic/test/qa_DataSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct Source : public Block<Source<T>> {

if (nSamples == -1) {
this->requestStop();
output.publish(0_UZ);
output.publish(0UZ);
return work::Status::DONE;
}
if (next_tag < tags.size() && tags[next_tag].index <= static_cast<std::make_signed_t<std::size_t>>(n_samples_produced)) {
Expand Down Expand Up @@ -239,7 +239,6 @@ const boost::ut::suite DataSinkTests = [] {
using namespace gr;
using namespace gr::basic;
using namespace gr::basic::data_sink_test;
using namespace gr::literals;
using namespace std::string_literals;

"callback continuous mode"_test = [] {
Expand Down Expand Up @@ -267,7 +266,7 @@ const boost::ut::suite DataSinkTests = [] {
if (chunksSeen1 < 201) {
expect(eq(buffer.size(), kChunkSize));
} else {
expect(eq(buffer.size(), 5_UZ));
expect(eq(buffer.size(), 5UZ));
}
};

Expand Down Expand Up @@ -296,7 +295,7 @@ const boost::ut::suite DataSinkTests = [] {
if (chunksSeen2 < 201) {
expect(eq(buffer.size(), kChunkSize));
} else {
expect(eq(buffer.size(), 5_UZ));
expect(eq(buffer.size(), 5UZ));
}
};

Expand All @@ -315,8 +314,8 @@ const boost::ut::suite DataSinkTests = [] {
sink.stop(); // TODO the scheduler should call this

auto lg = std::lock_guard{ m2 };
expect(eq(chunksSeen1.load(), 201_UZ));
expect(eq(chunksSeen2, 201_UZ));
expect(eq(chunksSeen1.load(), 201UZ));
expect(eq(chunksSeen2, 201UZ));
expect(eq(samplesSeen1.load(), static_cast<std::size_t>(kSamples)));
expect(eq(samplesSeen2, static_cast<std::size_t>(kSamples)));
expect(eq(indexesMatch(receivedTags, srcTags), true)) << fmt::format("{} != {}", formatList(receivedTags), formatList(srcTags));
Expand Down Expand Up @@ -391,12 +390,12 @@ const boost::ut::suite DataSinkTests = [] {
const auto &[received2, receivedTags] = runner2.get();
expect(eq(received1.size(), expected.size()));
expect(eq(received1, expected));
expect(eq(pollerDataOnly->drop_count.load(), 0_UZ));
expect(eq(pollerDataOnly->drop_count.load(), 0UZ));
expect(eq(received2.size(), expected.size()));
expect(eq(received2, expected));
expect(eq(receivedTags.size(), tags.size()));
expect(eq(indexesMatch(receivedTags, tags), true)) << fmt::format("{} != {}", formatList(receivedTags), formatList(tags));
expect(eq(pollerWithTags->drop_count.load(), 0_UZ));
expect(eq(pollerWithTags->drop_count.load(), 0UZ));
};

"blocking polling trigger mode non-overlapping"_test = [] {
Expand Down Expand Up @@ -454,11 +453,11 @@ const boost::ut::suite DataSinkTests = [] {
const auto &[receivedData, receivedTags] = polling.get();
const auto expected_tags = { tags[0], tags[2] }; // triggers-only

expect(eq(receivedData.size(), 10_UZ));
expect(eq(receivedData.size(), 10UZ));
expect(eq(receivedData, std::vector<int32_t>{ 2997, 2998, 2999, 3000, 3001, 179997, 179998, 179999, 180000, 180001 }));
expect(eq(receivedTags.size(), expected_tags.size()));

expect(eq(poller->drop_count.load(), 0_UZ));
expect(eq(poller->drop_count.load(), 0UZ));
};

"blocking snapshot mode"_test = [] {
Expand Down Expand Up @@ -527,7 +526,7 @@ const boost::ut::suite DataSinkTests = [] {
const auto receivedData = poller_result.get();
expect(eq(receivedDataCb, receivedData));
expect(eq(receivedData, std::vector<int32_t>{ 8000, 185000 }));
expect(eq(poller->drop_count.load(), 0_UZ));
expect(eq(poller->drop_count.load(), 0UZ));
};

"blocking multiplexed mode"_test = [] {
Expand Down
23 changes: 10 additions & 13 deletions blocks/basic/test/qa_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@

#include <gnuradio-4.0/basic/selector.hpp>

using namespace gr::literals;

template<typename T>
struct repeated_source : public gr::Block<repeated_source<T>> {
std::uint32_t identifier = 0;
std::uint32_t remaining_events_count;
std::vector<T> values;
std::vector<T>::const_iterator values_next;

gr::PortOut<T> out;
gr::PortOut<T> out;

void
settingsChanged(const gr::property_map & /*old_settings*/, const gr::property_map &new_settings) noexcept {
Expand All @@ -35,13 +33,12 @@ struct repeated_source : public gr::Block<repeated_source<T>> {
}

if (remaining_events_count != 0) {
using namespace gr::literals;
auto &port = gr::outputPort<0>(this);
auto &writer = port.streamWriter();
auto data = writer.reserve_output_range(1_UZ);
auto data = writer.reserve_output_range(1UZ);

data[0] = *values_next;
data.publish(1_UZ);
data[0] = *values_next;
data.publish(1UZ);

remaining_events_count--;
if (remaining_events_count == 0) {
Expand All @@ -62,8 +59,8 @@ ENABLE_REFLECTION_FOR_TEMPLATE_FULL((typename T), (repeated_source<T>), identifi

template<typename T>
struct validator_sink : public gr::Block<validator_sink<T>> {
std::uint32_t identifier = 0;
gr::PortIn<T> in;
std::uint32_t identifier = 0;
gr::PortIn<T> in;

std::vector<T> expected_values;
std::vector<T>::const_iterator expected_values_next;
Expand Down Expand Up @@ -130,16 +127,16 @@ void
execute_selector_test(test_definition definition) {
using namespace boost::ut;

const std::uint32_t sources_count = definition.input_values.size();
const std::uint32_t sinks_count = definition.output_values.size();
const std::uint32_t sources_count = definition.input_values.size();
const std::uint32_t sinks_count = definition.output_values.size();

gr::Graph graph;
std::vector<repeated_source<double> *> sources;
std::vector<validator_sink<double> *> sinks;
gr::basic::Selector<double> *selector;

std::vector<std::uint32_t> mapIn(definition.mapping.size());
std::vector<std::uint32_t> mapOut(definition.mapping.size());
std::vector<std::uint32_t> mapIn(definition.mapping.size());
std::vector<std::uint32_t> mapOut(definition.mapping.size());
std::ranges::transform(definition.mapping, mapIn.begin(), [](auto &p) { return p.first; });
std::ranges::transform(definition.mapping, mapOut.begin(), [](auto &p) { return p.second; });

Expand Down
22 changes: 10 additions & 12 deletions blocks/testing/include/gnuradio-4.0/testing/bm_test_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ inline constexpr std::size_t N_MAX = std::numeric_limits<std::size_t>::max();

namespace test {

using namespace gr::literals;
inline static std::size_t n_samples_produced = 0UZ;

inline static std::size_t n_samples_produced = 0_UZ;

template<typename T, std::size_t min = 0_UZ, std::size_t count = N_MAX, bool use_bulk_operation = true>
template<typename T, std::size_t min = 0UZ, std::size_t count = N_MAX, bool use_bulk_operation = true>
class source : public gr::Block<source<T, min, count>> {
public:
uint64_t _n_samples_max;
Expand Down Expand Up @@ -61,8 +59,8 @@ class source : public gr::Block<source<T, min, count>> {

if constexpr (use_bulk_operation) {
std::size_t n_write = std::clamp(n_to_publish, 0UL, std::min(writer.available(), port.max_buffer_size()));
if (n_write == 0_UZ) {
return { requested_work, 0_UZ, gr::work::Status::INSUFFICIENT_INPUT_ITEMS };
if (n_write == 0UZ) {
return { requested_work, 0UZ, gr::work::Status::INSUFFICIENT_INPUT_ITEMS };
}

writer.publish( //
Expand All @@ -74,22 +72,22 @@ class source : public gr::Block<source<T, min, count>> {
n_write);
} else {
auto [data, token] = writer.get(1);
if (data.size() == 0_UZ) {
return { requested_work, 0_UZ, gr::work::Status::ERROR };
if (data.size() == 0UZ) {
return { requested_work, 0UZ, gr::work::Status::ERROR };
}
data[0] = processOne();
writer.publish(token, 1);
}
return { requested_work, 1_UZ, gr::work::Status::OK };
return { requested_work, 1UZ, gr::work::Status::OK };
} else {
return { requested_work, 0_UZ, gr::work::Status::DONE };
return { requested_work, 0UZ, gr::work::Status::DONE };
}
}
};

inline static std::size_t n_samples_consumed = 0_UZ;
inline static std::size_t n_samples_consumed = 0UZ;

template<typename T, std::size_t N_MIN = 1_UZ, std::size_t N_MAX = N_MAX>
template<typename T, std::size_t N_MIN = 1UZ, std::size_t N_MAX = N_MAX>
struct sink : public gr::Block<sink<T, N_MIN, N_MAX>> {
gr::PortIn<T, gr::RequiredSamples<N_MIN, N_MAX>> in;
std::size_t should_receive_n_samples = 0;
Expand Down
Loading

0 comments on commit 3ff579c

Please sign in to comment.