Skip to content

Commit

Permalink
Structuring...
Browse files Browse the repository at this point in the history
  • Loading branch information
RanolP committed Feb 21, 2020
1 parent 4777829 commit ff9a0c6
Show file tree
Hide file tree
Showing 18 changed files with 2,737 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
"**/CMakeFiles": true,
"**/cmake_install.cmake": true,
"**/Makefile": true,
"**/CMakeCache.txt": true
"**/CMakeCache.txt": true,
"**/*.a": true
},
"files.associations": {
"*.tcc": "cpp",
"type_traits": "cpp",
"optional": "cpp"
}
}
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ project(SpaicRoot)
add_subdirectory(./src/spaic)
add_subdirectory(./src/spaic-css)
add_subdirectory(./src/spaic-dom)
add_subdirectory(./src/spaic-dui)
add_subdirectory(./src/spaic-dui)

add_subdirectory(./examples)
2,548 changes: 2,548 additions & 0 deletions Doxyfile

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.8.0)
project(SpaicExample)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

include_directories("../include/")
file(GLOB_RECURSE SOURCE_LIST "./*.cpp")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../bin")

add_executable(${PROJECT_NAME} ${SOURCE_LIST})
28 changes: 28 additions & 0 deletions examples/Counter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <cstdlib>

#include <spaic/Prelude.hpp>

namespace props::counter
{
auto is_dark_theme = fallback<bool>(false);
}
class Counter
{
private:
bool test;

public:
template <typename... T>
Counter(T... values)
{
}
};

int main()
{
using namespace props::counter;
// new Counter(is_dark_theme = true);
// Counter{is_dark_theme = true};
// Counter(is_dark_theme = true);
return EXIT_SUCCESS;
}
9 changes: 9 additions & 0 deletions include/spaic-css/CSS.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include <spaic-css/Stylesheet.hpp>

namespace spaic
{
template <typename... T>
spaic::css::Stylesheet css(T... params);
}
8 changes: 8 additions & 0 deletions include/spaic-css/Stylesheet.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

namespace spaic::css
{
class Stylesheet
{
};
} // namespace spaic::css
17 changes: 17 additions & 0 deletions include/spaic/Component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <functional>

namespace spaic
{
using ShouldRender = bool;
template <typename State, typename Msg>
using Update = std::function(Msg)->ShouldRender;

template <typename Props, typename State>
class Component
{
};
template <typename Props, typename State>
Component<Props, State> create_component();
} // namespace spaic
5 changes: 5 additions & 0 deletions include/spaic/Prelude.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include <spaic/Property.hpp>

using namespace spaic::props;
36 changes: 36 additions & 0 deletions include/spaic/Property.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once

#include <optional>

namespace spaic::props
{

template <typename I, typename O>
class AssignedProperty;

template <typename I, typename O>
class Property
{

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

template <typename I, typename O>
class AssignedProperty
{
private:
Property<I, O> &target;
O value;

AssignedProperty(Property<I, O> &target, O &&value);
};
template <typename T>
Property<T, T> &&required() noexcept;

template <typename T>
Property<T, std::optional<T>> &&optional() noexcept;

template <typename T>
Property<T, T> &&fallback(T &&value) noexcept;
} // namespace spaic::props
2 changes: 2 additions & 0 deletions src/spaic-css/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ set(CMAKE_CXX_EXTENSIONS OFF)
include_directories("../../include/")
file(GLOB_RECURSE SOURCE_LIST "./*.cpp")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../../bin")

add_library(${PROJECT_NAME} STATIC ${SOURCE_LIST})
Empty file added src/spaic-css/Stylesheet.cpp
Empty file.
2 changes: 2 additions & 0 deletions src/spaic-dom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ set(CMAKE_CXX_EXTENSIONS OFF)
include_directories("../../include/")
file(GLOB_RECURSE SOURCE_LIST "./*.cpp")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../../bin")

add_library(${PROJECT_NAME} STATIC ${SOURCE_LIST})
Empty file added src/spaic-dom/Test.cpp
Empty file.
2 changes: 2 additions & 0 deletions src/spaic-dui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ set(CMAKE_CXX_EXTENSIONS OFF)
include_directories("../../include/")
file(GLOB_RECURSE SOURCE_LIST "./*.cpp")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../../bin")

add_library(${PROJECT_NAME} STATIC ${SOURCE_LIST})
Empty file added src/spaic-dui/Test.cpp
Empty file.
2 changes: 2 additions & 0 deletions src/spaic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ set(CMAKE_CXX_EXTENSIONS OFF)
include_directories("../../include/")
file(GLOB_RECURSE SOURCE_LIST "./*.cpp")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../../bin")

add_library(${PROJECT_NAME} STATIC ${SOURCE_LIST})
55 changes: 55 additions & 0 deletions src/spaic/Property.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include <spaic/Property.hpp>

#include <optional>

namespace spaic::props
{
template <typename T>
class Required : Property<T, T>
{
public:
AssignedProperty<T, T> operator=(T &&value) noexcept
{
return std::move(new AssignedProperty(&this, value));
};
};
template <typename T>
class Optional : Property<T, std::optional<T>>
{
public:
AssignedProperty<T, std::optional<T>> operator=(T &&value) noexcept
{
return std::move(new AssignedProperty(&this, std::optional(value)));
};
};
template <typename T>
class Fallback : Property<T, T>
{
private:
T &&m_fallback_value;

public:
Fallback(T &&fallback_value) : m_fallback_value(fallback_value)
{
}
AssignedProperty<T, T> operator=(T &&value) noexcept
{
return std::move(new AssignedProperty(&this, value));
};
};
template <typename T>
Property<T, T> &&required() noexcept
{
return std::move(Required<T>());
}
template <typename T>
Property<T, std::optional<T>> &&optional() noexcept
{
return std::move(Optional<T>());
}
template <typename T>
Property<T, T> &&fallback(T &&fallback_value) noexcept
{
return std::move(Fallback<T>(fallback_value));
}
} // namespace spaic::props

0 comments on commit ff9a0c6

Please sign in to comment.