Skip to content

Commit

Permalink
Creepers are not my enemy. I can boom better than them. πŸ’₯πŸ’₯πŸ’₯πŸ’₯
Browse files Browse the repository at this point in the history
  • Loading branch information
RanolP committed Mar 9, 2020
1 parent b8ec654 commit b6051f1
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 21 deletions.
40 changes: 39 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,44 @@
"array": "cpp",
"tuple": "cpp",
"utility": "cpp",
"functional": "cpp"
"functional": "cpp",
"istream": "cpp",
"variant": "cpp",
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"random": "cpp",
"string": "cpp",
"string_view": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp"
}
}
5 changes: 3 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
cmake_minimum_required(VERSION 3.8.0)
cmake_minimum_required(VERSION 3.12.0)
project(SpaicExample)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options(-fconcepts)

include_directories("../include/")
file(GLOB_RECURSE SOURCE_LIST "./*.cpp")
Expand Down
40 changes: 34 additions & 6 deletions examples/Counter.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <cstdlib>
#include <iostream>

#include <spaic/Prelude.hpp>
#include <spaic-css/Prelude.hpp>
Expand Down Expand Up @@ -42,13 +43,40 @@ VNode render()
return 0;
}

auto counter = create_component(props::counter::all, state::counter::all, update, render);

int main()
{
using namespace props::counter;
auto wtf_is_this_style = css(
width = 10.0_px);
counter(is_dark_theme = true)("Hello, world!");
std::cout << "μ•ˆλ…• μ„Έκ³„λŠ” κ°œλΏ”μ΄" << std::endl;
try
{
using namespace props::counter;
auto wtf_is_this_style = css(
width = 10.0_px);
auto counter = create_component(props::counter::all, state::counter::all, update, render);

counter(is_dark_theme = true)("Hello, world!");
}
catch (const char *e)
{
std::cout << e << std::endl;
}
return EXIT_SUCCESS;
}

// fucking test
void test(VNode node) {}

struct Incompatible
{
int i;
};

void test()
{
using namespace props::counter;
test("STR");
test(true);
std::vector<VNode> wtf;
wtf.push_back("STR");
test(wtf);
// test(Incompatible{3});
}
2 changes: 1 addition & 1 deletion include/spaic-css/detail/CSS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace spaic::css
template <typename... T>
spaic::css::Stylesheet css(T... params)
{
throw "TODO";
throw "TODO: css(params)";
}
} // namespace spaic::css
2 changes: 1 addition & 1 deletion include/spaic/Component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ using Render = std::function<spaic::vnode::VNode()>;
class ComponentBody
{
public:
spaic::vnode::VNode operator()(spaic::vnode::VNode children...) noexcept;
spaic::vnode::VNode operator()(spaic::vnode::VNode children...); // noexcept;
};
template <typename Props>
class Component
Expand Down
2 changes: 1 addition & 1 deletion include/spaic/Message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Message
operator bool();

template <size_t I>
typename std::tuple_element<I, std::tuple<T...>>::type get();
std::tuple_element_t<I, std::tuple<T...>> get();
};

} // namespace spaic::msg
Expand Down
2 changes: 2 additions & 0 deletions include/spaic/Property.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Property

public:
virtual AssignedProperty<I, O> operator=(I &&value) noexcept {};

O &operator*() noexcept;
};

template <typename I, typename O>
Expand Down
17 changes: 16 additions & 1 deletion include/spaic/VNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace spaic::vnode
{
// TODO: Array of VNode should be VNode.
using VNode = std::variant<
using VNodeBase = std::variant<
std::string,
std::nullptr_t,
bool,
Expand All @@ -28,4 +28,19 @@ using VNode = std::variant<
float,
double,
long double>;

class VNode final
{
private:
// I prefer `_value`
// wtf is that noexcept(noexcept())
std::variant<VNodeBase, std::vector<VNode>> _value;

public:
template <typename T>
requires std::is_convertible_v<std::remove_reference_t<T>, VNodeBase> ||
std::is_convertible_v<std::remove_reference_t<T>, std::vector<VNode>>
VNode(T &&v) noexcept(noexcept(std::is_constructible_v<decltype(_value), decltype(std::forward<T>(v))>))
: _value(std::forward<T>(v)) {}
};
} // namespace spaic::vnode
6 changes: 4 additions & 2 deletions include/spaic/detail/Component.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#pragma once

#include <functional>
Expand All @@ -8,7 +9,7 @@

namespace spaic::comp
{
spaic::vnode::VNode ComponentBody::operator()(spaic::vnode::VNode children...) noexcept
spaic::vnode::VNode ComponentBody::operator()(spaic::vnode::VNode children...) // noexcept
{
throw "TODO: ComponentBody::operator()(children)";
}
Expand All @@ -17,7 +18,8 @@ template <typename Props>
template <typename... T>
ComponentBody Component<Props>::operator()(T... args) noexcept
{
throw "TODO: Component::operator()(args)";
// TODO: Component::operator()(args)
return ComponentBody();
}
template <typename Props, typename StateSet>
Component<Props> create_component(Props props, StateSet state, Update update, Render render)
Expand Down
5 changes: 3 additions & 2 deletions src/spaic-css/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
cmake_minimum_required(VERSION 3.8.0)
cmake_minimum_required(VERSION 3.12.0)
project(SpaicCSS)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options(-fconcepts)

include_directories("../../include/")
file(GLOB_RECURSE SOURCE_LIST "./*.cpp")
Expand Down
5 changes: 3 additions & 2 deletions src/spaic-dom/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
cmake_minimum_required(VERSION 3.8.0)
cmake_minimum_required(VERSION 3.12.0)
project(SpaicDOM)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options(-fconcepts)

include_directories("../../include/")
file(GLOB_RECURSE SOURCE_LIST "./*.cpp")
Expand Down
5 changes: 3 additions & 2 deletions src/spaic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
cmake_minimum_required(VERSION 3.8.0)
cmake_minimum_required(VERSION 3.12.0)
project(Spaic)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options(-fconcepts)

include_directories("../../include/")
file(GLOB_RECURSE SOURCE_LIST "./*.cpp")
Expand Down

0 comments on commit b6051f1

Please sign in to comment.