Skip to content

Commit

Permalink
Spaic 모듈 코드 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
kmc7468 committed Mar 17, 2020
1 parent c7c60c8 commit 6f632a3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
7 changes: 4 additions & 3 deletions include/spaic/Component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace spaic::vnode
{
class VNode;
}

namespace spaic::comp
{
using NativeNodeName = std::optional<const char *>;
Expand All @@ -19,7 +20,7 @@ class ComponentParent
const NativeNodeName native_node_name;
const std::vector<spaic::vnode::VNode> children;

ComponentParent(NativeNodeName native_node_name, std::vector<spaic::vnode::VNode> children);
ComponentParent(NativeNodeName native_node_name, std::vector<spaic::vnode::VNode> &&children);
};
class ComponentSingle
{
Expand All @@ -29,7 +30,7 @@ class ComponentSingle
ComponentSingle(NativeNodeName native_node_name);

template <typename... T>
ComponentParent operator()(T... children) noexcept;
ComponentParent operator()(T&&... children) noexcept;
};
template <typename Props>
class Component
Expand All @@ -39,7 +40,7 @@ class Component

Component(NativeNodeName native_node_name);
template <typename... T>
ComponentSingle operator()(T... args) noexcept;
ComponentSingle operator()(T&&... args) noexcept;
};
} // namespace spaic::comp

Expand Down
2 changes: 1 addition & 1 deletion include/spaic/ComponentPart.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using Update = std::function<ShouldRender()>;
using Render = std::function<spaic::vnode::VNode()>;

template <typename Props, typename StateSet>
Component<Props> create_component(Props props, StateSet state, Update update, Render render);
Component<Props> create_component(Props &&props, StateSet &&state, const Update &update, const Render &render);
} // namespace spaic::comp

#include <spaic/detail/ComponentPart.hpp>
13 changes: 6 additions & 7 deletions include/spaic/detail/Component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@
namespace spaic::comp
{
template <typename... T>
ComponentParent ComponentSingle::operator()(T... children) noexcept
ComponentParent ComponentSingle::operator()(T&&... children) noexcept
{
// TODO: ComponentSingle::operator()(children)
return ComponentParent(this->native_node_name, {children...});
return ComponentParent(native_node_name, { std::forward<T>(children)... });
}

template <typename Props>
Component<Props>::Component(NativeNodeName native_node_name) : native_node_name(native_node_name)
{
}
Component<Props>::Component(NativeNodeName native_node_name) : native_node_name(native_node_name) {}

template <typename Props>
template <typename... T>
ComponentSingle Component<Props>::operator()(T... args) noexcept
ComponentSingle Component<Props>::operator()(T&&... args) noexcept
{
// TODO: Component::operator()(args)
return ComponentSingle(this->native_node_name);
return ComponentSingle(native_node_name);
}
} // namespace spaic::comp
2 changes: 1 addition & 1 deletion include/spaic/detail/ComponentPart.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace spaic::comp
{
template <typename Props, typename StateSet>
Component<Props> create_component(Props props, StateSet state, Update update, Render render)
Component<Props> create_component(Props &&props, StateSet &&state, const Update &update, const Render &render)
{
// TODO: create_component(props, state, update, render)
return Component<Props>(std::nullopt);
Expand Down
2 changes: 1 addition & 1 deletion include/spaic/detail/Property.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ Property<T, std::optional<T>> optional() noexcept
template <typename T>
Property<T, T> fallback(T &&fallback_value) noexcept
{
return Fallback<T>(fallback_value);
return Fallback<T>(std::forward<T>(fallback_value));
}
} // namespace spaic::props
2 changes: 1 addition & 1 deletion src/spaic/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace spaic::comp
{
ComponentSingle::ComponentSingle(NativeNodeName native_node_name) : native_node_name(native_node_name) {}

ComponentParent::ComponentParent(NativeNodeName native_node_name, std::vector<spaic::vnode::VNode> children) : native_node_name(native_node_name), children(children) {}
ComponentParent::ComponentParent(NativeNodeName native_node_name, std::vector<spaic::vnode::VNode> &&children) : native_node_name(native_node_name), children(std::move(children)) {}
} // namespace spaic::comp

0 comments on commit 6f632a3

Please sign in to comment.