main
Brett 2024-01-24 15:38:01 -05:00
parent 91d688bb62
commit 7f7f6b1d9b
2 changed files with 55 additions and 21 deletions

View File

@ -1,3 +1,3 @@
Start testing: Jan 22 08:33 EST Start testing: Jan 24 14:13 EST
---------------------------------------------------------- ----------------------------------------------------------
End testing: Jan 22 08:33 EST End testing: Jan 24 14:13 EST

View File

@ -26,49 +26,85 @@
#include <vector> #include <vector>
#include "blt/std/hashmap.h" #include "blt/std/hashmap.h"
#include "blt/std/types.h" #include "blt/std/types.h"
#include <variant>
#include <array>
template<typename T> template<typename T>
using allowed_funcs = std::vector<T>; using allowed_funcs = std::vector<T>;
template<typename T>
using func_list = std::vector<allowed_funcs<T>>;
class empty {}; class empty {};
// #define FUNC_DEFINE(NAME, REQUIRED_ARGS, FUNC, ALLOWED) // #define FUNC_DEFINE(NAME, REQUIRED_ARGS, FUNC, ALLOWED)
#define FUNC_ALLOW_ANY std::vector<empty>(); #define FUNC_ALLOW_ANY
#define FUNC_ALLOW_NONE std::vector<empty>(); #define FUNC_ALLOW_NONE
/*
* Define Functions
*/
#define FUNC_FUNCTIONS \ #define FUNC_FUNCTIONS \
FUNC_DEFINE(RANDOM, 0, void(), allowed_funcs(FUNC_ALLOW_NONE)) \ FUNC_DEFINE(Y, 0, void, FUNC_ALLOW_NONE) \
FUNC_DEFINE(NOISE, 0, void(), allowed_funcs(FUNC_ALLOW_NONE)) \ FUNC_DEFINE(X, 0, void, FUNC_ALLOW_NONE) \
FUNC_DEFINE(COLOR, 0, void(), allowed_funcs(FUNC_ALLOW_NONE)) \ FUNC_DEFINE(RANDOM, 0, void, FUNC_ALLOW_NONE) \
FUNC_DEFINE(SCALAR, 0, void(), allowed_funcs(FUNC_ALLOW_NONE)) \ FUNC_DEFINE(NOISE, 0, void, FUNC_ALLOW_NONE) \
FUNC_DEFINE(ADD, 2, void(), allowed_funcs(FUNC_ALLOW_ANY, FUNC_ALLOW_ANY)) \ FUNC_DEFINE(CNOISE, 0, void, FUNC_ALLOW_NONE) \
FUNC_DEFINE(SUB, 2, void(), allowed_funcs(FUNC_ALLOW_ANY, FUNC_ALLOW_ANY)) \ FUNC_DEFINE(SCALAR, 0, void, FUNC_ALLOW_NONE) \
FUNC_DEFINE(MUL, 2, void(), allowed_funcs(FUNC_ALLOW_ANY, FUNC_ALLOW_ANY)) \ FUNC_DEFINE(VECTOR, 0, void, FUNC_ALLOW_NONE) \
FUNC_DEFINE(DIV, 2, void(), allowed_funcs(FUNC_ALLOW_ANY, FUNC_ALLOW_ANY)) \ FUNC_DEFINE(LOG, 1, void, FUNC_ALLOW_ANY) \
FUNC_DEFINE(EXP, 2, void(), allowed_funcs(FUNC_ALLOW_ANY, FUNC_ALLOW_ANY)) \ FUNC_DEFINE(SQRT, 1, void, FUNC_ALLOW_ANY) \
FUNC_DEFINE(LOG, 1, void(), allowed_funcs(FUNC_ALLOW_ANY, FUNC_ALLOW_ANY)) \ FUNC_DEFINE(SIN, 1, void, FUNC_ALLOW_ANY) \
FUNC_DEFINE(SQRT, 1, void(), allowed_funcs(FUNC_ALLOW_ANY, FUNC_ALLOW_ANY)) \ FUNC_DEFINE(COS, 1, void, FUNC_ALLOW_ANY) \
FUNC_DEFINE(ATAN, 1, void, FUNC_ALLOW_ANY) \
FUNC_DEFINE(ADD, 2, void, FUNC_ALLOW_ANY, FUNC_ALLOW_ANY) \
FUNC_DEFINE(SUB, 2, void, FUNC_ALLOW_ANY, FUNC_ALLOW_ANY) \
FUNC_DEFINE(MUL, 2, void, FUNC_ALLOW_ANY, FUNC_ALLOW_ANY) \
FUNC_DEFINE(DIV, 2, void, FUNC_ALLOW_ANY, FUNC_ALLOW_ANY) \
FUNC_DEFINE(OR, 2, void, FUNC_ALLOW_ANY, FUNC_ALLOW_ANY) \
FUNC_DEFINE(AND, 2, void, FUNC_ALLOW_ANY, FUNC_ALLOW_ANY) \
FUNC_DEFINE(XOR, 2, void, FUNC_ALLOW_ANY, FUNC_ALLOW_ANY) \
#undef FUNC_ALLOW_ANY #undef FUNC_ALLOW_ANY
#undef FUNC_ALLOW_NONE #undef FUNC_ALLOW_NONE
#define FUNC_DEFINE(NAME, REQUIRED_ARGS, FUNC, ALLOWED) NAME, /*
* Construct enum
*/
#define FUNC_DEFINE(NAME, REQUIRED_ARGS, FUNC, ...) NAME,
enum class function_t enum class function_t
{ {
FUNC_FUNCTIONS FUNC_FUNCTIONS
m_END
}; };
#undef FUNC_DEFINE #undef FUNC_DEFINE
#define FUNC_DEFINE(NAME, REQUIRED_ARGS, FUNC, ALLOWED) function_t::NAME, static constexpr int OPERATOR_COUNT = static_cast<int>(function_t::m_END);
/*
* Define function lists
*/
#define FUNC_DEFINE(NAME, REQUIRED_ARGS, FUNC, ...) function_t::NAME,
static inline allowed_funcs<function_t> FUNC_ALLOW_ANY_LIST{FUNC_FUNCTIONS}; static inline allowed_funcs<function_t> FUNC_ALLOW_ANY_LIST{FUNC_FUNCTIONS};
static inline allowed_funcs<function_t> FUNC_ALLOW_NONE_LIST{}; static inline allowed_funcs<function_t> FUNC_ALLOW_NONE_LIST{};
#define FUNC_ALLOW_ANY FUNC_ALLOW_ANY_LIST #define FUNC_ALLOW_ANY FUNC_ALLOW_ANY_LIST
#define FUNC_ALLOW_NONE FUNC_ALLOW_NONE_LIST #define FUNC_ALLOW_NONE FUNC_ALLOW_NONE_LIST
#undef FUNC_DEFINE #undef FUNC_DEFINE
#define FUNC_DEFINE(NAME, REQUIRED_ARGS, FUNC, ALLOWED) {REQUIRED_ARGS, function_t::NAME}, /*
HASHMAP<blt::u32, function_t> function_arg_map = { * Create mappings
*/
#define FUNC_DEFINE(NAME, REQUIRED_ARGS, FUNC, ...) REQUIRED_ARGS,
std::array<blt::u32, OPERATOR_COUNT> function_arg_count_map = {
FUNC_FUNCTIONS
};
#undef FUNC_DEFINE
#define FUNC_DEFINE(NAME, REQUIRED_ARGS, FUNC, ...) func_list<function_t>{__VA_ARGS__},
std::array<func_list<function_t>, OPERATOR_COUNT> function_arg_allowed_map = {
FUNC_FUNCTIONS FUNC_FUNCTIONS
}; };
#undef FUNC_DEFINE #undef FUNC_DEFINE
@ -93,6 +129,4 @@ HASHMAP<blt::u32, function_t> function_arg_map = {
// SCALAR // 0 // SCALAR // 0
//}; //};
static constexpr int OPERATOR_COUNT = static_cast<int>(function_t::SCALAR) + 1;
#endif //GP_IMAGE_TEST_FUNCTIONS_H #endif //GP_IMAGE_TEST_FUNCTIONS_H