Skip to content

Commit

Permalink
Merge pull request #127 from NuiCpp/feat/copy_deps
Browse files Browse the repository at this point in the history
Clang Tidy Improvements & OBSERVED_BUNDLE_FILES
  • Loading branch information
5cript authored Nov 26, 2024
2 parents f7141ff + 68f7208 commit 7ac7d97
Show file tree
Hide file tree
Showing 29 changed files with 296 additions and 162 deletions.
10 changes: 10 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ Checks: '-*,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-avoid-do-while,
llvm-*,
-llvm-header-guard,
-llvm-include-order,
-llvm-namespace-comment,
clang-analyzer-*,
modernize-*,
-modernize-use-trailing-return-type,
Expand All @@ -17,6 +19,7 @@ Checks: '-*,
-modernize-use-using,
performance-*,
-performance-noexcept-move-constructor,
-performance-enum-size,
portability-*,
readability-*,
-readability-redundant-member-init,
Expand All @@ -25,14 +28,21 @@ Checks: '-*,
-readability-named-parameter,
-readability-redundant-access-specifiers,
-readability-magic-numbers,
-readability-braces-around-statements,
-readability-identifier-length,
hicpp-*,
-hicpp-avoid-c-arrays,
-hicpp-uppercase-literal-suffix,
-hicpp-noexcept-move,
-hicpp-vararg,
-hicpp-member-init,
-hicpp-braces-around-statements,
-hicpp-named-parameter,
misc-*,
-misc-non-private-member-variables-in-classes'
CheckOptions:
- key: AllowPartialMove
value: true

# Disabled Options Explanation:
# CppCoreGuidelines:
Expand Down
5 changes: 3 additions & 2 deletions cmake/frontend/emscripten.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function(nui_prepare_emscripten_target)
NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS
"NO_INLINE;NO_INLINE_INJECT;LEAN_INDEX_HTML"
"TARGET;PREJS;STATIC;UNPACKED_MODE"
"EMSCRIPTEN_LINK_OPTIONS;EMSCRIPTEN_COMPILE_OPTIONS;PARCEL_ARGS;NPM_INSTALL_ARGS"
"EMSCRIPTEN_LINK_OPTIONS;EMSCRIPTEN_COMPILE_OPTIONS;PARCEL_ARGS;NPM_INSTALL_ARGS;OBSERVED_BUNDLE_FILES"
${ARGN}
)

Expand Down Expand Up @@ -43,7 +43,8 @@ function(nui_prepare_emscripten_target)
)

add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/bin/index.html"
OUTPUT "${CMAKE_BINARY_DIR}/bin/index.html"
DEPENDS ${NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS_OBSERVED_BUNDLE_FILES}
COMMAND ${CMAKE_COMMAND} -E copy_directory "${NUI_SOURCE_DIRECTORY}/nui/js" "${NUI_MODULE_BUILD_DIR}/nui-js"
COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_BINARY_DIR}/static"
COMMAND ${CMAKE_COMMAND} -E copy_directory ${NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS_STATIC} "${CMAKE_BINARY_DIR}/static"
Expand Down
18 changes: 8 additions & 10 deletions nui/include/nui/backend/rpc_hub.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <string>
#include <tuple>
#include <utility>
#include <thread>
#include <functional>
#include <unordered_map>
#include <mutex>
Expand Down Expand Up @@ -40,7 +39,7 @@ namespace Nui
template <typename FunctionT>
constexpr static auto wrapFunction(FunctionT&& func)
{
return [func = std::move(func)](nlohmann::json const& args) mutable {
return [func = std::forward<FunctionT>(func)](nlohmann::json const& args) mutable {
func(args);
};
}
Expand All @@ -52,7 +51,7 @@ namespace Nui
template <typename FunctionT>
constexpr static auto wrapFunction(FunctionT&& func)
{
return [func = std::move(func)](nlohmann::json const& args) mutable {
return [func = std::forward<FunctionT>(func)](nlohmann::json const& args) mutable {
func(extractJsonMember<ArgsTypes>(args[Is])...);
};
}
Expand All @@ -78,7 +77,7 @@ namespace Nui
class RpcHub
{
public:
RpcHub(Window& window);
explicit RpcHub(Window& window);
~RpcHub() = default;
RpcHub(const RpcHub&) = delete;
RpcHub& operator=(const RpcHub&) = delete;
Expand Down Expand Up @@ -153,13 +152,15 @@ namespace Nui
template <typename Arg>
void callRemote(std::string const& name, Arg&& arg) const
{
nlohmann::json j = arg;
callRemoteImpl(name, std::move(j));
nlohmann::json json = std::forward<Arg>(arg);
callRemoteImpl(name, json);
}
void callRemote(std::string const& name, nlohmann::json const& json) const
{
callRemoteImpl(name, json);
}
// I dont want to remove this overload in case there are some rvalue nlohmanns?
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
void callRemote(std::string const& name, nlohmann::json&& json) const
{
callRemoteImpl(name, json);
Expand Down Expand Up @@ -238,10 +239,7 @@ namespace Nui
}}})
.first->second.get();
}
else
{
return iter->second.get();
}
return iter->second.get();
}

private:
Expand Down
7 changes: 5 additions & 2 deletions nui/include/nui/data_structures/selectables_registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <utility>
#include <optional>
#include <algorithm>
#include <variant>
#include <limits>
#include <set>
#include <iterator>
Expand Down Expand Up @@ -66,6 +65,7 @@ namespace Nui
ItemWithId(ItemWithId&&) = default;
ItemWithId& operator=(ItemWithId const&) = default;
ItemWithId& operator=(ItemWithId&&) = default;
~ItemWithId() = default;

/// @brief Compares the id of the item.
bool operator<(ItemWithId const& other) const
Expand Down Expand Up @@ -197,7 +197,7 @@ namespace Nui
using IteratorBase<WrappedIterator>::operator=;
using IteratorBase<WrappedIterator>::wrappedIterator_;

ConstIterator(typename ItemContainerType::iterator iter)
explicit ConstIterator(typename ItemContainerType::iterator iter)
: IteratorBase<WrappedIterator>{std::move(iter)}
{}

Expand Down Expand Up @@ -400,6 +400,9 @@ namespace Nui
{
++itemCount_;
++result;
// selected is a set item, and therefore immutable, so we need to const_cast to move it.
// this would break the set, but its cleared afterwards anyway.
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
entry->item = std::move(const_cast<ItemWithId&>(selected).item);
}
}
Expand Down
11 changes: 9 additions & 2 deletions nui/include/nui/event_system/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ namespace Nui
{
virtual bool call(std::size_t eventId) = 0;
virtual bool valid() const = 0;

virtual ~EventImpl() = default;
EventImpl() = default;
EventImpl(EventImpl const&) = default;
EventImpl(EventImpl&&) = default;
EventImpl& operator=(EventImpl const&) = default;
EventImpl& operator=(EventImpl&&) = default;
};

struct TwoFunctorEventImpl : public EventImpl
Expand Down Expand Up @@ -39,7 +45,7 @@ namespace Nui
class Event
{
public:
Event(
explicit Event(
std::function<bool(std::size_t eventId)> action,
std::function<bool()> valid =
[] {
Expand All @@ -51,8 +57,9 @@ namespace Nui
Event(Event&&) = default;
Event& operator=(Event const&) = delete;
Event& operator=(Event&&) = default;
~Event() = default;

operator bool() const
explicit operator bool() const
{
return impl_->valid();
}
Expand Down
2 changes: 0 additions & 2 deletions nui/include/nui/event_system/event_registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
#include <nui/frontend/event_system/event.hpp>
#include <nui/utility/visit_overloaded.hpp>

#include <functional>
#include <limits>
#include <map>

namespace Nui
{
Expand Down
Loading

0 comments on commit 7ac7d97

Please sign in to comment.