Skip to content

Commit

Permalink
style(core): format code
Browse files Browse the repository at this point in the history
  • Loading branch information
RiscadoA committed Sep 28, 2023
1 parent d8ab876 commit b81b3b2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 60 deletions.
38 changes: 17 additions & 21 deletions core/include/cubos/core/reflection/external/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::map<K, V>))
{
return new typename Map::iterator(reinterpret_cast<Map*>(instance)->begin());
}

return new typename Map::const_iterator(reinterpret_cast<const Map*>(instance)->cbegin());


return new typename Map::const_iterator(reinterpret_cast<const Map*>(instance)->cbegin());
} /*begin*/,
[](uintptr_t instance, const void* key, bool writeable) -> void* {
if (writeable)
Expand All @@ -36,25 +35,24 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::map<K, V>))
}
return new typename Map::iterator(it);
}

auto it = reinterpret_cast<const Map*>(instance)->find(*reinterpret_cast<const K*>(key));
if (it == reinterpret_cast<const Map*>(instance)->end())
{
return nullptr;
}
return new typename Map::const_iterator(it);


auto it = reinterpret_cast<const Map*>(instance)->find(*reinterpret_cast<const K*>(key));
if (it == reinterpret_cast<const Map*>(instance)->end())
{
return nullptr;

Check warning on line 42 in core/include/cubos/core/reflection/external/map.hpp

View check run for this annotation

Codecov / codecov/patch

core/include/cubos/core/reflection/external/map.hpp#L42

Added line #L42 was not covered by tests
}
return new typename Map::const_iterator(it);
} /*find*/,
[](uintptr_t instance, void* iterator, bool writeable) -> bool {
if (writeable)
{
++*static_cast<typename Map::iterator*>(iterator);
return *static_cast<typename Map::iterator*>(iterator) != reinterpret_cast<Map*>(instance)->end();
}
++*static_cast<typename Map::const_iterator*>(iterator);
return *static_cast<typename Map::const_iterator*>(iterator) != reinterpret_cast<const Map*>(instance)->cend();


++*static_cast<typename Map::const_iterator*>(iterator);
return *static_cast<typename Map::const_iterator*>(iterator) !=
reinterpret_cast<const Map*>(instance)->cend();
} /*advance*/,
[](void* iterator, bool writeable) {
if (writeable)
Expand All @@ -71,18 +69,16 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::map<K, V>))
{
return &(*static_cast<const typename Map::iterator*>(iterator))->first;
}

return &(*static_cast<const typename Map::const_iterator*>(iterator))->first;


return &(*static_cast<const typename Map::const_iterator*>(iterator))->first;
} /*key*/,
[](const void* iterator, bool writeable) -> uintptr_t {
if (writeable)
{
return reinterpret_cast<uintptr_t>(&(*static_cast<const typename Map::iterator*>(iterator))->second);
}

return reinterpret_cast<uintptr_t>(&(*static_cast<const typename Map::const_iterator*>(iterator))->second);


return reinterpret_cast<uintptr_t>(&(*static_cast<const typename Map::const_iterator*>(iterator))->second);
} /*value*/);

// We supply the insert functions depending on the constructibility of the value type.
Expand Down
38 changes: 17 additions & 21 deletions core/include/cubos/core/reflection/external/unordered_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::unordered_map<K,
{
return new typename Map::iterator(reinterpret_cast<Map*>(instance)->begin());
}

return new typename Map::const_iterator(reinterpret_cast<const Map*>(instance)->cbegin());


return new typename Map::const_iterator(reinterpret_cast<const Map*>(instance)->cbegin());
} /*begin*/,
[](uintptr_t instance, const void* key, bool writeable) -> void* {
if (writeable)
Expand All @@ -36,25 +35,24 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::unordered_map<K,
}
return new typename Map::iterator(it);
}

auto it = reinterpret_cast<const Map*>(instance)->find(*reinterpret_cast<const K*>(key));
if (it == reinterpret_cast<const Map*>(instance)->end())
{
return nullptr;
}
return new typename Map::const_iterator(it);


auto it = reinterpret_cast<const Map*>(instance)->find(*reinterpret_cast<const K*>(key));
if (it == reinterpret_cast<const Map*>(instance)->end())
{
return nullptr;

Check warning on line 42 in core/include/cubos/core/reflection/external/unordered_map.hpp

View check run for this annotation

Codecov / codecov/patch

core/include/cubos/core/reflection/external/unordered_map.hpp#L42

Added line #L42 was not covered by tests
}
return new typename Map::const_iterator(it);
} /*find*/,
[](uintptr_t instance, void* iterator, bool writeable) {
if (writeable)
{
++*static_cast<typename Map::iterator*>(iterator);
return *static_cast<typename Map::iterator*>(iterator) != reinterpret_cast<Map*>(instance)->end();
}
++*static_cast<typename Map::const_iterator*>(iterator);
return *static_cast<typename Map::const_iterator*>(iterator) != reinterpret_cast<const Map*>(instance)->cend();


++*static_cast<typename Map::const_iterator*>(iterator);
return *static_cast<typename Map::const_iterator*>(iterator) !=
reinterpret_cast<const Map*>(instance)->cend();
} /*advance*/,
[](void* iterator, bool writeable) {
if (writeable)
Expand All @@ -71,18 +69,16 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::unordered_map<K,
{
return &(*static_cast<const typename Map::iterator*>(iterator))->first;
}

return &(*static_cast<const typename Map::const_iterator*>(iterator))->first;


return &(*static_cast<const typename Map::const_iterator*>(iterator))->first;
} /*key*/,
[](const void* iterator, bool writeable) -> uintptr_t {
if (writeable)
{
return reinterpret_cast<uintptr_t>(&(*static_cast<const typename Map::iterator*>(iterator))->second);
}

return reinterpret_cast<uintptr_t>(&(*static_cast<const typename Map::const_iterator*>(iterator))->second);


return reinterpret_cast<uintptr_t>(&(*static_cast<const typename Map::const_iterator*>(iterator))->second);
} /*value*/);

// We supply the insert functions depending on the constructibility of the value type.
Expand Down
12 changes: 6 additions & 6 deletions core/include/cubos/core/reflection/traits/dictionary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ namespace cubos::core::reflection
Stop mStop;
Key mKey;
Value mValue;
InsertDefault mInsertDefault;
InsertCopy mInsertCopy;
InsertMove mInsertMove;
Erase mErase;
InsertDefault mInsertDefault{nullptr};
InsertCopy mInsertCopy{nullptr};
InsertMove mInsertMove{nullptr};
Erase mErase{nullptr};
};

class DictionaryTrait::Iterator
Expand Down Expand Up @@ -254,7 +254,7 @@ namespace cubos::core::reflection
/// @param trait Dictionary trait.
Iterator(void* inner, void* instance, const DictionaryTrait& trait);

void* mInner;
void* mInner{nullptr};
void* mInstance;
const DictionaryTrait& mTrait;
};
Expand Down Expand Up @@ -300,7 +300,7 @@ namespace cubos::core::reflection
/// @param trait Dictionary trait.
ConstIterator(void* inner, const void* instance, const DictionaryTrait& trait);

void* mInner;
void* mInner{nullptr};
const void* mInstance;
const DictionaryTrait& mTrait;
};
Expand Down
18 changes: 6 additions & 12 deletions core/src/cubos/core/reflection/traits/dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ DictionaryTrait::DictionaryTrait(const Type& keyType, const Type& valueType, Len
, mStop(stop)
, mKey(key)
, mValue(value)
, mInsertDefault(nullptr)
, mInsertCopy(nullptr)
, mInsertMove(nullptr)
, mErase(nullptr)
{
}

Expand Down Expand Up @@ -180,8 +176,7 @@ DictionaryTrait::Iterator::Iterator(void* inner, void* instance, const Dictionar
}

DictionaryTrait::Iterator::Iterator(const Iterator& other)
: mInner(nullptr)
, mInstance(other.mInstance)
: mInstance(other.mInstance)
, mTrait(other.mTrait)

Check warning on line 180 in core/src/cubos/core/reflection/traits/dictionary.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/cubos/core/reflection/traits/dictionary.cpp#L178-L180

Added lines #L178 - L180 were not covered by tests
{
if (!other.isNull())

Check warning on line 182 in core/src/cubos/core/reflection/traits/dictionary.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/cubos/core/reflection/traits/dictionary.cpp#L182

Added line #L182 was not covered by tests
Expand All @@ -190,8 +185,8 @@ DictionaryTrait::Iterator::Iterator(const Iterator& other)
}
}

DictionaryTrait::Iterator::Iterator(Iterator&& other)
noexcept : mInner(other.mInner)
DictionaryTrait::Iterator::Iterator(Iterator&& other) noexcept
: mInner(other.mInner)
, mInstance(other.mInstance)
, mTrait(other.mTrait)

Check warning on line 191 in core/src/cubos/core/reflection/traits/dictionary.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/cubos/core/reflection/traits/dictionary.cpp#L188-L191

Added lines #L188 - L191 were not covered by tests
{
Expand Down Expand Up @@ -245,8 +240,7 @@ DictionaryTrait::ConstIterator::ConstIterator(void* inner, const void* instance,
}

DictionaryTrait::ConstIterator::ConstIterator(const ConstIterator& other)
: mInner(nullptr)
, mInstance(other.mInstance)
: mInstance(other.mInstance)
, mTrait(other.mTrait)

Check warning on line 244 in core/src/cubos/core/reflection/traits/dictionary.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/cubos/core/reflection/traits/dictionary.cpp#L242-L244

Added lines #L242 - L244 were not covered by tests
{
if (!other.isNull())

Check warning on line 246 in core/src/cubos/core/reflection/traits/dictionary.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/cubos/core/reflection/traits/dictionary.cpp#L246

Added line #L246 was not covered by tests
Expand All @@ -255,8 +249,8 @@ DictionaryTrait::ConstIterator::ConstIterator(const ConstIterator& other)
}
}

DictionaryTrait::ConstIterator::ConstIterator(ConstIterator&& other)
noexcept : mInner(other.mInner)
DictionaryTrait::ConstIterator::ConstIterator(ConstIterator&& other) noexcept
: mInner(other.mInner)
, mInstance(other.mInstance)
, mTrait(other.mTrait)

Check warning on line 255 in core/src/cubos/core/reflection/traits/dictionary.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/cubos/core/reflection/traits/dictionary.cpp#L252-L255

Added lines #L252 - L255 were not covered by tests
{
Expand Down

0 comments on commit b81b3b2

Please sign in to comment.