Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major update #7

Merged
merged 23 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, windows-latest]
os: [ubuntu-24.04, windows-latest]
build: [Release]
arch: [x86, x64]
cxx: [g++, clang++-17, ClangCl, v143]
cxx: [g++-14, clang++-19, ClangCl, v143]
feature: [
[NoSIMD, 16, ' ', '/arch:IA32'],
[SSE2, 16, '-msse2', '/arch:SSE2'],
Expand All @@ -26,14 +26,14 @@ jobs:
]

exclude:
- os: ubuntu-22.04
- os: ubuntu-24.04
cxx: v143
- os: ubuntu-22.04
- os: ubuntu-24.04
cxx: ClangCl
- os: windows-latest
cxx: g++
cxx: g++-14
- os: windows-latest
cxx: clang++-17
cxx: clang++-19

- arch: x64
cxx: ClangCl
Expand Down Expand Up @@ -97,14 +97,14 @@ jobs:
- feature: [AVX512, 64, '-mavx512f', '/arch:AVX512']

include:
- cxx: g++
c: gcc
- cxx: clang++-17
c: clang-17
- os: ubuntu-22.04
- cxx: g++-14
c: gcc-14
- cxx: clang++-19
c: clang-19
- os: ubuntu-24.04
arch: x86
cmake_args: "-DCMAKE_CXX_FLAGS=-m32"
- os: ubuntu-22.04
- os: ubuntu-24.04
arch: x64
cmake_args: "-DCMAKE_CXX_FLAGS=-m64"
- os: windows-latest
Expand All @@ -120,21 +120,28 @@ jobs:
- name: Clone
uses: actions/checkout@v4

- if: matrix.os == 'ubuntu-22.04' && matrix.arch == 'x86'
- if: matrix.os == 'ubuntu-24.04' && matrix.arch == 'x86'
name: Prepare Linux for cross-compilation
run: |
sudo apt update
sudo apt install g++-multilib
sudo apt install g++-14-multilib

- if: matrix.cxx == 'clang++-17'
name: Installing Clang 17
- if: matrix.cxx == 'g++-14'
name: Installing G++ 14
run: |
sudo apt update
sudo apt install gcc-14 g++-14

- if: matrix.cxx == 'clang++-19'
name: Installing Clang 19
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main"
sudo apt-add-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main"
sudo apt update
sudo apt install clang-17
sudo apt install gcc-14 g++-14 # clang-19 needs stdc++14.2 see https://github.com/llvm/llvm-project/issues/102336
sudo apt install clang-19

- if: matrix.os == 'ubuntu-22.04'
- if: matrix.os == 'ubuntu-24.04'
name: Configure (Linux)
run: >
mkdir build && cd build && cmake ..
Expand Down
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ if(PROJECT_IS_TOP_LEVEL OR NOT LANGULUS)
include(LangulusUtilities.cmake)

# Add Langulus::Core/Logger/RTTI/SIMD/Fractalloc/Anyness/Flow libraries
fetch_langulus_module(Core GIT_TAG 393d95b6ab13fc5846bda8a3044e4ca62f02fd5a)
fetch_langulus_module(Logger GIT_TAG 69626cd4c738195df0929a1cd867317422506e61)
fetch_langulus_module(RTTI GIT_TAG 720e675b1ea114156c309fe44871e03557e0a64f)
fetch_langulus_module(Core GIT_TAG 35756f11d2f9c475f27b094b8d4c82cd453969fc)
fetch_langulus_module(Logger GIT_TAG dafbeb825071ec60d8403254143f75606151a7e6)
fetch_langulus_module(RTTI GIT_TAG fc49750884ac943dff4261ac5b8dfb2c148423d7)
if(LANGULUS_FEATURE_MANAGED_MEMORY)
fetch_langulus_module(Fractalloc GIT_TAG b4917194b18c139969fb9d0a14bf993ee5f2582a)
fetch_langulus_module(Fractalloc GIT_TAG 66408e8557b1bb3c80615909129342bcebd3fb9f)
endif()
fetch_langulus_module(SIMD GIT_TAG 6611cf422e3c8157b88c086f30966afbf4e7dc6c)
fetch_langulus_module(Anyness GIT_TAG 7e433990052d2cf4c1dbd73afdddb1c697d92c56)
fetch_langulus_module(Flow GIT_TAG 4a0b0f349e5a6f543114b9269f96f55adc025a60)
fetch_langulus_module(SIMD GIT_TAG ead5493049e2800b4c3c02d385c0c6314efac69c)
fetch_langulus_module(Anyness GIT_TAG 46a6513d6bcf3d532e9bf746b50d1299692eb96a)
fetch_langulus_module(Flow GIT_TAG 06000427afccf13016738140d09850f0b8cf837b)
endif()

file(GLOB_RECURSE
Expand All @@ -31,7 +31,7 @@ file(GLOB_RECURSE
)

# Build and install Math library
add_library(LangulusMath ${LANGULUS_LIBRARY_TYPE}
add_langulus_library(LangulusMath
$<TARGET_OBJECTS:LangulusLogger>
$<TARGET_OBJECTS:LangulusRTTI>
$<$<BOOL:${LANGULUS_FEATURE_MANAGED_MEMORY}>:$<TARGET_OBJECTS:LangulusFractalloc>>
Expand Down
1 change: 1 addition & 0 deletions include/Math/Number.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
///
#pragma once
#include "../../source/Numbers/TNumber.inl"
#include "../../source/Numbers/Infinity.hpp"
40 changes: 20 additions & 20 deletions source/Adaptive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,6 @@ namespace Langulus
concept NotAdaptive = ((not Adaptive<T>) and ...);
}

/// Custom name generator at compile-time for adaptive types
template<class T>
consteval auto CustomName(Of<Math::Adaptive<T>>&&) noexcept {
using CLASS = Math::Adaptive<T>;
constexpr auto defaultClassName = RTTI::LastCppNameOf<CLASS>();
::std::array<char, defaultClassName.size() + 1> name {};
::std::size_t offset = 0;

// Write prefix
for (auto i : "Adaptive")
name[offset++] = i;
--offset;

// Write the rest
for (auto i : NameOf<T>())
name[offset++] = i;
return name;
}

namespace Math
{

Expand All @@ -69,8 +50,26 @@ namespace Langulus
///
template<class T>
struct Adaptive : A::Adaptive {
private:
static consteval auto GenerateToken() {
constexpr auto defaultClassName = RTTI::LastCppNameOf<Adaptive>();
::std::array<char, defaultClassName.size() + 1> name {};
::std::size_t offset = 0;

// Write prefix
for (auto i : "Adaptive")
name[offset++] = i;
--offset;

// Write the rest
for (auto i : NameOf<T>())
name[offset++] = i;
return name;
}

public:
LANGULUS(NAME) GenerateToken();
LANGULUS(ABSTRACT) false;
LANGULUS(NAME) CustomNameOf<Adaptive>::Generate();
LANGULUS(TYPED) T;
LANGULUS_BASES(A::Adaptive);
LANGULUS_CONVERTS_TO(Flow::Code);
Expand All @@ -80,6 +79,7 @@ namespace Langulus
// The level in which the data is adapted to
Level mLevel {};

public:
constexpr Adaptive() noexcept = default;
constexpr Adaptive(const T& data, Level level = {}) noexcept
: mValue {data}
Expand Down
53 changes: 53 additions & 0 deletions source/Colors/TColor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
///
/// Langulus::Math
/// Copyright (c) 2014 Dimo Markov <team@langulus.com>
/// Part of the Langulus framework, see https://langulus.com
///
/// SPDX-License-Identifier: GPL-3.0-or-later
///
#include "TColor.inl"


namespace Langulus::Math
{

/// Register all commonly used color types and constants, so they can be
/// instantiated from scripts
void RegisterColors() {
// Types
(void) MetaOf<RGB24>();
(void) MetaOf<RGB96>();
(void) MetaOf<RGBA32>();
(void) MetaOf<RGBA128>();

(void) MetaOf<Red8>();
(void) MetaOf<Green8>();
(void) MetaOf<Blue8>();
(void) MetaOf<Alpha8>();

(void) MetaOf<Red32>();
(void) MetaOf<Green32>();
(void) MetaOf<Blue32>();
(void) MetaOf<Alpha32>();

(void) MetaOf<Depth16>();
(void) MetaOf<Depth32>();

// Constants
(void) MetaOf<Constants::ColorWhite>();
(void) MetaOf<Constants::ColorBlack>();
(void) MetaOf<Constants::ColorGrey>();
(void) MetaOf<Constants::ColorRed>();
(void) MetaOf<Constants::ColorGreen>();
(void) MetaOf<Constants::ColorDarkGreen>();
(void) MetaOf<Constants::ColorBlue>();
(void) MetaOf<Constants::ColorDarkBlue>();
(void) MetaOf<Constants::ColorCyan>();
(void) MetaOf<Constants::ColorDarkCyan>();
(void) MetaOf<Constants::ColorOrange>();
(void) MetaOf<Constants::ColorYellow>();
(void) MetaOf<Constants::ColorPurple>();
(void) MetaOf<Constants::ColorDarkPurple>();
}

} // namespace Langulus::Math
84 changes: 44 additions & 40 deletions source/Colors/TColor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace Langulus
{
namespace Math
{

LANGULUS_API(MATH) extern void RegisterColors();

template<CT::VectorBased>
struct TColor;

Expand Down Expand Up @@ -81,43 +84,6 @@ namespace Langulus

} // namespace Langulus::A


/// Custom name generator at compile-time for colors
template<CT::VectorBased T>
constexpr auto CustomName(Of<Math::TColor<T>>&&) noexcept {
constexpr auto defaultClassName = RTTI::LastCppNameOf<Math::TColor<T>>();
::std::array<char, defaultClassName.size() + 1> name {};
::std::size_t offset {};

// Write prefix
switch (T::MemberCount) {
case 2:
for (auto i : "Grayscale")
name[offset++] = i;
break;
case 3:
for (auto i : "RGB")
name[offset++] = i;
break;
case 4:
for (auto i : "RGBA")
name[offset++] = i;
break;
}

// Write suffix
--offset;
if constexpr (not CT::Same<TypeOf<T>, ::std::uint8_t>) {
if constexpr (CT::Same<TypeOf<T>, float>)
name[offset++] = 'f';
else if constexpr (CT::Same<TypeOf<T>, double>)
name[offset++] = 'd';
else for (auto i : SuffixOf<TypeOf<T>>())
name[offset++] = i;
}
return name;
}

namespace Math
{

Expand All @@ -143,22 +109,60 @@ namespace Langulus
"Invalid number of channels");
static constexpr bool CTTI_ColorTrait = true;

LANGULUS(NAME) CustomNameOf<TColor>::Generate();
private:
/// Custom name generator at compile-time for colors
static constexpr auto GenerateToken() {
constexpr auto defaultClassName = RTTI::LastCppNameOf<TColor>();
::std::array<char, defaultClassName.size() + 1> name {};
::std::size_t offset {};

// Write prefix
switch (T::MemberCount) {
case 2:
for (auto i : "Grayscale")
name[offset++] = i;
break;
case 3:
for (auto i : "RGB")
name[offset++] = i;
break;
case 4:
for (auto i : "RGBA")
name[offset++] = i;
break;
}

// Write suffix
--offset;
if constexpr (not CT::Same<TypeOf<T>, ::std::uint8_t>) {
if constexpr (CT::Same<TypeOf<T>, float>)
name[offset++] = 'f';
else if constexpr (CT::Same<TypeOf<T>, double>)
name[offset++] = 'd';
else for (auto i : SuffixOf<TypeOf<T>>())
name[offset++] = i;
}
return name;
}

public:
LANGULUS(NAME) GenerateToken();
LANGULUS_BASES(
A::ColorOfSize<MemberCount>,
A::ColorOfType<TypeOf<T>>,
T
);

public:
using T::T;
constexpr TColor(const CT::Vector auto&) noexcept;
constexpr TColor(Logger::Color);

using T::Get;

using T::operator =;

template<CT::Number ALTT, CT::Dimension D>
constexpr TColor<T>& operator = (const TColorComponent<ALTT, D>&) noexcept;
constexpr auto operator = (const TColorComponent<ALTT, D>&) noexcept -> TColor&;

operator Flow::Code() const;
operator Logger::Color() const;
Expand Down
Loading