Skip to content

Commit

Permalink
fix: add inline to prevent multiple definitions (#2606)
Browse files Browse the repository at this point in the history
Co-authored-by: Angus Hollands <goosey15@gmail.com>
  • Loading branch information
ManasviGoyal and agoose77 authored Aug 8, 2023
1 parent 6e69067 commit 0628b7f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/header-only-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Header-only Tests

on:
pull_request:
# paths:
# - 'header-only'
paths:
- 'header-only'

workflow_dispatch:

Expand Down
36 changes: 18 additions & 18 deletions header-only/layout-builder/awkward/LayoutBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
#include <string>
#include <functional>

/// @brief Object of {@link BuilderOptions BuilderOptions} which sets the
/// values of the default options.
#define AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS awkward::BuilderOptions(1024, 1)

namespace awkward {

namespace LayoutBuilder {

/// @brief Object of {@link BuilderOptions BuilderOptions} which sets the
/// values of the default options.
awkward::BuilderOptions default_options(1024, 1);

/// @class Field
///
/// @brief Helper class for sending a pair of field names (as enum) and field
Expand Down Expand Up @@ -55,10 +55,10 @@ namespace awkward {
class Numpy {
public:
/// @brief Creates a new Numpy layout builder by allocating a new buffer,
/// using `default_options` for initializing the buffer.
/// using `AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS` for initializing the buffer.
Numpy()
: data_(
awkward::GrowableBuffer<PRIMITIVE>(default_options)) {
awkward::GrowableBuffer<PRIMITIVE>(AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS)) {
size_t id = 0;
set_id(id);
}
Expand Down Expand Up @@ -210,10 +210,10 @@ namespace awkward {
class ListOffset {
public:
/// @brief Creates a new ListOffset layout builder by allocating a new `offset`
/// buffer, using `default_options` for initializing the buffer.
/// buffer, using `AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS` for initializing the buffer.
ListOffset()
: offsets_(
awkward::GrowableBuffer<PRIMITIVE>(default_options)) {
awkward::GrowableBuffer<PRIMITIVE>(AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS)) {
offsets_.append(0);
size_t id = 0;
set_id(id);
Expand Down Expand Up @@ -415,7 +415,7 @@ namespace awkward {
/// contents in the form of a JSON-like string.
std::string
form() const noexcept {
return "{ \"class\": \"EmptyArray\", \"parameters\": {} }";
return "{ \"class\": \"EmptyArray\" }";
}

private:
Expand Down Expand Up @@ -1034,10 +1034,10 @@ namespace awkward {
class IndexedOption {
public:
/// @brief Creates a new IndexedOption layout builder by allocating a new `index`
/// buffer, using `default_options` for initializing the buffer.
/// buffer, using `AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS` for initializing the buffer.
IndexedOption()
: index_(
awkward::GrowableBuffer<PRIMITIVE>(default_options)),
awkward::GrowableBuffer<PRIMITIVE>(AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS)),
last_valid_(-1) {
size_t id = 0;
set_id(id);
Expand Down Expand Up @@ -1358,9 +1358,9 @@ namespace awkward {
class ByteMasked {
public:
/// @brief Creates a new ByteMasked layout builder by allocating a new `mask`
/// buffer, using `default_options` for initializing the buffer.
/// buffer, using `AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS` for initializing the buffer.
ByteMasked()
: mask_(awkward::GrowableBuffer<int8_t>(default_options)) {
: mask_(awkward::GrowableBuffer<int8_t>(AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS)) {
size_t id = 0;
set_id(id);
}
Expand Down Expand Up @@ -1571,9 +1571,9 @@ namespace awkward {
class BitMasked {
public:
/// @brief Creates a new BitMasked layout builder by allocating a new `mask`
/// buffer, using `default_options` for initializing the buffer.
/// buffer, using `AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS` for initializing the buffer.
BitMasked()
: mask_(awkward::GrowableBuffer<uint8_t>(default_options)),
: mask_(awkward::GrowableBuffer<uint8_t>(AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS)),
current_byte_(uint8_t(0)),
current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
current_index_(0) {
Expand Down Expand Up @@ -1877,10 +1877,10 @@ namespace awkward {
using ContentType = std::tuple_element_t<I, Contents>;

/// @brief Creates a new Union layout builder by allocating new tags and
/// index buffers, using `default_options` for initializing the buffer.
/// index buffers, using `AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS` for initializing the buffer.
Union()
: tags_(awkward::GrowableBuffer<TAGS>(default_options)),
index_(awkward::GrowableBuffer<INDEX>(default_options)) {
: tags_(awkward::GrowableBuffer<TAGS>(AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS)),
index_(awkward::GrowableBuffer<INDEX>(AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS)) {
size_t id = 0;
set_id(id);
for (size_t i = 0; i < contents_count_; i++)
Expand Down
18 changes: 9 additions & 9 deletions header-only/layout-builder/awkward/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace awkward {

/// @brief Returns the name of a primitive type as a string.
template <typename T>
const std::string
inline const std::string
type_to_name() {
if (is_integral_v<T>) {
if (is_signed_v<T>) {
Expand Down Expand Up @@ -81,15 +81,15 @@ namespace awkward {
}

template <>
const std::string
inline const std::string
type_to_name<bool>() {
// This takes precedence over the unspecialized template, and therefore any
// 8-bit data that is not named bool will be mapped to "int8" or "uint8".
return "bool";
}

template <>
const std::string
inline const std::string
type_to_name<char>() {
// This takes precedence over the unspecialized template, and therefore any
// 8-bit data that is not named char will be mapped to "int8" or "uint8".
Expand All @@ -100,47 +100,47 @@ namespace awkward {
/// @brief Returns `char` string when the primitive type
/// is a character.
template <typename T>
const std::string
inline const std::string
type_to_numpy_like() {
return type_to_name<T>();
}

/// @brief Returns numpy-like character code of a primitive
/// type as a string.
template <>
const std::string
inline const std::string
type_to_numpy_like<uint8_t>() {
return "u8";
}

/// @brief Returns numpy-like character code `i8`, when the
/// primitive type is an 8-bit signed integer.
template <>
const std::string
inline const std::string
type_to_numpy_like<int8_t>() {
return "i8";
}

/// @brief Returns numpy-like character code `u32`, when the
/// primitive type is a 32-bit unsigned integer.
template <>
const std::string
inline const std::string
type_to_numpy_like<uint32_t>() {
return "u32";
}

/// @brief Returns numpy-like character code `i32`, when the
/// primitive type is a 32-bit signed integer.
template <>
const std::string
inline const std::string
type_to_numpy_like<int32_t>() {
return "i32";
}

/// @brief Returns numpy-like character code `i64`, when the
/// primitive type is a 64-bit signed integer.
template <>
const std::string
inline const std::string
type_to_numpy_like<int64_t>() {
return "i64";
}
Expand Down

0 comments on commit 0628b7f

Please sign in to comment.