From 2770cb53424584db8c4c19aabef051ff3148f558 Mon Sep 17 00:00:00 2001 From: Manasvi Goyal Date: Fri, 20 Oct 2023 11:49:45 +0200 Subject: [PATCH 1/3] Add a test for ctypes for fake case --- src-fake-test/BuilderOptions.h | 66 + src-fake-test/GrowableBuffer.h | 564 +++++++ src-fake-test/LayoutBuilder.h | 2238 +++++++++++++++++++++++++ src-fake-test/fake.cpp | 149 ++ src-fake-test/fake.h | 187 +++ src-fake-test/fake.py | 77 + src-fake-test/fake.raw | Bin 0 -> 36000 bytes src-fake-test/kaitai/custom_decoder.h | 16 + src-fake-test/kaitai/exceptions.h | 224 +++ src-fake-test/kaitai/kaitaistream.cpp | 877 ++++++++++ src-fake-test/kaitai/kaitaistream.h | 374 +++++ src-fake-test/kaitai/kaitaistruct.h | 20 + src-fake-test/utils.h | 275 +++ 13 files changed, 5067 insertions(+) create mode 100644 src-fake-test/BuilderOptions.h create mode 100644 src-fake-test/GrowableBuffer.h create mode 100644 src-fake-test/LayoutBuilder.h create mode 100644 src-fake-test/fake.cpp create mode 100644 src-fake-test/fake.h create mode 100644 src-fake-test/fake.py create mode 100644 src-fake-test/fake.raw create mode 100644 src-fake-test/kaitai/custom_decoder.h create mode 100644 src-fake-test/kaitai/exceptions.h create mode 100644 src-fake-test/kaitai/kaitaistream.cpp create mode 100644 src-fake-test/kaitai/kaitaistream.h create mode 100644 src-fake-test/kaitai/kaitaistruct.h create mode 100644 src-fake-test/utils.h diff --git a/src-fake-test/BuilderOptions.h b/src-fake-test/BuilderOptions.h new file mode 100644 index 0000000..036aa0c --- /dev/null +++ b/src-fake-test/BuilderOptions.h @@ -0,0 +1,66 @@ +// BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE + +#ifndef AWKWARD_BUILDEROPTIONS_H_ +#define AWKWARD_BUILDEROPTIONS_H_ + +#include +#include +#include +#include +#include +#include + +namespace awkward { + + /// @class Options + /// + /// @brief Container for all configuration options needed by ArrayBuilder, + /// GrowableBuffer, LayoutBuilder and the Builder subclasses. + template + struct Options { + static constexpr std::size_t value = sizeof...(OPTIONS); + + using OptionsPack = typename std::tuple; + + // FIXME: + // std::tuple_element_t is missing on some of the CI node compilers + // + // template + // using OptionType = std::tuple_element_t; + + template + using OptionType = + typename std::tuple_element::type; + + /// @brief Creates an Options tuple from a full set of parameters. + Options(OPTIONS... options) : pars(options...) {} + + /// @brief The initial number of + /// {@link GrowableBuffer#reserved reserved} entries for a GrowableBuffer. + int64_t + initial() const noexcept { + return option<0>(); + } + + /// @brief The factor with which a GrowableBuffer is resized + /// when its {@link GrowableBuffer#length length} reaches its + /// {@link GrowableBuffer#reserved reserved}. + double + resize() const noexcept { + return option<1>(); + } + + /// @brief Access to all other options. + template + const OptionType& + option() const noexcept { + return std::get(pars); + } + + OptionsPack pars; + }; + + using BuilderOptions = Options; +} // namespace awkward + +#endif // AWKWARD_BUILDEROPTIONS_H_ diff --git a/src-fake-test/GrowableBuffer.h b/src-fake-test/GrowableBuffer.h new file mode 100644 index 0000000..6d5b7b8 --- /dev/null +++ b/src-fake-test/GrowableBuffer.h @@ -0,0 +1,564 @@ +// BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE + +#ifndef AWKWARD_GROWABLEBUFFER_H_ +#define AWKWARD_GROWABLEBUFFER_H_ + +#include "BuilderOptions.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace awkward { + + template