From 6ca18b97aaf249b4fb2d0ef0ee9edb8229690fa5 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Tue, 12 Mar 2024 16:53:27 -0400 Subject: [PATCH] patch --- CMakeLists.txt | 2 +- include/lilfbtf/fwddecl.h | 10 +++++++ include/lilfbtf/system.h | 29 +++++++++++++++++++++ include/lilfbtf/tree.h | 9 +++---- include/lilfbtf/type.h | 55 +++++++++++++++++++++++++++++++++++++++ src/system.cpp | 23 ++++++++++++++++ src/type.cpp | 23 ++++++++++++++++ 7 files changed, 145 insertions(+), 6 deletions(-) create mode 100644 include/lilfbtf/system.h create mode 100644 include/lilfbtf/type.h create mode 100644 src/system.cpp create mode 100644 src/type.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 677e787..717d422 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(lilfbtf5 VERSION 0.1.16) +project(lilfbtf5 VERSION 0.1.17) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/include/lilfbtf/fwddecl.h b/include/lilfbtf/fwddecl.h index dbc52ab..ba1f696 100644 --- a/include/lilfbtf/fwddecl.h +++ b/include/lilfbtf/fwddecl.h @@ -19,6 +19,10 @@ #ifndef LILFBTF5_FWDDECL_H #define LILFBTF5_FWDDECL_H +#include +#include +#include "blt/std/ranges.h" + namespace fb { namespace detail @@ -28,6 +32,12 @@ namespace fb class func_t; class tree_t; + + class type_engine_t; + class gp_system_t; + + using type_id = blt::size_t; + using func_t_call_t = std::function)>; } #endif //LILFBTF5_FWDDECL_H diff --git a/include/lilfbtf/system.h b/include/lilfbtf/system.h new file mode 100644 index 0000000..c4e41b6 --- /dev/null +++ b/include/lilfbtf/system.h @@ -0,0 +1,29 @@ +/* + * + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LILFBTF5_SYSTEM_H +#define LILFBTF5_SYSTEM_H + +#include + +namespace fb +{ + +} + +#endif //LILFBTF5_SYSTEM_H diff --git a/include/lilfbtf/tree.h b/include/lilfbtf/tree.h index 9690fe8..79fe5ef 100644 --- a/include/lilfbtf/tree.h +++ b/include/lilfbtf/tree.h @@ -27,19 +27,18 @@ namespace fb { - using func_t_call_t = std::function)>; class func_t { private: blt::size_t argc_ = 0; - std::string type; + type_id type; const func_t_call_t& func; protected: blt::unsafe::any_t value; public: - explicit func_t(blt::size_t argc, const func_t_call_t& func): - argc_(argc), func(func) + explicit func_t(blt::size_t argc, const func_t_call_t& func, type_id type): + argc_(argc), type(type), func(func) {} [[nodiscard]] inline blt::size_t argc() const @@ -56,7 +55,7 @@ namespace fb return *this; } - inline std::string& getType() + [[nodiscard]] inline type_id getType() const { return type; } diff --git a/include/lilfbtf/type.h b/include/lilfbtf/type.h new file mode 100644 index 0000000..b033b97 --- /dev/null +++ b/include/lilfbtf/type.h @@ -0,0 +1,55 @@ +/* + * + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LILFBTF5_TYPE_H +#define LILFBTF5_TYPE_H + +#include +#include +#include + +namespace fb +{ + class type_engine_t + { + private: + blt::hashmap_t name_to_id; + // also used to assign IDs + std::vector id_to_name; + // TODO: we don't need a hashmap for this. + // Also a bad idea to store references, however these functions should be declared statically so this isn't as big of an issue. + blt::hashmap_t> functions; + public: + type_engine_t() = default; + + type_id register_type(const std::string& type_name) + { + type_id id = id_to_name.size(); + id_to_name.push_back(type_name); + name_to_id[type_name] = id; + return id; + } + + void register_function(const std::string& type_name, func_t_call_t& func) + { + + } + }; +} + +#endif //LILFBTF5_TYPE_H diff --git a/src/system.cpp b/src/system.cpp new file mode 100644 index 0000000..1341cd7 --- /dev/null +++ b/src/system.cpp @@ -0,0 +1,23 @@ +/* + * + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include + +namespace fb +{ + +} \ No newline at end of file diff --git a/src/type.cpp b/src/type.cpp new file mode 100644 index 0000000..1c078c1 --- /dev/null +++ b/src/type.cpp @@ -0,0 +1,23 @@ +/* + * + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include + +namespace fb +{ + +} \ No newline at end of file