Ver a proveniência

work on function and rendering characters

devel
Ludovic 'Archivist' Lagouardette há 4 anos
ascendente
cometimento
9cdf62d835
2 ficheiros alterados com 290 adições e 7 eliminações
  1. +22
    -7
      include/gp/function.hpp
  2. +268
    -0
      include/gp/rendering/characters.hpp

+ 22
- 7
include/gp/function.hpp Ver ficheiro

@ -2,6 +2,7 @@
#include "gp/exception.hpp"
#include "gp/algorithm/tmp_manip.hpp"
#include "gp/algorithm/move.hpp"
namespace gp{
template <typename>
@ -83,11 +84,27 @@ namespace gp{
delete self.functor;
}
}
if(t.state | ACTIVE)
if(o">!(t.state & ACTIVE))
{
state = INACTIVE;
return;
}
if constexpr (!std::is_same_v<T, function<ret(args...)>>) {
if constexpr (sizeof(callable<T>) <= sizeof(self))
{
t.self.functor->inplace_copy(self.inplace);
new((void*)self.inplace) callable<T>(t);
state = (state_t)(ACTIVE | SOO);
}
else
{
self.functor = new callable<T>(t);
state = (state_t)(ACTIVE | NO_SOO);
}
} else {
if(t.state & SOO)
{
auto& ref = t.self.functor;
ref->inplace_copy((char*)&self);
state = (state_t)(ACTIVE | SOO);
}
else
@ -95,9 +112,7 @@ namespace gp{
self.functor = t.self.functor->all_copy();
state = (state_t)(ACTIVE | NO_SOO);
}
return;
}
state = INACTIVE;
}
function()
@ -105,10 +120,10 @@ namespace gp{
state = INACTIVE;
}
template <typename T>
template<typename T>
function<>(T& t)
{
if constexpr (!std::is_same_v<T, function>) {
if constexpr (!std::is_same_v<T, function&lt;ret(args...)>&gt;) {
if constexpr (sizeof(callable<T>) <= sizeof(self))
{
new((void*)self.inplace) callable<T>(t);
@ -136,7 +151,7 @@ namespace gp{
template <typename T>
function(T&& t)
{
if constexpr (!std::is_same_v<T, function>) {
if constexpr (!std::is_same_v<T, function&lt;ret(args...)>&gt;) {
if constexpr (sizeof(callable<T>) <= sizeof(self))
{
new((void*)self.inplace) callable<T>(gp::move(t));

+ 268
- 0
include/gp/rendering/characters.hpp Ver ficheiro

@ -0,0 +1,268 @@
#pragma once
#include "gp/array.hpp"
using display_char = gp::array<uint8_t, 8>;
constexpr display_char ascii_tr(unsigned char c) {
display_char whitespace{
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000
};
display_char invalid{
0b11111111,
c,
0b10101011,
0b10101011,
0b10011001,
0b10100101,
0b11000011,
0b11111111
};
switch(c) {
case '\0':
return whitespace;
case ' ':
return whitespace;
case '!':
return {
0b00000000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00000000,
0b00010000,
0b00000000
};
case '"':
return {
0b00000000,
0b00101000,
0b00101000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000
};
case '#':
return {
0b00010010,
0b00100100,
0b11111110,
0b00100100,
0b01001000,
0b11111110,
0b01001000,
0b10010000
};
case '$':
return {
0b01111000,
0b10100100,
0b10100000,
0b01111000,
0b00100100,
0b00100100,
0b01111000,
0b00100000
};
case '%':
return {
0b11100001,
0b10100010,
0b11100100,
0b00001000,
0b00010000,
0b00100111,
0b01000101,
0b10000111
};
case '&':
return {
0b00011000,
0b00100100,
0b01000000,
0b00100000,
0b01010100,
0b10001000,
0b01110100,
0b00000000
};
case '\'':
return {
0b00000000,
0b00010000,
0b00010000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000
};
case '(':
return {
0b00100000,
0b01000000,
0b10000000,
0b10000000,
0b10000000,
0b01000000,
0b00100000,
0b00000000
};
case ')':
return {
0b00100000,
0b00010000,
0b00001000,
0b00001000,
0b00001000,
0b00010000,
0b00100000,
0b00000000
};
case '*':
return {
0b00000000,
0b00010000,
0b01111100,
0b00101000,
0b00000000,
0b00000000,
0b00000000,
0b00000000
};
case '+':
return {
0b00000000,
0b00000000,
0b00010000,
0b00010000,
0b01111100,
0b00010000,
0b00010000,
0b00000000
};
case ',':
return {
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00001000,
0b00010000,
0b00000000
};
case '-':
return {
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b01111100,
0b00000000,
0b00000000,
0b00000000
};
case '.':
return {
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00011000,
0b00011000,
0b00000000
};
case '/':
return {
0b00000100,
0b00001000,
0b00001000,
0b00010000,
0b00100000,
0b00100000,
0b01000000,
0b00000000
};
case '0':
return {
0b00111000,
0b01000100,
0b10001010,
0b10010010,
0b10100010,
0b01000100,
0b00111000,
0b00000000
};
case '1':
return {
0b00100000,
0b01100000,
0b00100000,
0b00100000,
0b00100000,
0b00100000,
0b00100000,
0b00000000
};
case '2':
return {
0b00111000,
0b01000100,
0b00000100,
0b00001000,
0b00010000,
0b00100000,
0b11111100,
0b00000000
};
case '3':
return {
0b00111000,
0b01000100,
0b00000100,
0b00011000,
0b00000100,
0b01000100,
0b00111000,
0b00000000
};
case '4':
return {
0b00001000,
0b00011000,
0b00101000,
0b01001000,
0b11111100,
0b00001000,
0b00001000,
0b00000000
};
case '5':
return {
0b01111110,
0b01000000,
0b00111100,
0b00000010,
0b00000010,
0b00000010,
0b01111100,
0b00000000
};
default:
return invalid;
}
}

Carregando…
Cancelar
Guardar