Skip to content

Commit da3a017

Browse files
committed
Now using common testing library
1 parent 9ccb6f0 commit da3a017

19 files changed

Lines changed: 337 additions & 339 deletions

CMakeLists.txt

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,12 @@ project(LangulusFlow
55
HOMEPAGE_URL https://langulus.com
66
)
77

8-
# Check if this project is built as standalone, or a part of something else
9-
if(PROJECT_IS_TOP_LEVEL OR NOT LANGULUS)
8+
# Check if this project is built as standalone, or a part of something else
9+
if (PROJECT_IS_TOP_LEVEL OR NOT LANGULUS)
1010
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
1111
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
12-
1312
include(LangulusUtilities.cmake)
14-
15-
# Add Langulus::Core/Logger/RTTI/SIMD/Fractalloc/Anyness libraries
16-
fetch_langulus_module(Core GIT_TAG 35756f11d2f9c475f27b094b8d4c82cd453969fc)
17-
fetch_langulus_module(Logger GIT_TAG dafbeb825071ec60d8403254143f75606151a7e6)
18-
fetch_langulus_module(RTTI GIT_TAG fc49750884ac943dff4261ac5b8dfb2c148423d7)
19-
if(LANGULUS_FEATURE_MANAGED_MEMORY)
20-
fetch_langulus_module(Fractalloc GIT_TAG 66408e8557b1bb3c80615909129342bcebd3fb9f)
21-
endif()
22-
fetch_langulus_module(SIMD GIT_TAG ead5493049e2800b4c3c02d385c0c6314efac69c)
23-
fetch_langulus_module(Anyness GIT_TAG 46a6513d6bcf3d532e9bf746b50d1299692eb96a)
13+
fetch_langulus_module(Anyness GIT_TAG 07f8aa588bc27c5883c454bebaee04426869cd1e)
2414
endif()
2515

2616
file(GLOB_RECURSE
@@ -29,7 +19,7 @@ file(GLOB_RECURSE
2919
source/*.cpp
3020
)
3121

32-
# Build and install Flow library
22+
# Build and install Flow library
3323
add_langulus_library(LangulusFlow
3424
$<TARGET_OBJECTS:LangulusLogger>
3525
$<TARGET_OBJECTS:LangulusRTTI>
@@ -38,11 +28,12 @@ add_langulus_library(LangulusFlow
3828
${LANGULUS_FLOW_SOURCES}
3929
)
4030

41-
target_include_directories(LangulusFlow PUBLIC include
42-
$<TARGET_PROPERTY:LangulusLogger,INTERFACE_INCLUDE_DIRECTORIES>
43-
$<TARGET_PROPERTY:LangulusRTTI,INTERFACE_INCLUDE_DIRECTORIES>
44-
$<$<BOOL:${LANGULUS_FEATURE_MANAGED_MEMORY}>:$<TARGET_PROPERTY:LangulusFractalloc,INTERFACE_INCLUDE_DIRECTORIES>>
45-
$<TARGET_PROPERTY:LangulusAnyness,INTERFACE_INCLUDE_DIRECTORIES>
31+
target_include_directories(LangulusFlow
32+
PUBLIC $<TARGET_PROPERTY:LangulusLogger,INTERFACE_INCLUDE_DIRECTORIES>
33+
$<TARGET_PROPERTY:LangulusRTTI,INTERFACE_INCLUDE_DIRECTORIES>
34+
$<$<BOOL:${LANGULUS_FEATURE_MANAGED_MEMORY}>:$<TARGET_PROPERTY:LangulusFractalloc,INTERFACE_INCLUDE_DIRECTORIES>>
35+
$<TARGET_PROPERTY:LangulusAnyness,INTERFACE_INCLUDE_DIRECTORIES>
36+
include
4637
)
4738

4839
target_link_libraries(LangulusFlow
@@ -55,6 +46,6 @@ target_compile_definitions(LangulusFlow
5546
)
5647

5748
if(LANGULUS_TESTING)
58-
enable_testing()
49+
enable_testing()
5950
add_subdirectory(test)
6051
endif()

LangulusUtilities.cmake

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
include(FetchContent)
22

3+
4+
# Utility for fetching Langulus libraries using FetchContent
35
function(fetch_langulus_module NAME GIT_TAG TAG)
6+
if (LANGULUS)
7+
message(FATAL_ERROR "You can't fetch Langulus::${NAME}, because this build \
8+
indicates LANGULUS is being build along your project. The library you're \
9+
trying to fetch should already be available locally.")
10+
endif()
11+
412
if(NOT DEFINED LANGULUS_EXTERNAL_DIRECTORY)
513
set(LANGULUS_EXTERNAL_DIRECTORY "${CMAKE_SOURCE_DIR}/external" CACHE PATH
614
"Place where external dependencies will be downloaded")
7-
message(WARNING "LANGULUS_EXTERNAL_DIRECTORY not defined, using default: ${LANGULUS_EXTERNAL_DIRECTORY}")
15+
message(WARNING "LANGULUS_EXTERNAL_DIRECTORY not defined, using default: \
16+
${LANGULUS_EXTERNAL_DIRECTORY}")
817
endif()
918

10-
# Completely avoid downloading or updating anything, once the appropriate folder exists
19+
# Completely avoid downloading or updating anything, once the appropriate
20+
# folder exists
1121
string(TOUPPER ${NAME} UPPERCASE_NAME)
1222
if (EXISTS "${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src")
1323
set(FETCHCONTENT_SOURCE_DIR_LANGULUS${UPPERCASE_NAME} "${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src" CACHE INTERNAL "" FORCE)
14-
message(STATUS "Reusing external library Langulus::${NAME}... (delete ${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src manually in order to redownload)")
24+
message(STATUS "Reusing external library Langulus::${NAME}... \
25+
(delete ${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src manually in order to redownload)")
1526
else()
1627
unset(FETCHCONTENT_SOURCE_DIR_LANGULUS${UPPERCASE_NAME} CACHE)
1728
message(STATUS "Downloading external library Langulus::${NAME}...")
@@ -28,18 +39,23 @@ function(fetch_langulus_module NAME GIT_TAG TAG)
2839
FetchContent_MakeAvailable(Langulus${NAME})
2940
endfunction()
3041

42+
43+
# Utility for fetching external libraries using FetchContent
3144
function(fetch_external_module NAME GIT_REPOSITORY REPO GIT_TAG TAG)
3245
if(NOT DEFINED LANGULUS_EXTERNAL_DIRECTORY)
3346
set(LANGULUS_EXTERNAL_DIRECTORY "${CMAKE_SOURCE_DIR}/external" CACHE PATH
3447
"Place where external dependencies will be downloaded")
35-
message(WARNING "LANGULUS_EXTERNAL_DIRECTORY not defined, using default: ${LANGULUS_EXTERNAL_DIRECTORY}")
48+
message(WARNING "LANGULUS_EXTERNAL_DIRECTORY not defined, \
49+
using default: ${LANGULUS_EXTERNAL_DIRECTORY}")
3650
endif()
3751

38-
# Completely avoid downloading or updating anything, once the appropriate folder exists
52+
# Completely avoid downloading or updating anything, once the appropriate
53+
# folder exists
3954
string(TOUPPER ${NAME} UPPERCASE_NAME)
4055
if (EXISTS "${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src")
4156
set(FETCHCONTENT_SOURCE_DIR_${UPPERCASE_NAME} "${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src" CACHE INTERNAL "" FORCE)
42-
message(STATUS "Reusing external library ${NAME}... (delete ${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src manually in order to redownload)")
57+
message(STATUS "Reusing external library ${NAME}... \
58+
(delete ${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src manually in order to redownload)")
4359
else()
4460
unset(FETCHCONTENT_SOURCE_DIR_${UPPERCASE_NAME} CACHE)
4561
message(STATUS "Downloading external library ${NAME}...")
@@ -59,4 +75,4 @@ function(fetch_external_module NAME GIT_REPOSITORY REPO GIT_TAG TAG)
5975
string(TOLOWER ${NAME} LOWERCASE_NAME)
6076
set(${NAME}_SOURCE_DIR "${${LOWERCASE_NAME}_SOURCE_DIR}" CACHE INTERNAL "${NAME} source directory")
6177
set(${NAME}_BINARY_DIR "${${LOWERCASE_NAME}_BINARY_DIR}" CACHE INTERNAL "${NAME} binary directory")
62-
endfunction()
78+
endfunction()

source/Common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/// SPDX-License-Identifier: GPL-3.0-or-later
77
///
88
#pragma once
9-
#include <Langulus/RTTI/Meta.hpp>
9+
#include <Langulus/MetaOf.hpp>
1010

1111
#if defined(LANGULUS_EXPORT_ALL) || defined(LANGULUS_EXPORT_FLOW)
1212
#define LANGULUS_API_FLOW() LANGULUS_EXPORT()

source/Executor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ namespace Langulus::Flow
120120
}
121121
else if (flow.IsDense()) {
122122
executed = flow.ForEach(
123-
[&](const Inner::Missing& missing) {
123+
[&](const Temporal::Missing& missing) {
124124
// Nest if missing points
125125
Many local;
126126
if (not Execute(missing.mContent, context, local, integrate, skipVerbs, silent)) {
@@ -451,14 +451,14 @@ namespace Langulus::Flow
451451

452452
// Integrate the verb source to environment
453453
Many localSource;
454-
if (not verb.GetSource().Is<Inner::Redundant>()) {
454+
if (not verb.GetSource().Is<Temporal::Redundant>()) {
455455
if (not Execute(verb.GetSource(), context, localSource, true, silent)) {
456456
if (not silent)
457457
FLOW_ERRORS("Error at source of: ", verb);
458458
return false;
459459
}
460460
}
461-
else localSource = verb.GetSource().Get<Inner::Redundant>().mContent;
461+
else localSource = verb.GetSource().Get<Temporal::Redundant>().mContent;
462462

463463
if (localSource.IsInvalid())
464464
localSource = context;

source/Temporal-Logging.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ bool Temporal::DumpInner(const Many& data, bool newline, bool& first) {
116116
DumpSeparator(data, newline or tooLong, first);
117117
DumpTrait(t);
118118
},
119-
[&](const Inner::MissingFuture& p) {
119+
[&](const MissingFuture& p) {
120120
if (p.mSuspended) {
121121
if (p.mContent) {
122122
bool unused = true;
@@ -137,7 +137,7 @@ bool Temporal::DumpInner(const Many& data, bool newline, bool& first) {
137137

138138
DumpMissing(p);
139139
},
140-
[&](const Inner::MissingPast& p) {
140+
[&](const MissingPast& p) {
141141
// Write a missing past linking point
142142
DumpSeparator(data, newline or tooLong, first);
143143

@@ -212,7 +212,7 @@ bool Temporal::DumpInner(const Many& data, bool newline, bool& first) {
212212

213213
/// Dump a missing point as a hexxed address
214214
/// @param p - the missing point to dump
215-
void Temporal::DumpMissing(const Inner::Missing& p) {
215+
void Temporal::DumpMissing(const Missing& p) {
216216
const auto color = p.mFilter.IsPast() ? Logger::PushDarkYellow : Logger::PushDarkGreen;
217217

218218
if (p.mPriority) {

source/Temporal.cpp

Lines changed: 75 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
#include "Time.inl"
99
#include "Code.inl"
1010
#include "Resolvable.inl"
11+
#include "Temporal.hpp"
1112
#include "inner/Missing.hpp"
1213
#include "inner/Entangled.hpp"
13-
#include "Temporal.hpp"
14+
#include "inner/Redundant.hpp"
1415

1516
#if 1
1617
#define VERBOSE_ENABLED() 1
@@ -28,17 +29,75 @@ using namespace Langulus::Flow;
2829
/// Default constructor, add the initial missing future point
2930
/// @param environment - the initial flow environment
3031
Temporal::Temporal() {
31-
mPriorityStack << Inner::MissingFuture {};
32-
mFuture = mPriorityStack.Get<Inner::MissingFuture*>();
32+
mPriorityStack << MissingFuture {};
33+
mFuture = mPriorityStack.Get<MissingFuture*>();
3334
}
3435

3536
/// Construct as a sub-flow
3637
/// @attention assumes parent is a valid pointer
3738
/// @param parent - the parent flow
3839
Temporal::Temporal(Temporal* parent)
3940
: mParent {parent} {
40-
mPriorityStack << Inner::MissingFuture {};
41-
mFuture = mPriorityStack.Get<Inner::MissingFuture*>();
41+
mPriorityStack << MissingFuture {};
42+
mFuture = mPriorityStack.Get<MissingFuture*>();
43+
}
44+
45+
Temporal::Temporal(Temporal&& other) noexcept
46+
: mParent {::std::move(other.mParent)}
47+
, mStart {::std::move(other.mStart)}
48+
, mNow {::std::move(other.mNow)}
49+
, mPrevTime {::std::move(other.mPrevTime)}
50+
, mTimePeriod {::std::move(other.mTimePeriod)}
51+
, mRatePeriod {::std::move(other.mRatePeriod)}
52+
, mPriorityStack {::std::move(other.mPriorityStack)}
53+
, mFuture {::std::move(other.mFuture)}
54+
, mTimeStack {::std::move(other.mTimeStack)}
55+
, mFrequencyStack {::std::move(other.mFrequencyStack)}
56+
, mEntanglements {::std::move(other.mEntanglements)} {}
57+
58+
Temporal::Temporal(const Temporal& other) noexcept
59+
: mParent {other.mParent}
60+
, mStart {other.mStart}
61+
, mNow {other.mNow}
62+
, mPrevTime {other.mPrevTime}
63+
, mTimePeriod {other.mTimePeriod}
64+
, mRatePeriod {other.mRatePeriod}
65+
, mPriorityStack {other.mPriorityStack}
66+
, mFuture {other.mFuture}
67+
, mTimeStack {other.mTimeStack}
68+
, mFrequencyStack {other.mFrequencyStack}
69+
, mEntanglements {other.mEntanglements} {}
70+
71+
Temporal::~Temporal() {}
72+
73+
Temporal& Temporal::operator = (Temporal&& rhs) noexcept {
74+
mParent = ::std::move(rhs.mParent);
75+
mStart = ::std::move(rhs.mStart);
76+
mNow = ::std::move(rhs.mNow);
77+
mPrevTime = ::std::move(rhs.mPrevTime);
78+
mTimePeriod = ::std::move(rhs.mTimePeriod);
79+
mRatePeriod = ::std::move(rhs.mRatePeriod);
80+
mPriorityStack = ::std::move(rhs.mPriorityStack);
81+
mFuture = ::std::move(rhs.mFuture);
82+
mTimeStack = ::std::move(rhs.mTimeStack);
83+
mFrequencyStack = ::std::move(rhs.mFrequencyStack);
84+
mEntanglements = ::std::move(rhs.mEntanglements);
85+
return *this;
86+
}
87+
88+
Temporal& Temporal::operator = (const Temporal& rhs) noexcept {
89+
mParent = rhs.mParent;
90+
mStart = rhs.mStart;
91+
mNow = rhs.mNow;
92+
mPrevTime = rhs.mPrevTime;
93+
mTimePeriod = rhs.mTimePeriod;
94+
mRatePeriod = rhs.mRatePeriod;
95+
mPriorityStack = rhs.mPriorityStack;
96+
mFuture = rhs.mFuture;
97+
mTimeStack = rhs.mTimeStack;
98+
mFrequencyStack = rhs.mFrequencyStack;
99+
mEntanglements = rhs.mEntanglements;
100+
return *this;
42101
}
43102

44103
/// Serialize temporal as Code
@@ -72,11 +131,11 @@ void Temporal::ResetInner(Many& scope) {
72131
if (m.IsDense())
73132
ResetInner(m);
74133
},
75-
[&](Inner::Missing& missing) {
134+
[&](Missing& missing) {
76135
if (missing.mContent.IsDense())
77136
ResetInner(missing.mContent);
78137
},
79-
[&](Inner::Entangled& entangled) {
138+
[&](Entangled& entangled) {
80139
if (entangled.mTrueContent.IsDense())
81140
ResetInner(entangled.mTrueContent);
82141
if (entangled.mFalseContent.IsDense())
@@ -288,12 +347,12 @@ Many Temporal::Compile(const Many& scope, Real priority) {
288347

289348
if (scope.IsPast()) {
290349
// Convert the scope to a MissingPast intermediate format
291-
result = Inner::MissingPast {nullptr, scope, priority};
350+
result = MissingPast {nullptr, scope, priority};
292351
return Abandon(result);
293352
}
294353
else if (scope.IsFuture()) {
295354
// Convert the scope to a MissingFuture intermediate format
296-
result = Inner::MissingFuture {nullptr, scope, 0};
355+
result = MissingFuture {nullptr, scope, 0};
297356
return Abandon(result);
298357
}
299358
else if (scope.IsDeep()) {
@@ -359,11 +418,11 @@ Many Temporal::Compile(const Many& scope, Real priority) {
359418
/// Link a scope's past points to future points that are on the stack
360419
/// @param scope - the scope to link and insert
361420
/// @param entanglementAbove - an optional entanglement from above scope
362-
void Temporal::Link(const Many& scope, const Entanglement& entanglementAbove) {
421+
void Temporal::Link(const Many& scope, const Ref<Entanglement>& entanglementAbove) {
363422
LANGULUS_ASSUME(DevAssumes, mFuture, "Invalid future");
364423

365424
// Every time we push an OR scope we create an entanglement
366-
Entanglement entanglement;
425+
Ref<Entanglement> entanglement;
367426
if (scope.IsOr()) {
368427
entanglement = mEntanglements.Emplace(IndexBack)
369428
.New(entanglementAbove ? entanglementAbove->mParent : nullptr);
@@ -476,12 +535,12 @@ void Temporal::Link(const Many& scope, const Entanglement& entanglementAbove) {
476535
void Temporal::LinkRelative(
477536
const Many& scope,
478537
const Verb& override,
479-
const Entanglement& entanglementAbove
538+
const Ref<Entanglement>& entanglementAbove
480539
) {
481540
LANGULUS_ASSUME(DevAssumes, mFuture, "Invalid future");
482541

483542
// Every time we push an OR scope we create an entanglement
484-
Entanglement entanglement;
543+
Ref<Entanglement> entanglement;
485544
if (scope.IsOr()) {
486545
entanglement = mEntanglements.Emplace(IndexBack)
487546
.New(entanglementAbove ? entanglementAbove->mParent : nullptr);
@@ -665,8 +724,8 @@ void Temporal::LinkRelative(
665724
/// 'future', or in any of the futures below it
666725
bool Temporal::PushFutures(
667726
const Many& scope,
668-
Inner::MissingFuture& future,
669-
const Entanglement& entanglementAbove
727+
MissingFuture& future,
728+
const Ref<Entanglement>& entanglementAbove
670729
) noexcept {
671730
bool atLeastOneSuccess = false;
672731
try {
@@ -679,7 +738,7 @@ bool Temporal::PushFutures(
679738
// If reached, then scope wasn't linked in the immediate future
680739
// Dig deeper for any future points below the provided one
681740
if (not atLeastOneSuccess or not scope.IsExecutableDeep()) {
682-
future.mBelow.ForEach([&](Inner::MissingFuture& below) {
741+
future.mBelow.ForEach([&](MissingFuture& below) {
683742
atLeastOneSuccess |= PushFutures(scope, below, entanglementAbove);
684743
// Continue linking only if the future is uncertain
685744
//return not (future.mBelow.IsOr() and atLeastOneSuccess);

0 commit comments

Comments
 (0)