├── .clang-format ├── .gitignore ├── .gitmodules ├── .ycm_extra_conf.py ├── CMakeLists.txt ├── LICENSE_1_0.txt ├── README.rst ├── VERSION ├── config ├── BuildType.cmake ├── CommonLibs.cmake ├── Defaults.cmake └── Policies.cmake ├── doc ├── CMakeLists.txt ├── diagram │ ├── factory_generator.puml │ └── factory_generator.svg ├── doxygen │ ├── CMakeLists.txt │ ├── Doxyfile-common │ ├── Doxyfile-common.in │ ├── Doxyfile-html │ ├── Doxyfile-html.in │ ├── Doxyfile-xml │ ├── Doxyfile-xml.in │ ├── footer.html │ ├── header.html │ ├── include │ │ └── mirror.hpp │ └── mirror.css ├── howto │ └── workflow.rst ├── images │ ├── qt_factory-dark.png │ └── qt_factory-light.png ├── latex │ ├── CMakeLists.txt │ ├── LaTeX.cmake │ ├── P2560Rx.tex │ ├── beamer_mirror.tex.in │ ├── beamercolorthememirror-dark.sty.in │ ├── beamercolorthememirror-light.sty.in │ ├── beamerouterthememirror.sty.in │ ├── cards_class.pdf │ ├── cost_of_reflection.png │ ├── cpponsea.tex │ ├── data │ │ ├── time-baseline-sequence-1000x1000-i7-1185G7.csv │ │ ├── time-baseline-sequence-250x1000-ARMv7l.csv │ │ ├── time-baseline-sequence-500x1000-Ryzen7-4800HS.csv │ │ ├── time-baseline-sequence-500x1000-i5-2400.csv │ │ ├── time-tbr-copypaste-cmp-100x100-Ryzen7-4800HS.csv │ │ ├── time-tbr-copypaste-cmp-125x100-i5-2400.csv │ │ ├── time-tbr-copypaste-cmp-150x100-i7-1185G7.csv │ │ ├── time-tbr-copypaste-cmp-80x100-ARMv7l.csv │ │ ├── time-tbr-copypaste-op-cmp-100x100-Ryzen7-4800HS.csv │ │ ├── time-tbr-copypaste-op-tmp-100x100-Ryzen7-4800HS.csv │ │ ├── time-tbr-copypaste-tmp-100x100-Ryzen7-4800HS.csv │ │ ├── time-tbr-copypaste-tmp-125x100-i5-2400.csv │ │ ├── time-tbr-copypaste-tmp-150x100-i7-1185G7.csv │ │ ├── time-tbr-copypaste-tmp-80x100-ARMv7l.csv │ │ ├── time-tbr-sequence-cmp-1000x1000-i7-1185G7.csv │ │ ├── time-tbr-sequence-cmp-150x1000-ARMv7l.csv │ │ ├── time-tbr-sequence-cmp-400x1000-Ryzen7-4800HS.csv │ │ ├── time-tbr-sequence-cmp-500x1000-i5-2400.csv │ │ ├── time-tbr-sequence-tmp-1000x1000-i7-1185G7.csv │ │ ├── time-tbr-sequence-tmp-150x1000-ARMv7l.csv │ │ ├── time-tbr-sequence-tmp-400x1000-Ryzen7-4800HS.csv │ │ ├── time-tbr-sequence-tmp-500x1000-i5-2400.csv │ │ ├── time-vbr-copypaste-cmp-100x100-Ryzen7-4800HS.csv │ │ ├── time-vbr-copypaste-cmp-125x100-i5-2400.csv │ │ ├── time-vbr-copypaste-cmp-150x100-i7-1185G7.csv │ │ ├── time-vbr-copypaste-cmp-80x100-ARMv7l.csv │ │ ├── time-vbr-copypaste-op-cmp-100x100-Ryzen7-4800HS.csv │ │ ├── time-vbr-copypaste-op-tmp-100x100-Ryzen7-4800HS.csv │ │ ├── time-vbr-copypaste-tmp-100x100-Ryzen7-4800HS.csv │ │ ├── time-vbr-copypaste-tmp-125x100-i5-2400.csv │ │ ├── time-vbr-copypaste-tmp-150x100-i7-1185G7.csv │ │ ├── time-vbr-copypaste-tmp-80x100-ARMv7l.csv │ │ ├── time-vbr-sequence-cmp-1000x1000-i7-1185G7.csv │ │ ├── time-vbr-sequence-cmp-250x1000-ARMv7l.csv │ │ ├── time-vbr-sequence-cmp-500x1000-Ryzen7-4800HS.csv │ │ ├── time-vbr-sequence-cmp-500x1000-i5-2400.csv │ │ ├── time-vbr-sequence-tmp-1000x1000-i7-1185G7.csv │ │ ├── time-vbr-sequence-tmp-250x1000-ARMv7l.csv │ │ ├── time-vbr-sequence-tmp-500x1000-Ryzen7-4800HS.csv │ │ └── time-vbr-sequence-tmp-500x1000-i5-2400.csv │ ├── deserialize_class.pdf │ ├── deserialize_class.puml │ ├── extras.png │ ├── look_into_mirror.png │ ├── meeting_cpp.tex │ ├── reflection_api.tex │ ├── rpc_class.pdf │ ├── rpc_class.puml │ ├── rpc_sequence.pdf │ ├── rpc_sequence.puml │ ├── serialize_class.pdf │ ├── serialize_class.puml │ ├── tools │ │ ├── common.py │ │ ├── ct-baseline-sequence │ │ ├── ct-per-1-mo │ │ ├── ct-per-n-mo │ │ ├── ct-ratios │ │ ├── measure_ct │ │ ├── mksrc-baseline-sequence │ │ ├── mksrc-tbr-copypaste-cmp │ │ ├── mksrc-tbr-copypaste-op-cmp │ │ ├── mksrc-tbr-copypaste-op-tmp │ │ ├── mksrc-tbr-copypaste-tmp │ │ ├── mksrc-tbr-sequence-cmp │ │ ├── mksrc-tbr-sequence-tmp │ │ ├── mksrc-vbr-copypaste-cmp │ │ ├── mksrc-vbr-copypaste-op-cmp │ │ ├── mksrc-vbr-copypaste-op-tmp │ │ ├── mksrc-vbr-copypaste-tmp │ │ ├── mksrc-vbr-sequence-cmp │ │ ├── mksrc-vbr-sequence-tmp │ │ ├── tbr-copypaste-cmp │ │ ├── tbr-copypaste-op-cmp │ │ ├── tbr-copypaste-op-tmp │ │ ├── tbr-copypaste-tmp │ │ ├── tbr-sequence-cmp │ │ ├── tbr-sequence-tmp │ │ ├── vbr-copypaste-cmp │ │ ├── vbr-copypaste-op-cmp │ │ ├── vbr-copypaste-op-tmp │ │ ├── vbr-copypaste-tmp │ │ ├── vbr-sequence-cmp │ │ └── vbr-sequence-tmp │ ├── use_cases.tex │ └── value_vs_type_based.tex └── logo │ ├── CMakeLists.txt │ └── mirror.png ├── example ├── CMakeLists.txt ├── mirror │ ├── CMakeLists.txt │ ├── Example.cmake │ ├── amount_of_foo.cpp │ ├── applicable_ops.cpp │ ├── are_consecutive.cpp │ ├── are_sorted_by_name.cpp │ ├── are_sorted_by_size.cpp │ ├── chai_on_mirror.cpp │ ├── ctre_integer_concept.cpp │ ├── enum_min_max.cpp │ ├── expression.cpp │ ├── factory │ │ ├── CMakeLists.txt │ │ ├── iostream.cpp │ │ ├── qt │ │ │ ├── README.rst │ │ │ ├── include │ │ │ │ ├── AtomicViewModel.hpp │ │ │ │ ├── Backend.hpp │ │ │ │ ├── BuilderViewModel.hpp │ │ │ │ ├── ConstructorViewModel.hpp │ │ │ │ ├── FactoryViewModel.hpp │ │ │ │ ├── ParameterViewModel.hpp │ │ │ │ ├── Theme.hpp │ │ │ │ └── factory_traits.hpp │ │ │ ├── main.cpp │ │ │ ├── main.qml │ │ │ ├── qml_units │ │ │ │ ├── BoolUnit.qml │ │ │ │ ├── BuilderUnit.qml │ │ │ │ ├── CompositeUnit.qml │ │ │ │ ├── ConstructorUnit.qml │ │ │ │ ├── FactoryUnit.qml │ │ │ │ ├── FloatUnit.qml │ │ │ │ └── StringUnit.qml │ │ │ ├── qt_factory.pro │ │ │ ├── qt_factory.qrc │ │ │ ├── qtquickcontrols2.conf │ │ │ └── src │ │ │ │ ├── AtomicViewModel.cpp │ │ │ │ ├── Backend.cpp │ │ │ │ ├── BuilderViewModel.cpp │ │ │ │ ├── ConstructorViewModel.cpp │ │ │ │ ├── FactoryViewModel.cpp │ │ │ │ ├── ParameterViewModel.cpp │ │ │ │ └── Theme.cpp │ │ └── rapidjson.cpp │ ├── fake_rest_api.cpp │ ├── fake_rpc.cpp │ ├── fetch_from_sqlite.cpp │ ├── filter.cpp │ ├── find_if.cpp │ ├── find_longest_name.cpp │ ├── from_rapidjson.cpp │ ├── gen_puml_diagram.cpp │ ├── good_example.cpp │ ├── group_by.cpp │ ├── has_overloaded_functions.cpp │ ├── has_overloaded_functions_2.cpp │ ├── has_padding.cpp │ ├── hello_enums.cpp │ ├── hello_world.cpp │ ├── integral_data_members.cpp │ ├── interface_revision.cpp │ ├── invoke.cpp │ ├── is_bitfield_enum.cpp │ ├── list_structure.cpp │ ├── metaobject_concept.cpp │ ├── next_weekday.cpp │ ├── overload_arity.cpp │ ├── people.sql │ ├── print_enumerators.cpp │ ├── print_full_name.cpp │ ├── print_months.cpp │ ├── print_op_results.cpp │ ├── print_struct.cpp │ ├── print_traits.cpp │ ├── puml_class_diagram.cpp │ ├── remove_if.cpp │ ├── repeat_message_args.cpp │ ├── repeat_message_json.cpp │ ├── row_polymorphism.cpp │ ├── same_structure.cpp │ ├── simple_json.cpp │ ├── sort_by.cpp │ ├── sql_query_generator.cpp │ ├── testdecl │ │ ├── CMakeLists.txt │ │ ├── cards.hpp │ │ ├── month.hpp │ │ ├── register_cards.cpp │ │ ├── register_month.cpp │ │ ├── register_tetrahedron.cpp │ │ ├── register_weekday.cpp │ │ ├── tetrahedron.hpp │ │ └── weekday.hpp │ ├── to_json_string.cpp │ └── to_rapidjson.cpp └── reflexpr │ ├── CMakeLists.txt │ ├── Example.cmake │ ├── dependency_injection.cpp │ ├── enum_to_string.cpp │ ├── enum_to_string_map.cpp │ ├── named_parameters.cpp │ └── string_to_enum.cpp ├── include ├── CMakeLists.txt ├── mirror │ ├── CMakeLists.txt │ ├── all.hpp │ ├── all_ce.hpp │ ├── apply.hpp │ ├── base_type.hpp │ ├── bitfield.hpp │ ├── branch_predict.hpp │ ├── chaiscript.hpp │ ├── ctre_match.hpp │ ├── diagnostic.hpp │ ├── element_type.hpp │ ├── enum_utils.hpp │ ├── extract.hpp │ ├── factory │ │ ├── builder.hpp │ │ ├── iostream.hpp │ │ └── rapidjson.hpp │ ├── from_string.hpp │ ├── full_name.hpp │ ├── hash.hpp │ ├── init_list.hpp │ ├── interface.hpp │ ├── is_within_limits.hpp │ ├── make_array.hpp │ ├── make_tuple.hpp │ ├── metadata.hpp │ ├── operations.hpp │ ├── overload.hpp │ ├── placeholder.hpp │ ├── preprocessor.hpp │ ├── primitives.hpp │ ├── program_args.hpp │ ├── puml.hpp │ ├── rapidjson.hpp │ ├── registry.hpp │ ├── registry_fwd.hpp │ ├── rest_api.hpp │ ├── sequence.hpp │ ├── serialize │ │ ├── read.hpp │ │ ├── read_backend.hpp │ │ ├── read_rapidjson.hpp │ │ ├── result.hpp │ │ ├── write.hpp │ │ ├── write_backend.hpp │ │ ├── write_json.hpp │ │ └── write_rapidjson.hpp │ ├── sqlite3.hpp │ ├── traits.hpp │ ├── tribool.hpp │ ├── unit_composition.hpp │ └── url.hpp └── reflexpr │ └── CMakeLists.txt ├── source └── CMakeLists.txt ├── toolchain.cmake.bak └── tools ├── build_llvm.sh ├── toolchain.cmake.bak └── update_ce.py /.gitignore: -------------------------------------------------------------------------------- 1 | /_build 2 | /toolchain.cmake 3 | /tools/toolchain.cmake 4 | 5 | # editor swap files 6 | .*.swp 7 | 8 | # Compiled Object files 9 | *.slo 10 | *.lo 11 | *.o 12 | 13 | # Compiled Dynamic libraries 14 | *.so 15 | *.dylib 16 | 17 | # Compiled Static libraries 18 | *.lai 19 | *.la 20 | *.a 21 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "submodules/llvm-project"] 2 | path = submodules/llvm-project 3 | url = https://github.com/matus-chochlik/llvm-project.git 4 | [submodule "submodules/rapidjson"] 5 | path = submodules/rapidjson 6 | url = https://github.com/Tencent/rapidjson.git 7 | [submodule "submodules/ctre"] 8 | path = submodules/ctre 9 | url = https://github.com/hanickadot/compile-time-regular-expressions.git 10 | [submodule "submodules/ChaiScript"] 11 | path = submodules/ChaiScript 12 | url = https://github.com/ChaiScript/ChaiScript.git 13 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | cmake_minimum_required(VERSION 3.16) 7 | 8 | if(NOT EXISTS "${CMAKE_TOOLCHAIN_FILE}") 9 | if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/toolchain.cmake") 10 | set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/toolchain.cmake") 11 | endif() 12 | endif() 13 | 14 | project(Mirror CXX) 15 | 16 | file(STRINGS VERSION MIRROR_VERSION) 17 | 18 | include(config/Policies.cmake) 19 | include(config/Defaults.cmake) 20 | include(config/BuildType.cmake) 21 | include(config/CommonLibs.cmake) 22 | 23 | find_package(Threads REQUIRED) 24 | 25 | add_subdirectory(include) 26 | add_subdirectory(source) 27 | add_subdirectory(example) 28 | add_subdirectory(doc) 29 | -------------------------------------------------------------------------------- /LICENSE_1_0.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Mirror reflection utilities 2 | =========================== 3 | 4 | :Author: Matúš Chochlík 5 | 6 | Reboot of the Mirror reflection utilities implemented on top 7 | of the C++ reflection TS. 8 | 9 | Cloning the Mirror repository 10 | ----------------------------- 11 | :: 12 | 13 | git clone --recursive https://github.com/matus-chochlik/mirror.git 14 | 15 | Building `clang` with reflection support 16 | ---------------------------------------- 17 | 18 | Install the required packages for building `clang`: 19 | 20 | :: 21 | 22 | apt install cmake clang lld ninja-build libgmp-dev libmpfr-dev 23 | 24 | Build and install `clang` and `libc++`: 25 | :: 26 | 27 | cd /path/to/mirror/src/dir && \ 28 | ./tools/build_llvm.sh \ 29 | -b /path/to/llvm/build/dir \ 30 | -i /path/to/llvm/install/dir 31 | 32 | Setting up the toolchain 33 | ------------------------ 34 | 35 | In order for the build system of the `Mirror` library to use `clang` built 36 | and installed in the previous step either copy the default toolchain file: 37 | 38 | :: 39 | 40 | cd /path/to/mirror/src/dir && \ 41 | cp toolchain.cmake.bak toolchain.cmake 42 | 43 | or create your own cmake toolchain file which needs at least to set 44 | the following variables: 45 | 46 | :: 47 | 48 | set(MIRROR_LLVM_PREFIX /path/to/installed/llvm) 49 | set(CMAKE_CXX_COMPILER ${MIRROR_LLVM_PREFIX}/bin/clang++) 50 | 51 | Building Mirror 52 | --------------- 53 | 54 | In order to build the `Mirror` library and its examples with the appropriate 55 | toolchain you can do: 56 | 57 | :: 58 | 59 | mkdir -p /path/to/mirror/build/dir && \ 60 | cd /path/to/mirror/build/dir && \ 61 | cmake \ 62 | -DCMAKE_TOOLCHAIN_FILE=/path/to/mirror/toolchain.cmake \ 63 | /path/to/mirror/src/dir && \ 64 | make -j N 65 | 66 | or 67 | 68 | :: 69 | 70 | mkdir -p /path/to/mirror/build/dir && \ 71 | cd /path/to/mirror/build/dir && \ 72 | cmake \ 73 | -G Ninja \ 74 | -DCMAKE_TOOLCHAIN_FILE=/path/to/mirror/toolchain.cmake \ 75 | /path/to/mirror/src/dir && \ 76 | ninja 77 | 78 | License 79 | ======= 80 | 81 | Copyright 2008-2021 Matus Chochlik. Distributed under the Boost 82 | Software License, Version 1.0. (See accompanying file 83 | LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 84 | 85 | The applications using Qt5 are distributed under 86 | the GNU GENERAL PUBLIC LICENSE version 3. 87 | See http://www.gnu.org/licenses/gpl-3.0.txt 88 | 89 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.9.0 -------------------------------------------------------------------------------- /config/BuildType.cmake: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 7 | message(STATUS "No build type selected, default to Debug") 8 | set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type (default Debug)") 9 | endif() 10 | 11 | if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") 12 | set(MIRROR_DEBUG 0) 13 | else() 14 | set(MIRROR_DEBUG 1) 15 | endif() 16 | -------------------------------------------------------------------------------- /config/CommonLibs.cmake: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | add_library(Mirror::Deps::System INTERFACE IMPORTED) 7 | 8 | if(UNIX AND NOT APPLE) 9 | add_library(Mirror::Deps::RunTime INTERFACE IMPORTED) 10 | set_target_properties( 11 | Mirror::Deps::RunTime PROPERTIES 12 | INTERFACE_LINK_LIBRARIES rt 13 | ) 14 | 15 | add_library(Mirror::Deps::DynLink INTERFACE IMPORTED) 16 | set_target_properties( 17 | Mirror::Deps::DynLink PROPERTIES 18 | INTERFACE_LINK_LIBRARIES dl 19 | ) 20 | 21 | set_target_properties( 22 | Mirror::Deps::System PROPERTIES 23 | INTERFACE_LINK_LIBRARIES 24 | "Mirror::Deps::RunTime;Mirror::Deps::DynLink" 25 | ) 26 | endif() 27 | 28 | add_library(Mirror::Deps::SQLite3 INTERFACE IMPORTED) 29 | 30 | find_package(SQLite3) 31 | if(SQLite3_FOUND) 32 | target_compile_definitions( 33 | Mirror::Deps::SQLite3 34 | INTERFACE MIRROR_HAS_SQLITE3=1 35 | ) 36 | set_target_properties( 37 | Mirror::Deps::SQLite3 PROPERTIES 38 | INTERFACE_LINK_LIBRARIES 39 | SQLite::SQLite3 40 | ) 41 | else() 42 | target_compile_definitions( 43 | Mirror::Deps::SQLite3 44 | INTERFACE MIRROR_HAS_SQLITE3=0 45 | ) 46 | endif() 47 | -------------------------------------------------------------------------------- /config/Defaults.cmake: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | file(GLOB LIBDIR_ENTRIES LIST_DIRECTORIES true 7 | RELATIVE "${MIRROR_LLVM_PREFIX}/lib" 8 | "${MIRROR_LLVM_PREFIX}/lib/*" 9 | ) 10 | foreach(ENTRY ${LIBDIR_ENTRIES}) 11 | if(ENTRY MATCHES ${CMAKE_LIBRARY_ARCHITECTURE_REGEX}) 12 | set(MIRROR_LIBCXX_RPATH "${MIRROR_LLVM_PREFIX}/lib/${ENTRY}") 13 | message(STATUS "Using '${MIRROR_LIBCXX_RPATH}' as libc++ rpath") 14 | endif() 15 | endforeach() 16 | -------------------------------------------------------------------------------- /config/Policies.cmake: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | if(POLICY CMP0054) 7 | cmake_policy(SET CMP0054 NEW) 8 | endif() 9 | 10 | if(POLICY CMP0056) 11 | cmake_policy(SET CMP0056 NEW) 12 | endif() 13 | 14 | if(POLICY CMP0066) 15 | cmake_policy(SET CMP0066 NEW) 16 | endif() 17 | 18 | if(POLICY CMP0067) 19 | cmake_policy(SET CMP0067 NEW) 20 | endif() 21 | 22 | 23 | -------------------------------------------------------------------------------- /doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | add_custom_target(doc) 7 | add_custom_target(install-doc) 8 | 9 | add_subdirectory(logo) 10 | 11 | find_package(Doxygen) 12 | if(Doxygen_FOUND) 13 | add_subdirectory(doxygen) 14 | endif() 15 | 16 | find_program(PDFLATEX_COMMAND pdflatex) 17 | if(PDFLATEX_COMMAND) 18 | add_subdirectory(latex) 19 | endif() 20 | 21 | -------------------------------------------------------------------------------- /doc/doxygen/Doxyfile-common.in: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | 7 | @INCLUDE = @CMAKE_CURRENT_SOURCE_DIR@/Doxyfile-common 8 | PROJECT_NUMBER = @MIRROR_VERSION@ 9 | PROJECT_LOGO = @CMAKE_CURRENT_SOURCE_DIR@/doc/logo/mirror.png 10 | OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@ 11 | 12 | STRIP_FROM_PATH += @PROJECT_BINARY_DIR@/include 13 | STRIP_FROM_PATH += @PROJECT_SOURCE_DIR@/include 14 | STRIP_FROM_PATH += @CMAKE_CURRENT_SOURCE_DIR@/include 15 | STRIP_FROM_PATH += @CMAKE_CURRENT_SOURCE_DIR@/example 16 | STRIP_FROM_INC_PATH += @PROJECT_BINARY_DIR@/include 17 | STRIP_FROM_INC_PATH += @PROJECT_SOURCE_DIR@/include 18 | STRIP_FROM_INC_PATH += @CMAKE_CURRENT_BINARY_DIR@/include 19 | STRIP_FROM_INC_PATH += @CMAKE_CURRENT_SOURCE_DIR@/include 20 | 21 | INPUT += @CMAKE_CURRENT_SOURCE_DIR@/include 22 | INPUT += @PROJECT_SOURCE_DIR@/include 23 | INPUT += @PROJECT_SOURCE_DIR@/example 24 | -------------------------------------------------------------------------------- /doc/doxygen/Doxyfile-html.in: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | 7 | @INCLUDE = @CMAKE_CURRENT_BINARY_DIR@/Doxyfile-common 8 | @INCLUDE = @CMAKE_CURRENT_SOURCE_DIR@/Doxyfile-html 9 | 10 | HTML_HEADER = @CMAKE_CURRENT_SOURCE_DIR@/header.html 11 | HTML_FOOTER = @CMAKE_CURRENT_SOURCE_DIR@/footer.html 12 | HTML_STYLESHEET = @CMAKE_CURRENT_SOURCE_DIR@/mirror.css 13 | 14 | EXAMPLE_PATH = @PROJECT_SOURCE_DIR@/example 15 | IMAGE_PATH = 16 | 17 | WARN_LOGFILE = @CMAKE_CURRENT_BINARY_DIR@/html.log 18 | -------------------------------------------------------------------------------- /doc/doxygen/Doxyfile-xml: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | GENERATE_XML = YES 7 | GENERATE_HTML = No 8 | 9 | GENERATE_LEGEND = NO 10 | GENERATE_TODOLIST = NO 11 | GENERATE_TESTLIST = NO 12 | GENERATE_BUGLIST = NO 13 | GENERATE_DEPRECATEDLIST = NO 14 | 15 | EXAMPLE_PATTERNS = 16 | EXAMPLE_RECURSIVE = NO 17 | 18 | CREATE_SUBDIRS = NO 19 | XML_OUTPUT = xml 20 | 21 | WARNINGS = YES 22 | WARN_IF_UNDOCUMENTED = NO 23 | WARN_NO_PARAMDOC = NO 24 | 25 | -------------------------------------------------------------------------------- /doc/doxygen/Doxyfile-xml.in: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | 7 | @INCLUDE = @CMAKE_CURRENT_BINARY_DIR@/Doxyfile-common 8 | @INCLUDE = @CMAKE_CURRENT_SOURCE_DIR@/Doxyfile-xml 9 | 10 | EXAMPLE_PATH = 11 | IMAGE_PATH = 12 | 13 | WARN_LOGFILE = @CMAKE_CURRENT_BINARY_DIR@/xml.log 14 | -------------------------------------------------------------------------------- /doc/doxygen/footer.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | Copyright © 2015-$year Matúš Chochlík.
4 | <chochlik -at -gmail.com>
5 | Documentation generated on $date by Doxygen (version $doxygenversion). 6 |
7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /doc/doxygen/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | $title 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 |
21 |
22 |
23 |
24 |
25 | $projectname  26 | ($projectnumber) a C++ reflection library 27 |
28 |
29 |
30 |
31 |
32 |
33 | 34 |
35 |
36 |
37 |
38 | 39 | -------------------------------------------------------------------------------- /doc/doxygen/include/mirror.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | /// @mainpage The Mirror library reference 10 | /// 11 | /// This is the Doxygen-generated reference documentation for the Mirror project. 12 | /// 13 | /// @note This documentation is work-in-progress and incomplete. 14 | 15 | /// @brief Mirror's code is placed in this namespace. 16 | namespace mirror { 17 | 18 | /// @defgroup metaobjects Metaobject representation 19 | 20 | /// @defgroup classification Metaobject classification 21 | 22 | /// @defgroup operations Metaobject operations 23 | 24 | /// @defgroup sequence_operations Metaobject sequence operations 25 | 26 | /// @defgroup utilities Utilities 27 | 28 | /// @defgroup metadata Run-time metadata 29 | 30 | } // namespace mirror 31 | -------------------------------------------------------------------------------- /doc/images/qt_factory-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matus-chochlik/mirror/a04ae0fd2c06d953f895f3396583b3d644e5c5e7/doc/images/qt_factory-dark.png -------------------------------------------------------------------------------- /doc/images/qt_factory-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matus-chochlik/mirror/a04ae0fd2c06d953f895f3396583b3d644e5c5e7/doc/images/qt_factory-light.png -------------------------------------------------------------------------------- /doc/latex/beamercolorthememirror-dark.sty.in: -------------------------------------------------------------------------------- 1 | \mode 2 | 3 | \definecolor{mirrormajor}{RGB}{96,128,215} 4 | \definecolor{mirrorminor}{RGB}{2,16,38} 5 | \definecolor{mirrorpage}{RGB}{20,24,28} 6 | \definecolor{mirrortext}{RGB}{245, 250, 255} 7 | \definecolor{mirrorlisting}{RGB}{35,40,45} 8 | \definecolor{mirrorstring}{RGB}{129, 215, 255} 9 | \definecolor{mirrorkeyword}{RGB}{96, 148, 215} 10 | \definecolor{mirrorcomment}{RGB}{192, 192, 203} 11 | \definecolor{mirrorhilite0}{RGB}{215, 148, 96} 12 | \definecolor{mirrorhilite1}{RGB}{215, 215, 128} 13 | \definecolor{mirrorhilite2}{RGB}{215, 128, 128} 14 | 15 | \setbeamercolor{structure}{fg=mirrorminor} 16 | \setbeamercolor{background canvas}{bg=mirrorpage} 17 | \setbeamercolor{normal text}{fg=mirrortext} 18 | 19 | \setbeamercolor{palette primary}{fg=mirrorminor,bg=mirrormajor!70} 20 | \setbeamercolor{palette secondary}{fg=mirrorminor,bg=mirrormajor!75} 21 | \setbeamercolor{palette tertiary}{fg=mirrorminor,bg=mirrormajor!80} 22 | \setbeamercolor{palette quaternary}{fg=mirrorminor,bg=mirrormajor!90} 23 | 24 | \setbeamercolor{titlelike}{parent=palette quaternary} 25 | \setbeamercolor{frametitle}{fg=mirrortext,bg=mirrorpage} 26 | 27 | \setbeamercolor{block title}{fg=mirrorminor,bg=mirrormajor} 28 | \setbeamercolor{block title alerted}{use=alerted text,fg=mirrorminor,bg=alerted text.fg!75!bg} 29 | \setbeamercolor{block title example}{use=example text,fg=mirrorminor,bg=example text.fg!75!bg} 30 | 31 | \setbeamercolor{block body}{parent=normal text,use=block title,bg=block title.bg!25!bg} 32 | \setbeamercolor{block body alerted}{parent=normal text,use=block title alerted,bg=block title alerted.bg!25!bg} 33 | \setbeamercolor{block body example}{parent=normal text,use=block title example,bg=block title example.bg!25!bg} 34 | 35 | \setbeamercolor{sidebar}{bg=mirrormajor!70} 36 | 37 | \setbeamercolor{palette sidebar primary}{fg=mirrorminor} 38 | \setbeamercolor{palette sidebar secondary}{fg=mirrorminor!75} 39 | \setbeamercolor{palette sidebar tertiary}{fg=mirrorminor!75} 40 | \setbeamercolor{palette sidebar quaternary}{fg=mirrorminor} 41 | \setbeamercolor{page number in head/foot}{fg=mirrortext} 42 | 43 | \setbeamercolor*{separation line}{} 44 | \setbeamercolor*{fine separation line}{} 45 | 46 | \mode 47 | 48 | -------------------------------------------------------------------------------- /doc/latex/beamercolorthememirror-light.sty.in: -------------------------------------------------------------------------------- 1 | \mode 2 | 3 | \definecolor{mirrormajor}{RGB}{96,128,215} 4 | \definecolor{mirrorminor}{RGB}{2,16,38} 5 | \definecolor{mirrorpage}{RGB}{255,253,251} 6 | \definecolor{mirrortext}{RGB}{4,6,8} 7 | \definecolor{mirrorlisting}{RGB}{225, 230, 235} 8 | \definecolor{mirrorstring}{RGB}{129, 215, 255} 9 | \definecolor{mirrorkeyword}{RGB}{32, 48, 96} 10 | \definecolor{mirrorcomment}{RGB}{64, 64, 128} 11 | \definecolor{mirrorhilite0}{RGB}{128, 96, 48} 12 | \definecolor{mirrorhilite1}{RGB}{128, 128, 64} 13 | \definecolor{mirrorhilite2}{RGB}{128, 64, 64} 14 | 15 | \setbeamercolor{structure}{fg=mirrorminor} 16 | \setbeamercolor{background canvas}{bg=mirrorpage} 17 | \setbeamercolor{normal text}{fg=mirrortext} 18 | 19 | \setbeamercolor{palette primary}{fg=mirrorminor,bg=mirrormajor!70} 20 | \setbeamercolor{palette secondary}{fg=mirrorminor,bg=mirrormajor!75} 21 | \setbeamercolor{palette tertiary}{fg=mirrorminor,bg=mirrormajor!80} 22 | \setbeamercolor{palette quaternary}{fg=mirrorminor,bg=mirrormajor!90} 23 | 24 | \setbeamercolor{titlelike}{parent=palette quaternary} 25 | \setbeamercolor{frametitle}{fg=mirrortext,bg=mirrorpage} 26 | 27 | \setbeamercolor{block title}{fg=mirrorminor,bg=mirrormajor} 28 | \setbeamercolor{block title alerted}{use=alerted text,fg=mirrorminor,bg=alerted text.fg!75!bg} 29 | \setbeamercolor{block title example}{use=example text,fg=mirrorminor,bg=example text.fg!75!bg} 30 | 31 | \setbeamercolor{block body}{parent=normal text,use=block title,bg=block title.bg!25!bg} 32 | \setbeamercolor{block body alerted}{parent=normal text,use=block title alerted,bg=block title alerted.bg!25!bg} 33 | \setbeamercolor{block body example}{parent=normal text,use=block title example,bg=block title example.bg!25!bg} 34 | 35 | \setbeamercolor{sidebar}{bg=mirrormajor!70} 36 | 37 | \setbeamercolor{palette sidebar primary}{fg=mirrorminor} 38 | \setbeamercolor{palette sidebar secondary}{fg=mirrorminor!75} 39 | \setbeamercolor{palette sidebar tertiary}{fg=mirrorminor!75} 40 | \setbeamercolor{palette sidebar quaternary}{fg=mirrorminor} 41 | \setbeamercolor{page number in head/foot}{fg=mirrortext} 42 | 43 | \setbeamercolor*{separation line}{} 44 | \setbeamercolor*{fine separation line}{} 45 | 46 | \mode 47 | 48 | -------------------------------------------------------------------------------- /doc/latex/beamerouterthememirror.sty.in: -------------------------------------------------------------------------------- 1 | \mode 2 | 3 | \newcommand{\miniscule}{\@setfontsize\miniscule{4}{5}} 4 | \setbeamerfont{headline}{size=\miniscule} 5 | 6 | \beamer@compresstrue 7 | 8 | \AtBeginDocument{ 9 | { 10 | \usebeamerfont*{headline} 11 | \colorlet{global.bg}{bg} 12 | \usebeamercolor{section in head/foot} 13 | \usebeamercolor{frametitle} 14 | 15 | \pgfdeclareverticalshading{beamer@barshade}{\the\paperwidth}{% 16 | color(0ex)=(global.bg);% 17 | color(1ex)=(section in head/foot.bg);% 18 | color(7ex)=(section in head/foot.bg)% 19 | } 20 | \pgfdeclareverticalshading{beamer@aboveframetitle}{\the\paperwidth}{% 21 | color(0ex)=(frametitle.bg);% 22 | color(1ex)=(frametitle.bg);% 23 | color(2ex)=(section in head/foot.bg) 24 | } 25 | 26 | \pgfdeclareverticalshading{beamer@belowframetitle}{\the\paperwidth}{% 27 | color(0ex)=(global.bg);% 28 | color(1ex)=(frametitle.bg) 29 | } 30 | } 31 | } 32 | % Head 33 | \defbeamertemplate*{headline}{mirror theme} 34 | {% 35 | %\vskip-7ex% 36 | \begin{tcolorbox}[ 37 | enhanced, 38 | left=0pt,right=0pt,top=0pt,bottom=0pt, 39 | boxrule=0pt,outer arc=0pt,arc=0pt, 40 | interior code={ 41 | \shade [ 42 | left color=mirrormajor!85!white, 43 | middle color=mirrormajor!85!mirrorminor, 44 | right color=mirrormajor!25!mirrorpage 45 | ](interior.north west) rectangle (interior.south east); 46 | }, 47 | width=\paperwidth,height=0.7cm] 48 | \insertnavigation{1em} 49 | \hfill 50 | \smash{\raisebox{-0.22cm}{\includegraphics[width=0.7cm,height=0.7cm]{mirror.png}}} 51 | \end{tcolorbox} 52 | }% 53 | 54 | 55 | \defbeamertemplate*{frametitle}{mirror theme} 56 | {% 57 | \nointerlineskip 58 | \begin{beamercolorbox}[wd=\paperwidth,leftskip=1em,rightskip=1em]{frametitle}% 59 | \vskip1mm% 60 | \usebeamerfont{frametitle}\usebeamercolor[fg]{frametitle}\insertframetitle 61 | \ifx\insertframesubtitle\@empty% 62 | \else 63 | \usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}~-- \insertframesubtitle% 64 | \fi 65 | \vskip1mm% 66 | \end{beamercolorbox} 67 | } 68 | 69 | \defbeamertemplate*{navigation symbols}{} 70 | 71 | \mode 72 | 73 | 74 | \setbeamertemplate{page number in head/foot}[totalframenumber] 75 | \setbeamertemplate{bibliography item}[text] 76 | -------------------------------------------------------------------------------- /doc/latex/cards_class.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matus-chochlik/mirror/a04ae0fd2c06d953f895f3396583b3d644e5c5e7/doc/latex/cards_class.pdf -------------------------------------------------------------------------------- /doc/latex/cost_of_reflection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matus-chochlik/mirror/a04ae0fd2c06d953f895f3396583b3d644e5c5e7/doc/latex/cost_of_reflection.png -------------------------------------------------------------------------------- /doc/latex/data/time-tbr-copypaste-cmp-100x100-Ryzen7-4800HS.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.046 3 | 200;0.121 4 | 300;0.133 5 | 400;0.183 6 | 500;0.241 7 | 600;0.354 8 | 700;0.499 9 | 800;0.597 10 | 900;0.786 11 | 1000;0.961 12 | 1100;1.220 13 | 1200;1.510 14 | 1300;1.792 15 | 1400;2.114 16 | 1500;2.484 17 | 1600;2.925 18 | 1700;3.329 19 | 1800;3.695 20 | 1900;4.157 21 | 2000;4.723 22 | 2100;5.366 23 | 2200;5.867 24 | 2300;6.765 25 | 2400;7.345 26 | 2500;8.104 27 | 2600;8.863 28 | 2700;9.643 29 | 2800;10.486 30 | 2900;11.438 31 | 3000;12.152 32 | 3100;13.025 33 | 3200;13.881 34 | 3300;15.213 35 | 3400;16.098 36 | 3500;16.977 37 | 3600;18.172 38 | 3700;18.971 39 | 3800;20.455 40 | 3900;21.452 41 | 4000;22.720 42 | 4100;23.945 43 | 4200;25.304 44 | 4300;26.658 45 | 4400;28.212 46 | 4500;29.185 47 | 4600;30.795 48 | 4700;32.304 49 | 4800;33.919 50 | 4900;35.329 51 | 5000;37.050 52 | 5100;38.885 53 | 5200;39.995 54 | 5300;42.100 55 | 5400;43.141 56 | 5500;45.691 57 | 5600;47.202 58 | 5700;50.029 59 | 5800;51.159 60 | 5900;53.503 61 | 6000;54.698 62 | 6100;57.232 63 | 6200;59.472 64 | 6300;60.596 65 | 6400;63.054 66 | 6500;65.677 67 | 6600;67.264 68 | 6700;69.493 69 | 6800;72.691 70 | 6900;74.495 71 | 7000;77.083 72 | 7100;78.940 73 | 7200;81.897 74 | 7300;84.068 75 | 7400;86.600 76 | 7500;88.886 77 | 7600;90.261 78 | 7700;94.036 79 | 7800;95.155 80 | 7900;99.420 81 | 8000;102.198 82 | 8100;104.890 83 | 8200;107.423 84 | 8300;108.909 85 | 8400;114.759 86 | 8500;115.054 87 | 8600;117.482 88 | 8700;120.697 89 | 8800;122.220 90 | 8900;125.933 91 | 9000;129.488 92 | 9100;133.231 93 | 9200;133.915 94 | 9300;139.825 95 | 9400;143.888 96 | 9500;143.787 97 | 9600;149.630 98 | 9700;153.998 99 | 9800;154.565 100 | 9900;158.519 101 | 10000;161.205 102 | -------------------------------------------------------------------------------- /doc/latex/data/time-tbr-copypaste-cmp-125x100-i5-2400.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.069 3 | 200;0.108 4 | 300;0.160 5 | 400;0.250 6 | 500;0.343 7 | 600;0.478 8 | 700;0.626 9 | 800;0.797 10 | 900;1.032 11 | 1000;1.256 12 | 1100;1.506 13 | 1200;1.834 14 | 1300;2.172 15 | 1400;2.577 16 | 1500;3.098 17 | 1600;3.514 18 | 1700;4.033 19 | 1800;4.622 20 | 1900;5.213 21 | 2000;5.934 22 | 2100;6.632 23 | 2200;7.334 24 | 2300;8.160 25 | 2400;9.005 26 | 2500;9.891 27 | 2600;10.918 28 | 2700;11.969 29 | 2800;13.055 30 | 2900;14.079 31 | 3000;15.202 32 | 3100;16.547 33 | 3200;17.913 34 | 3300;19.102 35 | 3400;21.007 36 | 3500;21.933 37 | 3600;23.996 38 | 3700;25.009 39 | 3800;26.337 40 | 3900;28.336 41 | 4000;29.563 42 | 4100;31.966 43 | 4200;33.226 44 | 4300;35.107 45 | 4400;36.997 46 | 4500;38.966 47 | 4600;40.609 48 | 4700;43.555 49 | 4800;44.835 50 | 4900;46.960 51 | 5000;49.229 52 | 5100;51.526 53 | 5200;53.745 54 | 5300;55.969 55 | 5400;58.915 56 | 5500;60.968 57 | 5600;63.690 58 | 5700;66.119 59 | 5800;68.667 60 | 5900;72.485 61 | 6000;73.915 62 | 6100;76.879 63 | 6200;79.577 64 | 6300;82.113 65 | 6400;85.490 66 | 6500;89.832 67 | 6600;91.153 68 | 6700;94.078 69 | 6800;97.310 70 | 6900;100.035 71 | 7000;104.354 72 | 7100;106.247 73 | 7200;112.604 74 | 7300;113.080 75 | 7400;116.422 76 | 7500;120.623 77 | 7600;122.846 78 | 7700;126.316 79 | 7800;130.233 80 | 7900;134.803 81 | 8000;138.748 82 | 8100;141.543 83 | 8200;145.927 84 | 8300;149.068 85 | 8400;153.487 86 | 8500;156.431 87 | 8600;161.219 88 | 8700;166.651 89 | 8800;168.103 90 | 8900;173.761 91 | 9000;176.807 92 | 9100;181.309 93 | 9200;185.033 94 | 9300;190.711 95 | 9400;193.910 96 | 9500;198.252 97 | 9600;204.114 98 | 9700;206.944 99 | 9800;210.977 100 | 9900;216.936 101 | 10000;222.055 102 | 10100;226.525 103 | 10200;232.329 104 | 10300;237.464 105 | 10400;241.956 106 | 10500;247.654 107 | 10600;252.392 108 | 10700;255.875 109 | 10800;261.871 110 | 10900;266.848 111 | 11000;273.154 112 | 11100;283.473 113 | 11200;282.542 114 | 11300;289.427 115 | 11400;293.708 116 | 11500;300.312 117 | 11600;304.937 118 | 11700;309.036 119 | 11800;316.019 120 | 11900;321.585 121 | 12000;328.308 122 | 12100;333.227 123 | 12200;347.011 124 | 12300;355.508 125 | 12400;360.424 126 | 12500;368.479 127 | -------------------------------------------------------------------------------- /doc/latex/data/time-tbr-copypaste-cmp-80x100-ARMv7l.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.247 3 | 200;0.382 4 | 300;0.597 5 | 400;0.962 6 | 500;1.346 7 | 600;1.840 8 | 700;2.483 9 | 800;3.182 10 | 900;3.972 11 | 1000;4.953 12 | 1100;5.973 13 | 1200;7.015 14 | 1300;8.358 15 | 1400;9.812 16 | 1500;11.165 17 | 1600;12.934 18 | 1700;14.733 19 | 1800;16.157 20 | 1900;18.234 21 | 2000;20.303 22 | 2100;22.410 23 | 2200;24.618 24 | 2300;26.598 25 | 2400;29.244 26 | 2500;32.189 27 | 2600;34.894 28 | 2700;37.900 29 | 2800;41.239 30 | 2900;43.811 31 | 3000;46.992 32 | 3100;50.355 33 | 3200;53.681 34 | 3300;57.616 35 | 3400;60.841 36 | 3500;64.507 37 | 3600;68.907 38 | 3700;72.923 39 | 3800;76.888 40 | 3900;80.552 41 | 4000;84.436 42 | 4100;88.911 43 | 4200;92.982 44 | 4300;98.669 45 | 4400;101.986 46 | 4500;107.766 47 | 4600;112.007 48 | 4700;117.166 49 | 4800;123.132 50 | 4900;127.976 51 | 5000;132.797 52 | 5100;140.549 53 | 5200;145.639 54 | 5300;150.813 55 | 5400;157.732 56 | 5500;164.235 57 | 5600;170.617 58 | 5700;177.492 59 | 5800;183.065 60 | 5900;192.399 61 | 6000;198.314 62 | 6100;203.325 63 | 6200;212.835 64 | 6300;221.945 65 | 6400;224.458 66 | 6500;231.343 67 | 6600;238.744 68 | 6700;245.914 69 | 6800;255.934 70 | 6900;261.216 71 | 7000;268.703 72 | 7100;277.530 73 | 7200;284.318 74 | 7300;297.295 75 | 7400;300.755 76 | 7500;313.010 77 | 7600;318.900 78 | 7700;328.011 79 | 7800;334.010 80 | 7900;345.277 81 | 8000;351.023 82 | -------------------------------------------------------------------------------- /doc/latex/data/time-tbr-copypaste-op-cmp-100x100-Ryzen7-4800HS.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.078 3 | 200;0.111 4 | 300;0.138 5 | 400;0.226 6 | 500;0.318 7 | 600;0.458 8 | 700;0.725 9 | 800;0.985 10 | 900;1.145 11 | 1000;1.739 12 | 1100;1.854 13 | 1200;2.160 14 | 1300;2.713 15 | 1400;3.121 16 | 1500;3.656 17 | 1600;4.155 18 | 1700;4.781 19 | 1800;6.285 20 | 1900;6.175 21 | 2000;7.649 22 | 2100;7.697 23 | 2200;9.979 24 | 2300;9.740 25 | 2400;10.494 26 | 2500;12.289 27 | 2600;12.374 28 | 2700;13.533 29 | 2800;14.618 30 | 2900;15.705 31 | 3000;17.346 32 | 3100;19.113 33 | 3200;19.949 34 | 3300;21.007 35 | 3400;22.314 36 | 3500;24.800 37 | 3600;25.647 38 | 3700;26.733 39 | 3800;28.661 40 | 3900;29.965 41 | 4000;31.716 42 | 4100;34.076 43 | 4200;34.768 44 | 4300;36.874 45 | 4400;39.101 46 | 4500;43.711 47 | 4600;43.328 48 | 4700;46.303 49 | 4800;46.935 50 | 4900;49.158 51 | 5000;51.257 52 | 5100;53.565 53 | 5200;55.905 54 | 5300;59.315 55 | 5400;60.178 56 | 5500;62.652 57 | 5600;65.954 58 | 5700;67.359 59 | 5800;70.199 60 | 5900;72.643 61 | 6000;75.026 62 | 6100;79.288 63 | 6200;80.909 64 | 6300;85.597 65 | 6400;88.616 66 | 6500;91.827 67 | 6600;91.855 68 | 6700;94.941 69 | 6800;96.681 70 | 6900;100.954 71 | 7000;103.089 72 | 7100;106.566 73 | 7200;112.151 74 | 7300;113.225 75 | 7400;115.431 76 | 7500;120.886 77 | 7600;123.528 78 | 7700;126.963 79 | 7800;129.857 80 | 7900;136.513 81 | 8000;135.308 82 | 8100;139.874 83 | 8200;146.981 84 | 8300;146.745 85 | 8400;158.432 86 | 8500;153.977 87 | 8600;160.305 88 | 8700;162.976 89 | 8800;168.287 90 | 8900;169.843 91 | 9000;177.968 92 | 9100;179.175 93 | 9200;183.518 94 | 9300;188.265 95 | 9400;194.509 96 | 9500;197.444 97 | 9600;201.453 98 | 9700;213.768 99 | 9800;223.772 100 | 9900;217.888 101 | 10000;218.558 102 | -------------------------------------------------------------------------------- /doc/latex/data/time-tbr-copypaste-op-tmp-100x100-Ryzen7-4800HS.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.084 3 | 200;0.156 4 | 300;0.196 5 | 400;0.340 6 | 500;0.486 7 | 600;0.703 8 | 700;1.095 9 | 800;1.489 10 | 900;1.685 11 | 1000;2.433 12 | 1100;2.959 13 | 1200;3.157 14 | 1300;3.787 15 | 1400;4.712 16 | 1500;5.080 17 | 1600;5.897 18 | 1700;7.322 19 | 1800;8.400 20 | 1900;8.542 21 | 2000;9.524 22 | 2100;10.636 23 | 2200;11.699 24 | 2300;12.824 25 | 2400;14.023 26 | 2500;15.389 27 | 2600;16.821 28 | 2700;18.076 29 | 2800;19.470 30 | 2900;21.281 31 | 3000;22.624 32 | 3100;26.237 33 | 3200;26.112 34 | 3300;29.793 35 | 3400;29.195 36 | 3500;31.331 37 | 3600;32.847 38 | 3700;35.202 39 | 3800;40.030 40 | 3900;43.178 41 | 4000;41.213 42 | 4100;44.021 43 | 4200;45.697 44 | 4300;48.097 45 | 4400;50.035 46 | 4500;52.573 47 | 4600;55.781 48 | 4700;57.691 49 | 4800;66.335 50 | 4900;64.244 51 | 5000;65.919 52 | 5100;71.834 53 | 5200;71.605 54 | 5300;74.053 55 | 5400;77.676 56 | 5500;87.735 57 | 5600;83.148 58 | 5700;94.666 59 | 5800;90.218 60 | 5900;99.136 61 | 6000;96.713 62 | 6100;109.366 63 | 6200;102.549 64 | 6300;107.848 65 | 6400;109.562 66 | 6500;123.042 67 | 6600;117.094 68 | 6700;120.548 69 | 6800;124.941 70 | 6900;130.349 71 | 7000;132.315 72 | 7100;136.517 73 | 7200;152.418 74 | 7300;144.399 75 | 7400;148.267 76 | 7500;153.366 77 | 7600;157.909 78 | 7700;176.228 79 | 7800;167.654 80 | 7900;170.965 81 | 8000;175.061 82 | 8100;194.498 83 | 8200;184.196 84 | 8300;190.579 85 | 8400;195.102 86 | 8500;205.199 87 | 8600;202.278 88 | 8700;214.498 89 | 8800;211.847 90 | 8900;218.475 91 | 9000;229.510 92 | 9100;229.270 93 | 9200;232.421 94 | 9300;237.037 95 | 9400;243.226 96 | 9500;250.412 97 | 9600;254.910 98 | 9700;263.829 99 | 9800;264.700 100 | 9900;273.033 101 | 10000;277.943 102 | -------------------------------------------------------------------------------- /doc/latex/data/time-tbr-copypaste-tmp-100x100-Ryzen7-4800HS.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.080 3 | 200;0.147 4 | 300;0.144 5 | 400;0.249 6 | 500;0.345 7 | 600;0.660 8 | 700;0.834 9 | 800;1.011 10 | 900;1.317 11 | 1000;1.623 12 | 1100;2.026 13 | 1200;2.423 14 | 1300;2.871 15 | 1400;3.460 16 | 1500;3.985 17 | 1600;4.614 18 | 1700;5.213 19 | 1800;6.082 20 | 1900;6.741 21 | 2000;7.591 22 | 2100;9.101 23 | 2200;9.577 24 | 2300;10.577 25 | 2400;11.324 26 | 2500;12.432 27 | 2600;13.584 28 | 2700;14.724 29 | 2800;15.800 30 | 2900;17.153 31 | 3000;18.327 32 | 3100;19.664 33 | 3200;21.236 34 | 3300;22.467 35 | 3400;24.014 36 | 3500;25.150 37 | 3600;26.672 38 | 3700;28.449 39 | 3800;30.203 40 | 3900;32.071 41 | 4000;34.070 42 | 4100;35.443 43 | 4200;37.762 44 | 4300;39.272 45 | 4400;41.112 46 | 4500;43.365 47 | 4600;45.228 48 | 4700;47.976 49 | 4800;49.197 50 | 4900;51.501 51 | 5000;53.525 52 | 5100;55.719 53 | 5200;57.954 54 | 5300;60.337 55 | 5400;62.915 56 | 5500;66.429 57 | 5600;68.284 58 | 5700;71.177 59 | 5800;73.576 60 | 5900;75.893 61 | 6000;78.276 62 | 6100;82.885 63 | 6200;84.786 64 | 6300;87.256 65 | 6400;89.210 66 | 6500;92.748 67 | 6600;95.328 68 | 6700;98.173 69 | 6800;101.712 70 | 6900;106.395 71 | 7000;109.878 72 | 7100;112.632 73 | 7200;114.988 74 | 7300;118.791 75 | 7400;121.451 76 | 7500;124.764 77 | 7600;127.446 78 | 7700;131.625 79 | 7800;135.148 80 | 7900;138.775 81 | 8000;142.097 82 | 8100;147.359 83 | 8200;151.521 84 | 8300;153.638 85 | 8400;157.493 86 | 8500;163.523 87 | 8600;165.835 88 | 8700;169.518 89 | 8800;174.058 90 | 8900;178.203 91 | 9000;181.691 92 | 9100;186.875 93 | 9200;191.212 94 | 9300;195.518 95 | 9400;202.185 96 | 9500;203.394 97 | 9600;208.848 98 | 9700;213.616 99 | 9800;220.103 100 | 9900;222.651 101 | 10000;229.512 102 | -------------------------------------------------------------------------------- /doc/latex/data/time-tbr-copypaste-tmp-125x100-i5-2400.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.071 3 | 200;0.127 4 | 300;0.210 5 | 400;0.311 6 | 500;0.444 7 | 600;0.632 8 | 700;0.843 9 | 800;1.104 10 | 900;1.425 11 | 1000;1.762 12 | 1100;2.216 13 | 1200;2.648 14 | 1300;3.166 15 | 1400;3.726 16 | 1500;4.381 17 | 1600;5.253 18 | 1700;5.766 19 | 1800;6.642 20 | 1900;7.407 21 | 2000;8.424 22 | 2100;9.498 23 | 2200;10.587 24 | 2300;11.941 25 | 2400;13.054 26 | 2500;14.294 27 | 2600;15.514 28 | 2700;17.189 29 | 2800;18.620 30 | 2900;19.899 31 | 3000;21.662 32 | 3100;23.582 33 | 3200;24.789 34 | 3300;26.925 35 | 3400;28.321 36 | 3500;30.547 37 | 3600;32.189 38 | 3700;34.464 39 | 3800;36.328 40 | 3900;38.806 41 | 4000;41.430 42 | 4100;43.266 43 | 4200;46.817 44 | 4300;48.418 45 | 4400;50.714 46 | 4500;53.375 47 | 4600;55.951 48 | 4700;59.703 49 | 4800;61.569 50 | 4900;64.370 51 | 5000;67.273 52 | 5100;70.298 53 | 5200;73.300 54 | 5300;78.465 55 | 5400;81.386 56 | 5500;82.830 57 | 5600;86.106 58 | 5700;89.360 59 | 5800;93.866 60 | 5900;96.829 61 | 6000;99.781 62 | 6100;103.178 63 | 6200;107.050 64 | 6300;110.712 65 | 6400;114.650 66 | 6500;118.546 67 | 6600;122.156 68 | 6700;125.983 69 | 6800;129.944 70 | 6900;134.488 71 | 7000;138.578 72 | 7100;142.171 73 | 7200;147.162 74 | 7300;151.093 75 | 7400;155.638 76 | 7500;159.460 77 | 7600;163.953 78 | 7700;169.098 79 | 7800;173.709 80 | 7900;182.048 81 | 8000;184.294 82 | 8100;189.459 83 | 8200;193.797 84 | 8300;198.709 85 | 8400;205.484 86 | 8500;210.441 87 | 8600;215.488 88 | 8700;220.582 89 | 8800;225.552 90 | 8900;230.731 91 | 9000;238.280 92 | 9100;242.724 93 | 9200;249.873 94 | 9300;255.244 95 | 9400;259.501 96 | 9500;273.474 97 | 9600;272.615 98 | 9700;278.564 99 | 9800;284.502 100 | 9900;289.674 101 | 10000;304.117 102 | 10100;303.837 103 | 10200;308.667 104 | 10300;316.033 105 | 10400;322.490 106 | 10500;329.258 107 | 10600;334.775 108 | 10700;342.097 109 | 10800;348.337 110 | 10900;362.083 111 | 11000;362.033 112 | 11100;374.190 113 | 11200;374.724 114 | 11300;383.064 115 | 11400;388.717 116 | 11500;396.004 117 | 11600;402.834 118 | 11700;418.110 119 | 11800;417.062 120 | 11900;424.898 121 | 12000;433.637 122 | 12100;440.044 123 | 12200;447.145 124 | 12300;454.819 125 | 12400;461.619 126 | 12500;470.920 127 | -------------------------------------------------------------------------------- /doc/latex/data/time-tbr-copypaste-tmp-80x100-ARMv7l.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.277 3 | 200;0.468 4 | 300;0.773 5 | 400;1.199 6 | 500;1.762 7 | 600;2.429 8 | 700;3.215 9 | 800;4.137 10 | 900;5.203 11 | 1000;6.469 12 | 1100;7.775 13 | 1200;9.334 14 | 1300;10.966 15 | 1400;12.712 16 | 1500;14.457 17 | 1600;16.596 18 | 1700;18.548 19 | 1800;20.851 20 | 1900;23.150 21 | 2000;25.923 22 | 2100;28.603 23 | 2200;31.524 24 | 2300;34.465 25 | 2400;38.126 26 | 2500;41.548 27 | 2600;45.215 28 | 2700;48.608 29 | 2800;53.018 30 | 2900;56.833 31 | 3000;60.707 32 | 3100;65.371 33 | 3200;69.366 34 | 3300;73.921 35 | 3400;77.743 36 | 3500;82.839 37 | 3600;87.145 38 | 3700;91.816 39 | 3800;97.460 40 | 3900;102.754 41 | 4000;108.092 42 | 4100;112.976 43 | 4200;119.379 44 | 4300;125.456 45 | 4400;131.674 46 | 4500;138.589 47 | 4600;144.047 48 | 4700;151.199 49 | 4800;157.274 50 | 4900;163.195 51 | 5000;170.131 52 | 5100;178.568 53 | 5200;185.324 54 | 5300;193.717 55 | 5400;200.095 56 | 5500;207.728 57 | 5600;215.894 58 | 5700;223.298 59 | 5800;232.880 60 | 5900;241.680 61 | 6000;248.449 62 | 6100;259.489 63 | 6200;267.717 64 | 6300;274.497 65 | 6400;286.972 66 | 6500;294.003 67 | 6600;299.883 68 | 6700;310.673 69 | 6800;321.336 70 | 6900;330.004 71 | 7000;339.390 72 | 7100;348.752 73 | 7200;356.136 74 | 7300;366.863 75 | 7400;377.553 76 | 7500;388.220 77 | 7600;396.526 78 | 7700;409.928 79 | 7800;417.413 80 | 7900;431.769 81 | 8000;443.385 82 | -------------------------------------------------------------------------------- /doc/latex/data/time-vbr-copypaste-cmp-100x100-Ryzen7-4800HS.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.047 3 | 200;0.058 4 | 300;0.081 5 | 400;0.089 6 | 500;0.130 7 | 600;0.122 8 | 700;0.187 9 | 800;0.197 10 | 900;0.242 11 | 1000;0.256 12 | 1100;0.297 13 | 1200;0.363 14 | 1300;0.361 15 | 1400;0.464 16 | 1500;0.509 17 | 1600;0.620 18 | 1700;0.648 19 | 1800;0.837 20 | 1900;0.834 21 | 2000;0.905 22 | 2100;1.187 23 | 2200;1.175 24 | 2300;1.147 25 | 2400;1.619 26 | 2500;1.358 27 | 2600;1.591 28 | 2700;1.681 29 | 2800;1.719 30 | 2900;2.076 31 | 3000;2.061 32 | 3100;2.226 33 | 3200;3.048 34 | 3300;2.506 35 | 3400;2.842 36 | 3500;3.344 37 | 3600;3.160 38 | 3700;3.183 39 | 3800;3.516 40 | 3900;4.151 41 | 4000;3.741 42 | 4100;4.131 43 | 4200;4.123 44 | 4300;4.673 45 | 4400;4.384 46 | 4500;5.032 47 | 4600;5.149 48 | 4700;6.260 49 | 4800;5.290 50 | 4900;5.944 51 | 5000;6.884 52 | 5100;6.368 53 | 5200;6.380 54 | 5300;6.775 55 | 5400;7.292 56 | 5500;7.541 57 | 5600;9.139 58 | 5700;8.096 59 | 5800;8.869 60 | 5900;8.723 61 | 6000;9.117 62 | 6100;9.866 63 | 6200;10.433 64 | 6300;10.568 65 | 6400;10.532 66 | 6500;11.166 67 | 6600;11.599 68 | 6700;12.042 69 | 6800;12.870 70 | 6900;13.312 71 | 7000;13.485 72 | 7100;13.731 73 | 7200;13.834 74 | 7300;14.973 75 | 7400;16.925 76 | 7500;14.737 77 | 7600;16.128 78 | 7700;16.750 79 | 7800;17.116 80 | 7900;17.557 81 | 8000;18.356 82 | 8100;18.610 83 | 8200;18.961 84 | 8300;18.807 85 | 8400;19.802 86 | 8500;20.803 87 | 8600;21.682 88 | 8700;22.545 89 | 8800;22.038 90 | 8900;23.306 91 | 9000;24.773 92 | 9100;27.895 93 | 9200;25.376 94 | 9300;25.298 95 | 9400;26.506 96 | 9500;26.876 97 | 9600;26.729 98 | 9700;27.354 99 | 9800;30.920 100 | 9900;29.778 101 | 10000;29.422 102 | -------------------------------------------------------------------------------- /doc/latex/data/time-vbr-copypaste-cmp-125x100-i5-2400.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.047 3 | 200;0.057 4 | 300;0.084 5 | 400;0.105 6 | 500;0.136 7 | 600;0.174 8 | 700;0.222 9 | 800;0.263 10 | 900;0.335 11 | 1000;0.390 12 | 1100;0.460 13 | 1200;0.528 14 | 1300;0.628 15 | 1400;0.721 16 | 1500;0.838 17 | 1600;0.946 18 | 1700;1.072 19 | 1800;1.183 20 | 1900;1.316 21 | 2000;1.442 22 | 2100;1.576 23 | 2200;1.729 24 | 2300;1.897 25 | 2400;2.042 26 | 2500;2.231 27 | 2600;2.432 28 | 2700;2.648 29 | 2800;2.844 30 | 2900;3.097 31 | 3000;3.346 32 | 3100;3.539 33 | 3200;3.785 34 | 3300;4.084 35 | 3400;4.272 36 | 3500;4.504 37 | 3600;4.783 38 | 3700;5.030 39 | 3800;5.279 40 | 3900;5.539 41 | 4000;5.792 42 | 4100;6.080 43 | 4200;6.363 44 | 4300;6.706 45 | 4400;7.159 46 | 4500;7.271 47 | 4600;7.764 48 | 4700;7.963 49 | 4800;8.338 50 | 4900;8.691 51 | 5000;9.150 52 | 5100;9.706 53 | 5200;10.043 54 | 5300;10.362 55 | 5400;10.839 56 | 5500;11.266 57 | 5600;11.800 58 | 5700;12.333 59 | 5800;12.903 60 | 5900;13.291 61 | 6000;13.772 62 | 6100;14.478 63 | 6200;14.891 64 | 6300;15.203 65 | 6400;15.802 66 | 6500;16.529 67 | 6600;16.818 68 | 6700;17.292 69 | 6800;17.831 70 | 6900;18.593 71 | 7000;18.905 72 | 7100;19.608 73 | 7200;20.007 74 | 7300;20.894 75 | 7400;21.513 76 | 7500;21.862 77 | 7600;22.574 78 | 7700;23.457 79 | 7800;23.900 80 | 7900;24.676 81 | 8000;25.669 82 | 8100;25.835 83 | 8200;26.950 84 | 8300;27.389 85 | 8400;27.994 86 | 8500;28.814 87 | 8600;29.611 88 | 8700;30.449 89 | 8800;31.216 90 | 8900;31.824 91 | 9000;32.934 92 | 9100;33.502 93 | 9200;34.522 94 | 9300;35.254 95 | 9400;35.853 96 | 9500;37.425 97 | 9600;37.705 98 | 9700;38.613 99 | 9800;39.698 100 | 9900;40.246 101 | 10000;41.283 102 | 10100;42.225 103 | 10200;43.227 104 | 10300;44.206 105 | 10400;45.149 106 | 10500;45.886 107 | 10600;47.235 108 | 10700;48.049 109 | 10800;49.168 110 | 10900;50.965 111 | 11000;51.520 112 | 11100;52.053 113 | 11200;53.102 114 | 11300;54.691 115 | 11400;55.693 116 | 11500;56.962 117 | 11600;58.371 118 | 11700;58.722 119 | 11800;60.014 120 | 11900;61.414 121 | 12000;62.741 122 | 12100;63.922 123 | 12200;64.902 124 | 12300;66.073 125 | 12400;67.367 126 | 12500;69.238 127 | -------------------------------------------------------------------------------- /doc/latex/data/time-vbr-copypaste-cmp-150x100-i7-1185G7.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.027 3 | 200;0.036 4 | 300;0.040 5 | 400;0.057 6 | 500;0.067 7 | 600;0.087 8 | 700;0.108 9 | 800;0.141 10 | 900;0.193 11 | 1000;0.203 12 | 1100;0.239 13 | 1200;0.278 14 | 1300;0.331 15 | 1400;0.453 16 | 1500;0.507 17 | 1600;0.619 18 | 1700;0.595 19 | 1800;0.658 20 | 1900;0.741 21 | 2000;0.969 22 | 2100;0.890 23 | 2200;0.960 24 | 2300;1.203 25 | 2400;1.202 26 | 2500;1.395 27 | 2600;1.425 28 | 2700;1.500 29 | 2800;1.638 30 | 2900;1.812 31 | 3000;2.320 32 | 3100;2.264 33 | 3200;2.407 34 | 3300;2.610 35 | 3400;2.569 36 | 3500;2.840 37 | 3600;7.392 38 | 3700;3.196 39 | 3800;3.122 40 | 3900;3.222 41 | 4000;3.286 42 | 4100;3.888 43 | 4200;3.700 44 | 4300;4.172 45 | 4400;4.640 46 | 4500;4.364 47 | 4600;4.595 48 | 4700;4.883 49 | 4800;5.027 50 | 4900;5.074 51 | 5000;5.732 52 | 5100;6.083 53 | 5200;6.143 54 | 5300;6.095 55 | 5400;6.876 56 | 5500;7.809 57 | 5600;8.335 58 | 5700;8.196 59 | 5800;8.623 60 | 5900;7.592 61 | 6000;8.238 62 | 6100;8.731 63 | 6200;9.269 64 | 6300;9.432 65 | 6400;8.950 66 | 6500;9.265 67 | 6600;10.063 68 | 6700;9.879 69 | 6800;10.790 70 | 6900;11.000 71 | 7000;11.619 72 | 7100;13.001 73 | 7200;12.329 74 | 7300;13.337 75 | 7400;12.922 76 | 7500;13.116 77 | 7600;14.031 78 | 7700;15.933 79 | 7800;16.502 80 | 7900;14.640 81 | 8000;15.494 82 | 8100;17.028 83 | 8200;17.063 84 | 8300;17.974 85 | 8400;16.392 86 | 8500;15.830 87 | 8600;20.074 88 | 8700;17.899 89 | 8800;21.031 90 | 8900;18.321 91 | 9000;19.163 92 | 9100;22.303 93 | 9200;23.259 94 | 9300;19.880 95 | 9400;20.923 96 | 9500;23.056 97 | 9600;24.568 98 | 9700;21.870 99 | 9800;25.942 100 | 9900;22.853 101 | 10000;24.140 102 | 10100;23.437 103 | 10200;24.659 104 | 10300;28.679 105 | 10400;26.255 106 | 10500;28.489 107 | 10600;26.541 108 | 10700;29.009 109 | 10800;27.712 110 | 10900;27.009 111 | 11000;28.613 112 | 11100;29.625 113 | 11200;29.684 114 | 11300;31.190 115 | 11400;33.142 116 | 11500;32.256 117 | 11600;31.187 118 | 11700;37.682 119 | 11800;33.015 120 | 11900;33.671 121 | 12000;35.646 122 | 12100;34.711 123 | 12200;36.130 124 | 12300;37.208 125 | 12400;37.813 126 | 12500;38.266 127 | 12600;38.502 128 | 12700;38.142 129 | 12800;48.836 130 | 12900;40.320 131 | 13000;40.641 132 | 13100;62.814 133 | 13200;82.351 134 | 13300;43.476 135 | 13400;50.641 136 | 13500;45.738 137 | 13600;43.998 138 | 13700;45.173 139 | 13800;45.425 140 | 13900;46.164 141 | 14000;46.247 142 | 14100;98.714 143 | 14200;56.871 144 | 14300;48.988 145 | 14400;49.791 146 | 14500;50.678 147 | 14600;50.846 148 | 14700;59.969 149 | 14800;56.285 150 | 14900;106.054 151 | 15000;53.928 152 | -------------------------------------------------------------------------------- /doc/latex/data/time-vbr-copypaste-cmp-80x100-ARMv7l.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.206 3 | 200;0.238 4 | 300;0.291 5 | 400;0.400 6 | 500;0.456 7 | 600;0.570 8 | 700;0.703 9 | 800;0.865 10 | 900;1.050 11 | 1000;1.256 12 | 1100;1.463 13 | 1200;1.695 14 | 1300;2.007 15 | 1400;2.346 16 | 1500;2.649 17 | 1600;3.051 18 | 1700;3.465 19 | 1800;3.901 20 | 1900;4.492 21 | 2000;4.880 22 | 2100;5.258 23 | 2200;5.843 24 | 2300;6.381 25 | 2400;6.940 26 | 2500;7.831 27 | 2600;8.281 28 | 2700;9.028 29 | 2800;10.092 30 | 2900;10.691 31 | 3000;11.462 32 | 3100;12.624 33 | 3200;13.873 34 | 3300;14.033 35 | 3400;15.301 36 | 3500;15.960 37 | 3600;17.550 38 | 3700;18.352 39 | 3800;18.738 40 | 3900;19.923 41 | 4000;20.756 42 | 4100;22.406 43 | 4200;23.175 44 | 4300;24.611 45 | 4400;26.037 46 | 4500;27.149 47 | 4600;27.917 48 | 4700;29.253 49 | 4800;31.125 50 | 4900;32.532 51 | 5000;34.033 52 | 5100;35.069 53 | 5200;37.210 54 | 5300;38.634 55 | 5400;39.911 56 | 5500;42.418 57 | 5600;44.155 58 | 5700;44.876 59 | 5800;46.756 60 | 5900;50.308 61 | 6000;51.294 62 | 6100;53.141 63 | 6200;54.791 64 | 6300;56.923 65 | 6400;59.448 66 | 6500;60.751 67 | 6600;62.252 68 | 6700;63.927 69 | 6800;67.992 70 | 6900;69.641 71 | 7000;70.561 72 | 7100;73.290 73 | 7200;76.236 74 | 7300;76.923 75 | 7400;79.679 76 | 7500;82.104 77 | 7600;82.529 78 | 7700;86.811 79 | 7800;87.932 80 | 7900;90.316 81 | 8000;90.657 82 | -------------------------------------------------------------------------------- /doc/latex/data/time-vbr-copypaste-op-cmp-100x100-Ryzen7-4800HS.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.066 3 | 200;0.071 4 | 300;0.098 5 | 400;0.119 6 | 500;0.123 7 | 600;0.175 8 | 700;0.220 9 | 800;0.271 10 | 900;0.320 11 | 1000;0.422 12 | 1100;0.490 13 | 1200;0.554 14 | 1300;0.632 15 | 1400;0.839 16 | 1500;0.881 17 | 1600;0.976 18 | 1700;1.157 19 | 1800;1.214 20 | 1900;1.467 21 | 2000;1.942 22 | 2100;1.786 23 | 2200;2.496 24 | 2300;2.305 25 | 2400;2.549 26 | 2500;2.705 27 | 2600;3.018 28 | 2700;3.482 29 | 2800;3.532 30 | 2900;4.144 31 | 3000;4.588 32 | 3100;4.857 33 | 3200;5.907 34 | 3300;5.771 35 | 3400;6.064 36 | 3500;6.129 37 | 3600;7.180 38 | 3700;6.931 39 | 3800;7.569 40 | 3900;8.974 41 | 4000;9.461 42 | 4100;8.793 43 | 4200;9.521 44 | 4300;10.125 45 | 4400;12.032 46 | 4500;10.924 47 | 4600;11.937 48 | 4700;13.312 49 | 4800;13.152 50 | 4900;13.902 51 | 5000;16.204 52 | 5100;15.172 53 | 5200;15.954 54 | 5300;16.425 55 | 5400;19.149 56 | 5500;17.589 57 | 5600;19.389 58 | 5700;20.813 59 | 5800;20.312 60 | 5900;24.124 61 | 6000;22.022 62 | 6100;22.975 63 | 6200;25.475 64 | 6300;25.115 65 | 6400;25.246 66 | 6500;27.166 67 | 6600;27.523 68 | 6700;29.120 69 | 6800;29.680 70 | 6900;31.365 71 | 7000;35.185 72 | 7100;31.873 73 | 7200;33.241 74 | 7300;35.093 75 | 7400;37.576 76 | 7500;35.892 77 | 7600;41.186 78 | 7700;38.144 79 | 7800;41.223 80 | 7900;41.290 81 | 8000;41.931 82 | 8100;45.732 83 | 8200;44.028 84 | 8300;44.529 85 | 8400;46.005 86 | 8500;47.027 87 | 8600;48.549 88 | 8700;49.505 89 | 8800;50.503 90 | 8900;52.027 91 | 9000;53.516 92 | 9100;54.352 93 | 9200;56.327 94 | 9300;57.483 95 | 9400;62.276 96 | 9500;59.620 97 | 9600;67.658 98 | 9700;68.586 99 | 9800;64.436 100 | 9900;71.228 101 | 10000;73.846 102 | -------------------------------------------------------------------------------- /doc/latex/data/time-vbr-copypaste-op-tmp-100x100-Ryzen7-4800HS.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.064 3 | 200;0.046 4 | 300;0.079 5 | 400;0.102 6 | 500;0.126 7 | 600;0.176 8 | 700;0.162 9 | 800;0.229 10 | 900;0.238 11 | 1000;0.309 12 | 1100;0.361 13 | 1200;0.345 14 | 1300;0.434 15 | 1400;0.571 16 | 1500;0.688 17 | 1600;0.676 18 | 1700;0.871 19 | 1800;0.969 20 | 1900;1.130 21 | 2000;1.226 22 | 2100;1.474 23 | 2200;1.575 24 | 2300;1.696 25 | 2400;2.263 26 | 2500;2.264 27 | 2600;2.375 28 | 2700;2.607 29 | 2800;2.853 30 | 2900;3.065 31 | 3000;3.361 32 | 3100;3.818 33 | 3200;3.855 34 | 3300;4.131 35 | 3400;4.633 36 | 3500;4.781 37 | 3600;5.119 38 | 3700;5.551 39 | 3800;6.813 40 | 3900;6.207 41 | 4000;6.580 42 | 4100;7.026 43 | 4200;7.391 44 | 4300;7.649 45 | 4400;8.259 46 | 4500;8.605 47 | 4600;9.290 48 | 4700;9.519 49 | 4800;10.095 50 | 4900;10.843 51 | 5000;10.983 52 | 5100;11.679 53 | 5200;12.342 54 | 5300;12.649 55 | 5400;13.495 56 | 5500;13.994 57 | 5600;14.389 58 | 5700;14.837 59 | 5800;15.644 60 | 5900;16.202 61 | 6000;16.952 62 | 6100;18.463 63 | 6200;17.792 64 | 6300;19.029 65 | 6400;19.554 66 | 6500;21.827 67 | 6600;20.981 68 | 6700;21.379 69 | 6800;22.274 70 | 6900;24.445 71 | 7000;24.277 72 | 7100;24.719 73 | 7200;25.597 74 | 7300;28.116 75 | 7400;27.130 76 | 7500;27.345 77 | 7600;28.791 78 | 7700;29.701 79 | 7800;30.045 80 | 7900;31.350 81 | 8000;32.047 82 | 8100;33.080 83 | 8200;34.133 84 | 8300;34.353 85 | 8400;36.148 86 | 8500;37.283 87 | 8600;38.281 88 | 8700;39.724 89 | 8800;39.582 90 | 8900;40.246 91 | 9000;44.383 92 | 9100;42.475 93 | 9200;44.216 94 | 9300;44.788 95 | 9400;46.106 96 | 9500;47.890 97 | 9600;47.363 98 | 9700;48.830 99 | 9800;50.362 100 | 9900;53.487 101 | 10000;53.499 102 | -------------------------------------------------------------------------------- /doc/latex/data/time-vbr-copypaste-tmp-100x100-Ryzen7-4800HS.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.053 3 | 200;0.059 4 | 300;0.106 5 | 400;0.092 6 | 500;0.106 7 | 600;0.123 8 | 700;0.145 9 | 800;0.177 10 | 900;0.221 11 | 1000;0.285 12 | 1100;0.287 13 | 1200;0.357 14 | 1300;0.344 15 | 1400;0.389 16 | 1500;0.443 17 | 1600;0.572 18 | 1700;0.625 19 | 1800;0.733 20 | 1900;0.795 21 | 2000;0.932 22 | 2100;1.107 23 | 2200;1.181 24 | 2300;1.284 25 | 2400;1.481 26 | 2500;1.584 27 | 2600;1.643 28 | 2700;1.856 29 | 2800;1.975 30 | 2900;2.286 31 | 3000;2.434 32 | 3100;2.504 33 | 3200;2.729 34 | 3300;2.892 35 | 3400;3.184 36 | 3500;3.360 37 | 3600;3.749 38 | 3700;3.969 39 | 3800;4.210 40 | 3900;4.589 41 | 4000;4.783 42 | 4100;5.812 43 | 4200;5.471 44 | 4300;6.104 45 | 4400;6.027 46 | 4500;6.367 47 | 4600;6.415 48 | 4700;7.054 49 | 4800;7.924 50 | 4900;7.420 51 | 5000;8.003 52 | 5100;8.915 53 | 5200;9.166 54 | 5300;9.412 55 | 5400;10.108 56 | 5500;9.688 57 | 5600;11.219 58 | 5700;11.118 59 | 5800;11.604 60 | 5900;12.712 61 | 6000;12.380 62 | 6100;12.878 63 | 6200;13.566 64 | 6300;13.528 65 | 6400;14.615 66 | 6500;15.216 67 | 6600;15.608 68 | 6700;16.348 69 | 6800;16.824 70 | 6900;16.864 71 | 7000;18.315 72 | 7100;18.682 73 | 7200;18.997 74 | 7300;20.435 75 | 7400;20.994 76 | 7500;20.727 77 | 7600;21.967 78 | 7700;21.848 79 | 7800;22.895 80 | 7900;24.172 81 | 8000;24.201 82 | 8100;25.011 83 | 8200;24.982 84 | 8300;26.488 85 | 8400;26.837 86 | 8500;29.127 87 | 8600;27.853 88 | 8700;30.117 89 | 8800;28.819 90 | 8900;33.057 91 | 9000;30.856 92 | 9100;33.615 93 | 9200;33.906 94 | 9300;33.427 95 | 9400;34.603 96 | 9500;35.024 97 | 9600;35.336 98 | 9700;38.148 99 | 9800;37.606 100 | 9900;38.093 101 | 10000;41.730 102 | -------------------------------------------------------------------------------- /doc/latex/data/time-vbr-copypaste-tmp-125x100-i5-2400.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.049 3 | 200;0.060 4 | 300;0.080 5 | 400;0.097 6 | 500;0.136 7 | 600;0.169 8 | 700;0.208 9 | 800;0.254 10 | 900;0.306 11 | 1000;0.361 12 | 1100;0.425 13 | 1200;0.487 14 | 1300;0.571 15 | 1400;0.633 16 | 1500;0.725 17 | 1600;0.838 18 | 1700;0.940 19 | 1800;1.063 20 | 1900;1.190 21 | 2000;1.330 22 | 2100;1.439 23 | 2200;1.610 24 | 2300;1.771 25 | 2400;1.936 26 | 2500;2.108 27 | 2600;2.299 28 | 2700;2.485 29 | 2800;2.678 30 | 2900;2.930 31 | 3000;3.171 32 | 3100;3.442 33 | 3200;3.975 34 | 3300;4.107 35 | 3400;4.446 36 | 3500;4.673 37 | 3600;5.205 38 | 3700;5.564 39 | 3800;5.914 40 | 3900;6.259 41 | 4000;6.508 42 | 4100;6.877 43 | 4200;7.303 44 | 4300;7.795 45 | 4400;8.252 46 | 4500;8.620 47 | 4600;9.216 48 | 4700;9.598 49 | 4800;10.059 50 | 4900;10.812 51 | 5000;11.265 52 | 5100;11.648 53 | 5200;12.351 54 | 5300;12.913 55 | 5400;13.883 56 | 5500;13.932 57 | 5600;14.529 58 | 5700;15.112 59 | 5800;16.020 60 | 5900;16.540 61 | 6000;17.222 62 | 6100;17.820 63 | 6200;18.890 64 | 6300;19.306 65 | 6400;20.105 66 | 6500;21.006 67 | 6600;21.425 68 | 6700;22.424 69 | 6800;23.668 70 | 6900;24.227 71 | 7000;25.096 72 | 7100;25.709 73 | 7200;26.878 74 | 7300;27.752 75 | 7400;28.607 76 | 7500;29.727 77 | 7600;30.432 78 | 7700;31.713 79 | 7800;32.570 80 | 7900;33.347 81 | 8000;34.354 82 | 8100;35.381 83 | 8200;36.441 84 | 8300;36.213 85 | 8400;38.771 86 | 8500;40.073 87 | 8600;40.273 88 | 8700;41.920 89 | 8800;42.993 90 | 8900;43.864 91 | 9000;44.982 92 | 9100;46.811 93 | 9200;47.555 94 | 9300;48.533 95 | 9400;49.403 96 | 9500;51.201 97 | 9600;52.102 98 | 9700;53.423 99 | 9800;54.845 100 | 9900;55.819 101 | 10000;57.225 102 | 10100;58.457 103 | 10200;59.812 104 | 10300;61.450 105 | 10400;61.213 106 | 10500;63.932 107 | 10600;65.540 108 | 10700;66.965 109 | 10800;67.999 110 | 10900;69.393 111 | 11000;71.070 112 | 11100;72.346 113 | 11200;72.494 114 | 11300;75.166 115 | 11400;77.224 116 | 11500;77.095 117 | 11600;79.431 118 | 11700;81.228 119 | 11800;82.981 120 | 11900;84.310 121 | 12000;86.612 122 | 12100;87.284 123 | 12200;89.496 124 | 12300;90.662 125 | 12400;92.146 126 | 12500;93.775 127 | -------------------------------------------------------------------------------- /doc/latex/data/time-vbr-copypaste-tmp-80x100-ARMv7l.csv: -------------------------------------------------------------------------------- 1 | instantiations;compile-time [s] 2 | 100;0.211 3 | 200;0.244 4 | 300;0.293 5 | 400;0.387 6 | 500;0.472 7 | 600;0.582 8 | 700;0.725 9 | 800;0.905 10 | 900;1.116 11 | 1000;1.331 12 | 1100;1.574 13 | 1200;1.841 14 | 1300;2.180 15 | 1400;2.508 16 | 1500;2.891 17 | 1600;3.310 18 | 1700;3.854 19 | 1800;4.247 20 | 1900;4.755 21 | 2000;5.215 22 | 2100;5.749 23 | 2200;6.301 24 | 2300;6.912 25 | 2400;7.459 26 | 2500;8.253 27 | 2600;8.964 28 | 2700;9.986 29 | 2800;10.610 30 | 2900;11.356 31 | 3000;12.149 32 | 3100;13.070 33 | 3200;13.886 34 | 3300;15.321 35 | 3400;15.980 36 | 3500;17.314 37 | 3600;18.063 38 | 3700;19.226 39 | 3800;20.154 40 | 3900;21.270 41 | 4000;22.497 42 | 4100;23.920 43 | 4200;24.624 44 | 4300;26.110 45 | 4400;28.500 46 | 4500;29.283 47 | 4600;30.305 48 | 4700;31.302 49 | 4800;33.640 50 | 4900;34.726 51 | 5000;36.172 52 | 5100;37.359 53 | 5200;40.055 54 | 5300;41.560 55 | 5400;42.509 56 | 5500;44.235 57 | 5600;46.218 58 | 5700;47.681 59 | 5800;50.622 60 | 5900;52.000 61 | 6000;54.313 62 | 6100;55.860 63 | 6200;57.319 64 | 6300;59.571 65 | 6400;62.805 66 | 6500;63.301 67 | 6600;66.468 68 | 6700;67.988 69 | 6800;70.127 70 | 6900;72.230 71 | 7000;74.930 72 | 7100;75.550 73 | 7200;77.790 74 | 7300;82.448 75 | 7400;83.128 76 | 7500;86.711 77 | 7600;89.943 78 | 7700;91.274 79 | 7800;94.156 80 | 7900;94.934 81 | 8000;97.353 82 | -------------------------------------------------------------------------------- /doc/latex/deserialize_class.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matus-chochlik/mirror/a04ae0fd2c06d953f895f3396583b3d644e5c5e7/doc/latex/deserialize_class.pdf -------------------------------------------------------------------------------- /doc/latex/deserialize_class.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | interface read_backend { 4 | +enum_as_string() 5 | +begin() 6 | +read() 7 | +begin_list() 8 | +finish_list() 9 | +begin_element() 10 | +finish_element() 11 | +begin_record() 12 | +finish_record() 13 | +begin_attribute() 14 | +finish_attribute() 15 | +finish() 16 | } 17 | 18 | class json_read_backend { 19 | -json_document: _doc 20 | --- 21 | +read() 22 | } 23 | 24 | class deserializer { 25 | +read(...) 26 | } 27 | 28 | class read_driver { 29 | +read(...) 30 | } 31 | 32 | json_read_backend ..|> read_backend : implements 33 | deserializer <.. read_driver : creates 34 | deserializer --> read_driver : uses 35 | deserializer --> read_backend : uses 36 | read_driver --> read_backend : uses 37 | 38 | @enduml 39 | -------------------------------------------------------------------------------- /doc/latex/extras.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matus-chochlik/mirror/a04ae0fd2c06d953f895f3396583b3d644e5c5e7/doc/latex/extras.png -------------------------------------------------------------------------------- /doc/latex/look_into_mirror.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matus-chochlik/mirror/a04ae0fd2c06d953f895f3396583b3d644e5c5e7/doc/latex/look_into_mirror.png -------------------------------------------------------------------------------- /doc/latex/rpc_class.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matus-chochlik/mirror/a04ae0fd2c06d953f895f3396583b3d644e5c5e7/doc/latex/rpc_class.pdf -------------------------------------------------------------------------------- /doc/latex/rpc_class.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | class connection #C0C0C0 { 4 | +void send() 5 | +void on_received() 6 | } 7 | 8 | interface interface { 9 | +void foo() 10 | +void bar() 11 | +void baz() 12 | } 13 | 14 | class implementation #C0C0C0 { 15 | +void foo() 16 | +void bar() 17 | +void baz() 18 | } 19 | 20 | class stub { 21 | +void foo() 22 | +void bar() 23 | +void baz() 24 | } 25 | 26 | class stub_impl { 27 | +void make_call() 28 | } 29 | 30 | 31 | class skeleton { 32 | +void dispatch() 33 | } 34 | 35 | interface <|-- implementation 36 | interface <|-- stub 37 | stub_impl --* stub 38 | stub_impl --> connection 39 | skeleton <-- connection 40 | skeleton o-- interface 41 | 42 | @enduml 43 | -------------------------------------------------------------------------------- /doc/latex/rpc_sequence.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matus-chochlik/mirror/a04ae0fd2c06d953f895f3396583b3d644e5c5e7/doc/latex/rpc_sequence.pdf -------------------------------------------------------------------------------- /doc/latex/rpc_sequence.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | actor User as user 4 | participant stub 5 | participant stub_impl 6 | participant connection as local_connection #C0C0C0 7 | participant connection as remote_connection #C0C0C0 8 | participant skeleton 9 | participant implementation #C0C0C0 10 | 11 | user -> stub : calls 12 | stub -> stub_impl : serialize 13 | stub_impl -> local_connection : send request 14 | local_connection -> remote_connection : transmit 15 | remote_connection -> skeleton : notify 16 | skeleton -> implementation : dispatch/invoke 17 | implementation -> skeleton : return result 18 | skeleton -> remote_connection : send response 19 | remote_connection -> local_connection : transmit 20 | local_connection -> stub_impl : receive response 21 | stub_impl -> stub : deserialize 22 | stub -> user : return result 23 | 24 | @enduml 25 | -------------------------------------------------------------------------------- /doc/latex/serialize_class.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matus-chochlik/mirror/a04ae0fd2c06d953f895f3396583b3d644e5c5e7/doc/latex/serialize_class.pdf -------------------------------------------------------------------------------- /doc/latex/serialize_class.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | interface write_backend { 4 | +enum_as_string() 5 | +begin() 6 | +write() 7 | +begin_list() 8 | +finish_list() 9 | +begin_element() 10 | +finish_element() 11 | +begin_record() 12 | +finish_record() 13 | +begin_attribute() 14 | +finish_attribute() 15 | +finish() 16 | } 17 | 18 | class json_write_backend { 19 | -json_document: _doc 20 | --- 21 | +write() 22 | } 23 | 24 | class serializer { 25 | +write(...) 26 | } 27 | 28 | class write_driver { 29 | +write(...) 30 | } 31 | 32 | json_write_backend ..|> write_backend : implements 33 | serializer <.. write_driver : creates 34 | serializer --> write_driver : uses 35 | serializer --> write_backend : uses 36 | write_driver --> write_backend : uses 37 | 38 | @enduml 39 | -------------------------------------------------------------------------------- /doc/latex/tools/ct-baseline-sequence: -------------------------------------------------------------------------------- 1 | measure_ct -------------------------------------------------------------------------------- /doc/latex/tools/mksrc-baseline-sequence: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Matus Chochlik. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt 6 | # 7 | N=${1} 8 | S=${2} 9 | K=$((N/S)) 10 | if [[ ${S} -ge 10 ]] 11 | then F=$((S/10)) 12 | else F=1 13 | fi 14 | if [[ ${K} -ge 10 ]] 15 | then E=$((K/10)) 16 | else E=1 17 | fi 18 | D=$((N / (F * E))) 19 | cat << EOD 20 | // ${N} = ${D} * ${E} * ${F} 21 | #include 22 | 23 | template 24 | consteval auto bar( 25 | std::integral_constant, 26 | std::integral_constant, 27 | std::index_sequence) { 28 | return ( ... + (K * $((N / D)) + J * $((N / (D * E))) + I)); 29 | } 30 | 31 | template 32 | consteval auto baz( 33 | std::integral_constant, 34 | std::index_sequence) { 35 | return ( ... + bar( 36 | std::integral_constant{}, 37 | std::integral_constant{}, 38 | std::make_index_sequence<${F}>{})); 39 | } 40 | 41 | template 42 | consteval auto qux(std::index_sequence) { 43 | return ( ... + baz( 44 | std::integral_constant{}, 45 | std::make_index_sequence<${E}>{})); 46 | } 47 | 48 | int main() { 49 | return bool(qux(std::make_index_sequence<${D}>{})) ? 0 : 1; 50 | } 51 | EOD 52 | -------------------------------------------------------------------------------- /doc/latex/tools/mksrc-tbr-copypaste-cmp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Matus Chochlik. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt 6 | # 7 | N=${1} 8 | cat << EOD 9 | template 10 | struct wrapper { consteval operator unsigned long() const { return I;} }; 11 | 12 | consteval auto foo(unsigned long i) { 13 | return i; 14 | } 15 | 16 | consteval int bar() { 17 | return static_cast( 18 | EOD 19 | # 20 | for I in $(seq 1 $((N-1))) 21 | do echo " foo(wrapper<$((I))UL>{})+" 22 | done 23 | # 24 | cat << EOD 25 | foo(wrapper<$((N))UL>{})); 26 | } 27 | int main() { 28 | return bar(); 29 | } 30 | EOD 31 | -------------------------------------------------------------------------------- /doc/latex/tools/mksrc-tbr-copypaste-op-cmp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Matus Chochlik. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt 6 | # 7 | N=${1} 8 | cat << EOD 9 | template 10 | struct wrapper { consteval operator unsigned long() const { return I;} }; 11 | 12 | template 13 | consteval wrapper reflect() { return {}; } 14 | 15 | consteval auto foo(unsigned long i) { 16 | return i; 17 | } 18 | 19 | consteval int bar() { 20 | return static_cast( 21 | EOD 22 | # 23 | for I in $(seq 1 $((N-1))) 24 | do echo " foo(reflect<$((I))UL>())+" 25 | done 26 | # 27 | cat << EOD 28 | foo(reflect<$((N))UL>())); 29 | } 30 | int main() { 31 | return bar(); 32 | } 33 | EOD 34 | -------------------------------------------------------------------------------- /doc/latex/tools/mksrc-tbr-copypaste-op-tmp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Matus Chochlik. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt 6 | # 7 | N=${1} 8 | cat << EOD 9 | template 10 | struct wrapper { consteval operator unsigned long() const { return I;} }; 11 | 12 | template 13 | consteval wrapper reflect() { return {}; } 14 | 15 | template 16 | consteval auto foo(wrapper w) { 17 | return w; 18 | } 19 | 20 | consteval int bar() { 21 | return static_cast( 22 | EOD 23 | # 24 | for I in $(seq 1 $((N-1))) 25 | do echo " foo(reflect<$((I))UL>())+" 26 | done 27 | # 28 | cat << EOD 29 | foo(reflect<$((N))UL>())); 30 | } 31 | int main() { 32 | return bar(); 33 | } 34 | EOD 35 | -------------------------------------------------------------------------------- /doc/latex/tools/mksrc-tbr-copypaste-tmp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Matus Chochlik. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt 6 | # 7 | N=${1} 8 | cat << EOD 9 | template 10 | struct wrapper { consteval operator unsigned long() const { return I;} }; 11 | 12 | template 13 | consteval auto foo(wrapper w) { 14 | return w; 15 | } 16 | 17 | consteval int bar() { 18 | return static_cast( 19 | EOD 20 | # 21 | for I in $(seq 1 $((N-1))) 22 | do echo " foo(wrapper<$((I))UL>{})+" 23 | done 24 | # 25 | cat << EOD 26 | foo(wrapper<$((N))UL>{})); 27 | } 28 | int main() { 29 | return bar(); 30 | } 31 | EOD 32 | -------------------------------------------------------------------------------- /doc/latex/tools/mksrc-tbr-sequence-cmp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Matus Chochlik. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt 6 | # 7 | N=${1} 8 | S=${2} 9 | K=$((N/S)) 10 | if [[ ${S} -ge 10 ]] 11 | then F=$((S/10)) 12 | else F=1 13 | fi 14 | if [[ ${K} -ge 10 ]] 15 | then E=$((K/10)) 16 | else E=1 17 | fi 18 | D=$((N / (F * E))) 19 | cat << EOD 20 | // ${N} = ${D} * ${E} * ${F} 21 | #include 22 | 23 | template 24 | struct wrapper { 25 | consteval operator std::size_t() const { 26 | return I; 27 | } 28 | }; 29 | 30 | consteval std::size_t foo(std::size_t w) { 31 | return w; 32 | } 33 | 34 | template 35 | consteval auto bar( 36 | std::integral_constant, 37 | std::integral_constant, 38 | std::index_sequence) { 39 | return ( ... + foo(wrapper{})); 40 | } 41 | 42 | template 43 | consteval auto baz( 44 | std::integral_constant, 45 | std::index_sequence) { 46 | return ( ... + bar( 47 | std::integral_constant{}, 48 | std::integral_constant{}, 49 | std::make_index_sequence<${F}>{})); 50 | } 51 | 52 | template 53 | consteval auto qux(std::index_sequence) { 54 | return ( ... + baz( 55 | std::integral_constant{}, 56 | std::make_index_sequence<${E}>{})); 57 | } 58 | 59 | int main() { 60 | return bool(qux(std::make_index_sequence<${D}>{})) ? 0 : 1; 61 | } 62 | EOD 63 | -------------------------------------------------------------------------------- /doc/latex/tools/mksrc-tbr-sequence-tmp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Matus Chochlik. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt 6 | # 7 | N=${1} 8 | S=${2} 9 | K=$((N/S)) 10 | if [[ ${S} -ge 10 ]] 11 | then F=$((S/10)) 12 | else F=1 13 | fi 14 | if [[ ${K} -ge 10 ]] 15 | then E=$((K/10)) 16 | else E=1 17 | fi 18 | D=$((N / (F * E))) 19 | cat << EOD 20 | // ${N} = ${D} * ${E} * ${F} 21 | #include 22 | 23 | template 24 | struct wrapper { 25 | consteval operator std::size_t() const { 26 | return I; 27 | } 28 | }; 29 | 30 | template 31 | consteval std::size_t foo(wrapper w) { 32 | return w; 33 | } 34 | 35 | template 36 | consteval auto bar( 37 | std::integral_constant, 38 | std::integral_constant, 39 | std::index_sequence) { 40 | return ( ... + foo(wrapper{})); 41 | } 42 | 43 | template 44 | consteval auto baz( 45 | std::integral_constant, 46 | std::index_sequence) { 47 | return ( ... + bar( 48 | std::integral_constant{}, 49 | std::integral_constant{}, 50 | std::make_index_sequence<${F}>{})); 51 | } 52 | 53 | template 54 | consteval auto qux(std::index_sequence) { 55 | return ( ... + baz( 56 | std::integral_constant{}, 57 | std::make_index_sequence<${E}>{})); 58 | } 59 | 60 | int main() { 61 | return bool(qux(std::make_index_sequence<${D}>{})) ? 0 : 1; 62 | } 63 | EOD 64 | -------------------------------------------------------------------------------- /doc/latex/tools/mksrc-vbr-copypaste-cmp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Matus Chochlik. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt 6 | # 7 | N=${1} 8 | cat << EOD 9 | consteval auto foo(unsigned long i) { 10 | return i; 11 | } 12 | consteval int bar() { 13 | return static_cast( 14 | EOD 15 | # 16 | for I in $(seq 1 $((N-1))) 17 | do echo " foo($((I))UL)+" 18 | done 19 | # 20 | cat << EOD 21 | foo($((N))UL)); 22 | } 23 | int main() { 24 | return bar(); 25 | } 26 | EOD 27 | -------------------------------------------------------------------------------- /doc/latex/tools/mksrc-vbr-copypaste-op-cmp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Matus Chochlik. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt 6 | # 7 | N=${1} 8 | cat << EOD 9 | template 10 | consteval auto reflect() { 11 | return I; 12 | } 13 | 14 | consteval auto foo(unsigned long i) { 15 | return i; 16 | } 17 | consteval int bar() { 18 | return static_cast( 19 | EOD 20 | # 21 | for I in $(seq 1 $((N-1))) 22 | do echo " foo(reflect<$((I))UL>())+" 23 | done 24 | # 25 | cat << EOD 26 | foo(reflect<$((N))UL>())); 27 | } 28 | int main() { 29 | return bar(); 30 | } 31 | EOD 32 | -------------------------------------------------------------------------------- /doc/latex/tools/mksrc-vbr-copypaste-op-tmp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Matus Chochlik. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt 6 | # 7 | N=${1} 8 | cat << EOD 9 | template 10 | consteval auto reflect() { 11 | return I; 12 | } 13 | 14 | template 15 | consteval auto foo() { 16 | return I; 17 | } 18 | consteval int bar() { 19 | return static_cast( 20 | EOD 21 | # 22 | for I in $(seq 1 $((N-1))) 23 | do echo " foo()>()+" 24 | done 25 | # 26 | cat << EOD 27 | foo()>()); 28 | } 29 | int main() { 30 | return bar(); 31 | } 32 | EOD 33 | -------------------------------------------------------------------------------- /doc/latex/tools/mksrc-vbr-copypaste-tmp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Matus Chochlik. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt 6 | # 7 | N=${1} 8 | cat << EOD 9 | template 10 | consteval auto foo() { 11 | return I; 12 | } 13 | consteval int bar() { 14 | return static_cast( 15 | EOD 16 | # 17 | for I in $(seq 1 $((N-1))) 18 | do echo " foo<$((I))UL>()+" 19 | done 20 | # 21 | cat << EOD 22 | foo<$((N))UL>()); 23 | } 24 | int main() { 25 | return bar(); 26 | } 27 | EOD 28 | -------------------------------------------------------------------------------- /doc/latex/tools/mksrc-vbr-sequence-cmp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Matus Chochlik. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt 6 | # 7 | N=${1} 8 | S=${2} 9 | K=$((N/S)) 10 | if [[ ${S} -ge 10 ]] 11 | then F=$((S/10)) 12 | else F=1 13 | fi 14 | if [[ ${K} -ge 10 ]] 15 | then E=$((K/10)) 16 | else E=1 17 | fi 18 | D=$((N / (F * E))) 19 | cat << EOD 20 | // ${N} = ${D} * ${E} * ${F} 21 | #include 22 | 23 | consteval std::size_t foo(std::size_t i) { 24 | return i; 25 | } 26 | 27 | template 28 | consteval auto bar( 29 | std::integral_constant, 30 | std::integral_constant, 31 | std::index_sequence) { 32 | return ( ... + foo(K * $((N / D)) + J * $((N / (D * E))) + I)); 33 | } 34 | 35 | template 36 | consteval auto baz( 37 | std::integral_constant, 38 | std::index_sequence) { 39 | return ( ... + bar( 40 | std::integral_constant{}, 41 | std::integral_constant{}, 42 | std::make_index_sequence<${F}>{})); 43 | } 44 | 45 | template 46 | consteval auto qux(std::index_sequence) { 47 | return ( ... + baz( 48 | std::integral_constant{}, 49 | std::make_index_sequence<${E}>{})); 50 | } 51 | 52 | int main() { 53 | return bool(qux(std::make_index_sequence<${D}>{})) ? 0 : 1; 54 | } 55 | EOD 56 | -------------------------------------------------------------------------------- /doc/latex/tools/mksrc-vbr-sequence-tmp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Matus Chochlik. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt 6 | # 7 | N=${1} 8 | S=${2} 9 | K=$((N/S)) 10 | if [[ ${S} -ge 10 ]] 11 | then F=$((S/10)) 12 | else F=1 13 | fi 14 | if [[ ${K} -ge 10 ]] 15 | then E=$((K/10)) 16 | else E=1 17 | fi 18 | D=$((N / (F * E))) 19 | cat << EOD 20 | // ${N} = ${D} * ${E} * ${F} 21 | #include 22 | 23 | template 24 | consteval std::size_t foo() { 25 | return I; 26 | } 27 | 28 | template 29 | consteval auto bar( 30 | std::integral_constant, 31 | std::integral_constant, 32 | std::index_sequence) { 33 | return ( ... + foo()); 34 | } 35 | 36 | template 37 | consteval auto baz( 38 | std::integral_constant, 39 | std::index_sequence) { 40 | return ( ... + bar( 41 | std::integral_constant{}, 42 | std::integral_constant{}, 43 | std::make_index_sequence<${F}>{})); 44 | } 45 | 46 | template 47 | consteval auto qux(std::index_sequence) { 48 | return ( ... + baz( 49 | std::integral_constant{}, 50 | std::make_index_sequence<${E}>{})); 51 | } 52 | 53 | int main() { 54 | return bool(qux(std::make_index_sequence<${D}>{})) ? 0 : 1; 55 | } 56 | EOD 57 | -------------------------------------------------------------------------------- /doc/latex/tools/tbr-copypaste-cmp: -------------------------------------------------------------------------------- 1 | measure_ct -------------------------------------------------------------------------------- /doc/latex/tools/tbr-copypaste-op-cmp: -------------------------------------------------------------------------------- 1 | ./measure_ct -------------------------------------------------------------------------------- /doc/latex/tools/tbr-copypaste-op-tmp: -------------------------------------------------------------------------------- 1 | ./measure_ct -------------------------------------------------------------------------------- /doc/latex/tools/tbr-copypaste-tmp: -------------------------------------------------------------------------------- 1 | measure_ct -------------------------------------------------------------------------------- /doc/latex/tools/tbr-sequence-cmp: -------------------------------------------------------------------------------- 1 | measure_ct -------------------------------------------------------------------------------- /doc/latex/tools/tbr-sequence-tmp: -------------------------------------------------------------------------------- 1 | measure_ct -------------------------------------------------------------------------------- /doc/latex/tools/vbr-copypaste-cmp: -------------------------------------------------------------------------------- 1 | measure_ct -------------------------------------------------------------------------------- /doc/latex/tools/vbr-copypaste-op-cmp: -------------------------------------------------------------------------------- 1 | ./measure_ct -------------------------------------------------------------------------------- /doc/latex/tools/vbr-copypaste-op-tmp: -------------------------------------------------------------------------------- 1 | ./measure_ct -------------------------------------------------------------------------------- /doc/latex/tools/vbr-copypaste-tmp: -------------------------------------------------------------------------------- 1 | measure_ct -------------------------------------------------------------------------------- /doc/latex/tools/vbr-sequence-cmp: -------------------------------------------------------------------------------- 1 | measure_ct -------------------------------------------------------------------------------- /doc/latex/tools/vbr-sequence-tmp: -------------------------------------------------------------------------------- 1 | measure_ct -------------------------------------------------------------------------------- /doc/logo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | 7 | install( 8 | FILES mirror.png 9 | DESTINATION share/mirror/doc 10 | COMPONENT doc-logos 11 | EXCLUDE_FROM_ALL 12 | ) 13 | 14 | add_custom_command( 15 | OUTPUT "${CMAKE_INSTALL_PREFIX}/share/mirror/doc/mirror.png" 16 | COMMAND ${CMAKE_COMMAND} 17 | ARGS -DCOMPONENT=doc-logos -P cmake_install.cmake 18 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" 19 | MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/mirror.png" 20 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/mirror.png" 21 | ) 22 | 23 | add_custom_target( 24 | install-doc-logos 25 | DEPENDS "${CMAKE_INSTALL_PREFIX}/share/mirror/doc/mirror.png" 26 | ) 27 | 28 | add_dependencies( 29 | install-doc 30 | install-doc-logos 31 | ) 32 | 33 | -------------------------------------------------------------------------------- /doc/logo/mirror.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matus-chochlik/mirror/a04ae0fd2c06d953f895f3396583b3d644e5c5e7/doc/logo/mirror.png -------------------------------------------------------------------------------- /example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | add_subdirectory(reflexpr) 7 | add_subdirectory(mirror) 8 | -------------------------------------------------------------------------------- /example/mirror/Example.cmake: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | add_custom_target(mirror-examples ALL) 7 | set_target_properties( 8 | mirror-examples 9 | PROPERTIES FOLDER "Example/Mirror" 10 | ) 11 | 12 | function(mirror_install_example TARGET_NAME) 13 | install( 14 | TARGETS ${TARGET_NAME} 15 | DESTINATION share/mirror/example/mirror 16 | ) 17 | endfunction() 18 | 19 | function(mirror_add_simple_example EXAMPLE_NAME) 20 | add_executable( 21 | mirror-${EXAMPLE_NAME} 22 | EXCLUDE_FROM_ALL 23 | "${EXAMPLE_NAME}.cpp" 24 | ) 25 | add_dependencies(mirror-examples mirror-${EXAMPLE_NAME}) 26 | target_link_libraries( 27 | mirror-${EXAMPLE_NAME} 28 | PUBLIC Mirror 29 | ) 30 | 31 | set_target_properties( 32 | mirror-${EXAMPLE_NAME} 33 | PROPERTIES 34 | BUILD_RPATH "${MIRROR_LIBCXX_RPATH}" 35 | FOLDER "Example/Mirror" 36 | ) 37 | mirror_install_example(mirror-${EXAMPLE_NAME}) 38 | endfunction() 39 | -------------------------------------------------------------------------------- /example/mirror/amount_of_foo.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/amount_of_foo.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | 12 | struct meh {}; 13 | 14 | struct foo { 15 | foo() noexcept = default; 16 | }; 17 | 18 | struct qux { 19 | void foo() {} 20 | auto foo(int i) { 21 | return i; 22 | } 23 | auto foo(int l, int r) { 24 | return l + r; 25 | } 26 | void bar() {} 27 | void baz() {} 28 | }; 29 | 30 | void compare_by_foo(mirror::metaobject auto l, mirror::metaobject auto r) { 31 | using mirror::_1; 32 | const auto amount_of_foo = get_size(filter( 33 | flatten(make_sequence(get_constructors(_1), get_member_functions(_1))), 34 | ctre_match<"^foo$">(get_name(_1)))); 35 | 36 | const auto name_of = get_name(remove_all_aliases(_1)); 37 | 38 | if(amount_of_foo(l) > amount_of_foo(r)) { 39 | std::cout << name_of(l) << " has more foo than " << name_of(r); 40 | } else if(amount_of_foo(l) < amount_of_foo(r)) { 41 | std::cout << name_of(l) << " has less foo than " << name_of(r); 42 | } else { 43 | std::cout << name_of(l) << " and " << name_of(r) 44 | << " have equal amount of foo"; 45 | } 46 | std::cout << std::endl; 47 | } 48 | 49 | int main() { 50 | 51 | compare_by_foo(mirror(foo), mirror(meh)); 52 | compare_by_foo(mirror(foo), mirror(foo)); 53 | compare_by_foo(mirror(foo), mirror(qux)); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /example/mirror/applicable_ops.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/applicable_ops.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include "testdecl/weekday.hpp" 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | void print_info(mirror::metaobject auto mo) { 15 | 16 | std::cout << "operations applicable to " << get_display_name(mo) 17 | << std::endl; 18 | mirror::for_each_metaobject_operation([&](mirror::metaobject auto me) { 19 | if(is_applicable(mo)) { 20 | std::cout << " " << get_name(me) << std::endl; 21 | } 22 | }); 23 | std::cout << std::endl; 24 | } 25 | 26 | int main(int argc, const char**) { 27 | print_info(mirror(int)); 28 | print_info(mirror(std)); 29 | print_info(mirror(std::string)); 30 | print_info(mirror(argc)); 31 | print_info(mirror(example::weekday)); 32 | print_info(mirror(example::weekday::friday)); 33 | return argc - 1; 34 | } 35 | -------------------------------------------------------------------------------- /example/mirror/are_consecutive.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/are_consecutive.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | 12 | enum class digits { 13 | zero = 0, 14 | one, 15 | two, 16 | three, 17 | four, 18 | five, 19 | six, 20 | seven, 21 | eight, 22 | nine 23 | }; 24 | 25 | enum class po2s { 26 | one = 1, 27 | two = 2, 28 | four = 4, 29 | eight = 8, 30 | sixteen = 16, 31 | thirty_two = 32 32 | }; 33 | 34 | int main() { 35 | const auto are_consecutive = 36 | is_sorted(get_enumerators(mirror::_1), [](auto l, auto r) { 37 | return int(get_constant(l)) + 1 == int(get_constant(r)); 38 | }); 39 | 40 | std::cout << are_consecutive(mirror(digits)) << std::endl; 41 | std::cout << are_consecutive(mirror(po2s)) << std::endl; 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /example/mirror/are_sorted_by_name.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/are_sorted_by_name.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | 12 | struct foo { 13 | int plus(int x) { 14 | return x; 15 | } 16 | int plus(int x, int y) { 17 | return x + y; 18 | } 19 | int plus(int x, int y, int z) { 20 | return x + y + z; 21 | } 22 | int minus(int x) { 23 | return -x; 24 | } 25 | int minus(int x, int y) { 26 | return x - y; 27 | } 28 | }; 29 | 30 | struct bar { 31 | int a() { 32 | return 0; 33 | } 34 | int b() { 35 | return 1; 36 | } 37 | int c() { 38 | return 2; 39 | } 40 | }; 41 | 42 | int main() { 43 | const auto are_sorted_by_name = is_sorted( 44 | get_member_functions(mirror::_1), 45 | get_name(mirror::_1) < get_name(mirror::_2)); 46 | 47 | std::cout << are_sorted_by_name(mirror(foo)) << std::endl; 48 | std::cout << are_sorted_by_name(mirror(bar)) << std::endl; 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /example/mirror/are_sorted_by_size.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/are_sorted_by_size.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | 12 | struct foo { 13 | double d; 14 | int i; 15 | short s; 16 | char c; 17 | }; 18 | 19 | struct bar { 20 | int i; 21 | float f; 22 | long l; 23 | bool b; 24 | }; 25 | 26 | int main() { 27 | const auto are_sorted_by_size = is_sorted( 28 | get_data_members(mirror::_1), 29 | get_sizeof(get_type(mirror::_1)) < get_sizeof(get_type(mirror::_2))); 30 | 31 | std::cout << are_sorted_by_size(mirror(foo)) << std::endl; 32 | std::cout << are_sorted_by_size(mirror(bar)) << std::endl; 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /example/mirror/ctre_integer_concept.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/ctre_integer_concept.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | template 14 | concept very_smart_integer = mirror::ctre_match< 15 | "((signed|unsigned) )?((long long|long|short)( int)?|int)">( 16 | get_name(remove_all_aliases(mirror(T)))); 17 | 18 | auto add(very_smart_integer auto l, very_smart_integer auto r) { 19 | return l + r; 20 | } 21 | 22 | int main() { 23 | std::cout << add(1U, 2U) << std::endl; 24 | std::cout << add(short(3), short(4)) << std::endl; 25 | std::cout << add(21, 21) << std::endl; 26 | std::cout << add(400ULL, 20ULL) << std::endl; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /example/mirror/enum_min_max.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/enum_min_max.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include "testdecl/month.hpp" 9 | #include "testdecl/weekday.hpp" 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | int main() { 17 | using mirror::_1; 18 | using mirror::enum_to_string; 19 | 20 | auto min_enum = 21 | get_top_value(get_enumerators(_1), get_constant(_1), std::greater<>{}); 22 | auto max_enum = 23 | get_top_value(get_enumerators(_1), get_constant(_1), std::less<>{}); 24 | 25 | auto print_info = [&](auto me) { 26 | std::cout << get_name(me) << ": min(" << enum_to_string(min_enum(me)) 27 | << "), max(" << enum_to_string(max_enum(me)) << ")" 28 | << std::endl; 29 | }; 30 | 31 | print_info(mirror(example::month)); 32 | print_info(mirror(example::weekday)); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /example/mirror/expression.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/expression.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | //------------------------------------------------------------------------------ 12 | struct foo { 13 | foo(int, int) {} 14 | 15 | friend auto operator<<(std::ostream& out, const foo) -> std::ostream& { 16 | return out << "foo"; 17 | } 18 | }; 19 | //------------------------------------------------------------------------------ 20 | int main() { 21 | const auto msfe = mirror((std::asin(1.F))); 22 | const auto msde = mirror((std::asin(1.0))); 23 | const auto mfce = mirror((foo(1, 1))); 24 | 25 | static_assert(reflects_parenthesized_expression(msfe)); 26 | static_assert(reflects_parenthesized_expression(msde)); 27 | static_assert(reflects_parenthesized_expression(mfce)); 28 | 29 | const auto msf = get_callable(get_subexpression(msfe)); 30 | const auto msd = get_callable(get_subexpression(msde)); 31 | const auto mfc = get_callable(get_subexpression(mfce)); 32 | 33 | static_assert(reflects_function(msf)); 34 | static_assert(reflects_function(msd)); 35 | static_assert(reflects_constructor(mfc)); 36 | 37 | static_assert(!reflect_same(msf, msd)); 38 | 39 | std::cout << invoke(msf, 1.0F) << std::endl; 40 | std::cout << invoke(msd, 0.50) << std::endl; 41 | std::cout << invoke(mfc, 4, 5) << std::endl; 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /example/mirror/factory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | 7 | mirror_add_simple_example(iostream) 8 | mirror_add_simple_example(rapidjson) 9 | -------------------------------------------------------------------------------- /example/mirror/factory/iostream.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/factory/iostream.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | 10 | #include "../testdecl/tetrahedron.hpp" 11 | #include 12 | #include 13 | 14 | auto main() -> int { 15 | using namespace mirror; 16 | 17 | using iostream_factory_builder = factory_builder; 18 | 19 | auto fac = iostream_factory_builder("iof").build(); 20 | auto teh = fac.construct({std::cin, std::cout}); 21 | 22 | std::cout << "volume of the tetrahedron is: " << teh.volume() << std::endl; 23 | std::cout << "area of its base is: " << teh.base().area() << std::endl; 24 | std::cout << "distance of its apex from origin is: " 25 | << teh.apex().direction().length() << std::endl; 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/README.rst: -------------------------------------------------------------------------------- 1 | Qt5-based factory generator example 2 | =================================== 3 | 4 | This example shows how to use a reflection-based factory builder to automatically 5 | generate GUI windows that can select constructors to be used, take 6 | the constructor parameter values and construct instances of almost arbitrary 7 | types. 8 | 9 | Building 10 | -------- 11 | 12 | Make sure the required packages are installed: 13 | 14 | :: 15 | 16 | sudo apt install \ 17 | qt5-default \ 18 | qtdeclarative5-dev \ 19 | qml-module-qtquick-controls \ 20 | qml-module-qtquick-controls2 21 | 22 | Do the following in the current directory: 23 | 24 | :: 25 | 26 | mkdir _build 27 | cd _build 28 | qmake .. 29 | make 30 | 31 | Output 32 | ------ 33 | 34 | .. |QT Factory dark| image:: ../../../../doc/images/qt_factory-dark.png 35 | .. |QT Factory light| image:: ../../../../doc/images/qt_factory-light.png 36 | 37 | The generated GUI windows look like this: 38 | 39 | |QT Factory dark| 40 | |QT Factory light| 41 | 42 | 43 | License 44 | ------- 45 | 46 | The code in this sub-directory is licensed under the GNU GENERAL PUBLIC LICENSE 47 | version 3, available at 48 | [http://www.gnu.org/licenses/gpl-3.0.txt](http://www.gnu.org/licenses/gpl-3.0.txt). 49 | 50 | 51 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/include/AtomicViewModel.hpp: -------------------------------------------------------------------------------- 1 | /// Copyright Matus Chochlik. 2 | /// Distributed under the GNU GENERAL PUBLIC LICENSE version 3. 3 | /// See http://www.gnu.org/licenses/gpl-3.0.txt 4 | /// 5 | #ifndef MIRROR_FACTORY_BUILDER_QT_ATOMIC_VIEW_MODEL_HPP 6 | #define MIRROR_FACTORY_BUILDER_QT_ATOMIC_VIEW_MODEL_HPP 7 | 8 | #include 9 | 10 | class FactoryViewModel; 11 | //------------------------------------------------------------------------------ 12 | class AtomicViewModel : public QObject { 13 | Q_OBJECT 14 | 15 | public: 16 | AtomicViewModel(QString unit); 17 | 18 | auto getUnitName() -> QString; 19 | public slots: 20 | private: 21 | QString _unit; 22 | }; 23 | //------------------------------------------------------------------------------ 24 | class StringBackedViewModel : public AtomicViewModel { 25 | Q_OBJECT 26 | 27 | Q_PROPERTY(QString value READ getValue WRITE setValue NOTIFY valueChanged) 28 | public: 29 | StringBackedViewModel(QString); 30 | 31 | void setValue(QString); 32 | auto getValue() -> const QString&; 33 | 34 | signals: 35 | void valueChanged(); 36 | 37 | private: 38 | QString _value; 39 | }; 40 | //------------------------------------------------------------------------------ 41 | class StringViewModel : public StringBackedViewModel { 42 | public: 43 | StringViewModel(); 44 | 45 | auto get(std::string*) -> std::string; 46 | }; 47 | //------------------------------------------------------------------------------ 48 | class FloatViewModel : public StringBackedViewModel { 49 | public: 50 | FloatViewModel(); 51 | 52 | auto get(float*) -> float; 53 | auto get(double*) -> double; 54 | }; 55 | //------------------------------------------------------------------------------ 56 | class BoolViewModel : public AtomicViewModel { 57 | Q_OBJECT 58 | 59 | public: 60 | BoolViewModel(); 61 | 62 | auto get(bool*) -> bool; 63 | 64 | private: 65 | bool _value; 66 | }; 67 | //------------------------------------------------------------------------------ 68 | #endif 69 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/include/Backend.hpp: -------------------------------------------------------------------------------- 1 | /// Copyright Matus Chochlik. 2 | /// Distributed under the GNU GENERAL PUBLIC LICENSE version 3. 3 | /// See http://www.gnu.org/licenses/gpl-3.0.txt 4 | /// 5 | #ifndef MIRROR_FACTORY_BUILDER_QT_BACKEND_HPP 6 | #define MIRROR_FACTORY_BUILDER_QT_BACKEND_HPP 7 | 8 | #include "../../testdecl/tetrahedron.hpp" 9 | #include "Theme.hpp" 10 | #include "factory_traits.hpp" 11 | #include 12 | 13 | class BuilderViewModel; 14 | //------------------------------------------------------------------------------ 15 | class Backend : public QObject { 16 | Q_OBJECT 17 | 18 | Q_PROPERTY(BuilderViewModel* builder READ getBuilder CONSTANT) 19 | Q_PROPERTY(Theme* theme READ getTheme CONSTANT) 20 | public: 21 | Backend(); 22 | 23 | auto getBuilder() -> BuilderViewModel*; 24 | auto getTheme() noexcept -> Theme*; 25 | public slots: 26 | private: 27 | Theme _theme; 28 | 29 | mirror::factory_builder _builder; 30 | std::unique_ptr> _pointFactory; 31 | std::unique_ptr> 32 | _triangleFactory; 33 | std::unique_ptr> 34 | _tetrahedronFactory; 35 | }; 36 | //------------------------------------------------------------------------------ 37 | #endif 38 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/include/BuilderViewModel.hpp: -------------------------------------------------------------------------------- 1 | /// Copyright Matus Chochlik. 2 | /// Distributed under the GNU GENERAL PUBLIC LICENSE version 3. 3 | /// See http://www.gnu.org/licenses/gpl-3.0.txt 4 | /// 5 | #ifndef MIRROR_FACTORY_BUILDER_QT_BUILDER_VIEW_MODEL_HPP 6 | #define MIRROR_FACTORY_BUILDER_QT_BUILDER_VIEW_MODEL_HPP 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | class FactoryViewModel; 13 | //------------------------------------------------------------------------------ 14 | class BuilderViewModel : public QObject { 15 | Q_OBJECT 16 | 17 | Q_PROPERTY( 18 | QStringList factoryLabels READ getFactoryLabels NOTIFY factoriesChanged) 19 | Q_PROPERTY(FactoryViewModel* selectedFactory READ getSelectedFactory NOTIFY 20 | factorySelected) 21 | public: 22 | BuilderViewModel(); 23 | 24 | void addFactory(FactoryViewModel& viewModel); 25 | auto getFactoryLabels() -> QStringList; 26 | auto getSelectedFactory() -> FactoryViewModel*; 27 | signals: 28 | void factoriesChanged(); 29 | void factorySelected(); 30 | public slots: 31 | void selectFactory(int index); 32 | 33 | private: 34 | std::vector _factoryViewModels; 35 | int _selectedIndex{0}; 36 | }; 37 | //------------------------------------------------------------------------------ 38 | #endif 39 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/include/ConstructorViewModel.hpp: -------------------------------------------------------------------------------- 1 | /// Copyright Matus Chochlik. 2 | /// Distributed under the GNU GENERAL PUBLIC LICENSE version 3. 3 | /// See http://www.gnu.org/licenses/gpl-3.0.txt 4 | /// 5 | #ifndef MIRROR_FACTORY_BUILDER_QT_CONSTRUCTOR_VIEW_MODEL_HPP 6 | #define MIRROR_FACTORY_BUILDER_QT_CONSTRUCTOR_VIEW_MODEL_HPP 7 | 8 | #include 9 | #include 10 | 11 | class ParameterViewModel; 12 | //------------------------------------------------------------------------------ 13 | class ConstructorViewModel : public QObject { 14 | Q_OBJECT 15 | 16 | Q_PROPERTY(QString label READ getLabel() NOTIFY parametersChanged) 17 | Q_PROPERTY( 18 | QList parameters READ getParameters NOTIFY parametersChanged) 19 | public: 20 | ConstructorViewModel(bool is_default, bool is_move, bool is_copy); 21 | 22 | auto getLabel() -> QString; 23 | 24 | void addParameter(ParameterViewModel& viewModel); 25 | auto getParameters() -> QList; 26 | signals: 27 | void parametersChanged(); 28 | public slots: 29 | private: 30 | std::vector _parameterViewModels; 31 | bool _is_default; 32 | bool _is_move; 33 | bool _is_copy; 34 | }; 35 | //------------------------------------------------------------------------------ 36 | #endif 37 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/include/FactoryViewModel.hpp: -------------------------------------------------------------------------------- 1 | /// Copyright Matus Chochlik. 2 | /// Distributed under the GNU GENERAL PUBLIC LICENSE version 3. 3 | /// See http://www.gnu.org/licenses/gpl-3.0.txt 4 | /// 5 | #ifndef MIRROR_FACTORY_BUILDER_QT_FACTORY_VIEW_MODEL_HPP 6 | #define MIRROR_FACTORY_BUILDER_QT_FACTORY_VIEW_MODEL_HPP 7 | 8 | #include 9 | #include 10 | 11 | class ConstructorViewModel; 12 | //------------------------------------------------------------------------------ 13 | class FactoryViewModel : public QObject { 14 | Q_OBJECT 15 | 16 | Q_PROPERTY(QString label READ getLabel() CONSTANT) 17 | Q_PROPERTY(QStringList constructorLabels READ getConstructorLabels NOTIFY 18 | constructorsChanged) 19 | Q_PROPERTY(ConstructorViewModel* selectedConstructor READ 20 | getSelectedConstructor NOTIFY constructorSelected) 21 | public: 22 | FactoryViewModel(QString label); 23 | 24 | auto getLabel() -> QString; 25 | 26 | void addConstructor(ConstructorViewModel& viewModel); 27 | auto getConstructorLabels() -> QStringList; 28 | auto getSelectedConstructor() -> ConstructorViewModel*; 29 | auto getSelectedIndex() -> size_t; 30 | void testFunc(std::function); 31 | signals: 32 | void constructorsChanged(); 33 | void constructorSelected(); 34 | public slots: 35 | void selectConstructor(int index); 36 | QString test(); 37 | 38 | private: 39 | QString _label; 40 | std::function _doTest; 41 | std::vector _constructorViewModels; 42 | int _selectedIndex{0}; 43 | }; 44 | //------------------------------------------------------------------------------ 45 | #endif 46 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/include/ParameterViewModel.hpp: -------------------------------------------------------------------------------- 1 | /// Copyright Matus Chochlik. 2 | /// Distributed under the GNU GENERAL PUBLIC LICENSE version 3. 3 | /// See http://www.gnu.org/licenses/gpl-3.0.txt 4 | /// 5 | #ifndef MIRROR_FACTORY_BUILDER_QT_PARAMETER_VIEW_MODEL_HPP 6 | #define MIRROR_FACTORY_BUILDER_QT_PARAMETER_VIEW_MODEL_HPP 7 | 8 | #include 9 | 10 | class FactoryViewModel; 11 | //------------------------------------------------------------------------------ 12 | class ParameterViewModel : public QObject { 13 | Q_OBJECT 14 | 15 | Q_PROPERTY(QUrl unitUrl READ getUnitUrl() CONSTANT) 16 | Q_PROPERTY(QString typeName READ getTypeName() CONSTANT) 17 | Q_PROPERTY(QString name READ getName() CONSTANT) 18 | Q_PROPERTY(QObject* nested READ getNested NOTIFY nestedModelAdded) 19 | public: 20 | ParameterViewModel( 21 | QString typeName, 22 | QString name, 23 | QObject* nestedModel = nullptr); 24 | 25 | auto getUnitName() -> QString; 26 | auto getUnitUrl() -> QUrl; 27 | auto getTypeName() -> QString; 28 | auto getName() -> QString; 29 | auto getNested() -> QObject*; 30 | 31 | void addFactory(FactoryViewModel& viewModel); 32 | signals: 33 | void nestedModelAdded(); 34 | public slots: 35 | private: 36 | QString _typeName; 37 | QString _name; 38 | QString _unit; 39 | QObject* _nestedModel{nullptr}; 40 | }; 41 | //------------------------------------------------------------------------------ 42 | #endif 43 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/include/Theme.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// Copyright Matus Chochlik. 3 | /// Distributed under the GNU GENERAL PUBLIC LICENSE version 3. 4 | /// See http://www.gnu.org/licenses/gpl-3.0.txt 5 | /// 6 | 7 | #ifndef MIRROR_FACTORY_BUILDER_QT_THEME_HPP 8 | #define MIRROR_FACTORY_BUILDER_QT_THEME_HPP 9 | 10 | #include 11 | 12 | //------------------------------------------------------------------------------ 13 | class Theme : public QObject { 14 | Q_OBJECT 15 | 16 | Q_PROPERTY(bool light READ getLight WRITE setLight NOTIFY lightChanged) 17 | 18 | public: 19 | Theme(); 20 | 21 | void setLight(bool); 22 | auto getLight() const -> bool; 23 | 24 | signals: 25 | void lightChanged(); 26 | public slots: 27 | private: 28 | bool _light{false}; 29 | }; 30 | //------------------------------------------------------------------------------ 31 | #endif 32 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/main.cpp: -------------------------------------------------------------------------------- 1 | /// Copyright Matus Chochlik. 2 | /// Distributed under the GNU GENERAL PUBLIC LICENSE version 3. 3 | /// See http://www.gnu.org/licenses/gpl-3.0.txt 4 | /// 5 | #include "Backend.hpp" 6 | #include "BuilderViewModel.hpp" 7 | #include "ConstructorViewModel.hpp" 8 | #include "FactoryViewModel.hpp" 9 | #include "ParameterViewModel.hpp" 10 | #include 11 | #include 12 | #include 13 | 14 | int main(int argc, char* argv[]) { 15 | QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 16 | QGuiApplication app(argc, argv); 17 | 18 | qmlRegisterUncreatableType( 19 | "com.github.matus-chochlik", 1, 0, "Theme", {}); 20 | qmlRegisterUncreatableType( 21 | "com.github.matus-chochlik", 1, 0, "BuilderViewModel", {}); 22 | qmlRegisterUncreatableType( 23 | "com.github.matus-chochlik", 1, 0, "FactoryViewModel", {}); 24 | qmlRegisterUncreatableType( 25 | "com.github.matus-chochlik", 1, 0, "ConstructorViewModel", {}); 26 | qmlRegisterUncreatableType( 27 | "com.github.matus-chochlik", 1, 0, "ParameterViewModel", {}); 28 | 29 | Backend backend; 30 | QQmlApplicationEngine engine; 31 | 32 | engine.rootContext()->setContextProperty("backend", &backend); 33 | engine.load("qrc:///main.qml"); 34 | 35 | return app.exec(); 36 | } 37 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import QtQuick.Controls 2.4 3 | import QtQuick.Controls.Material 2.4 4 | import QtQuick.Layouts 1.2 5 | import "qrc:///qml_units" 6 | 7 | ApplicationWindow { 8 | id: root 9 | visible: true 10 | width: 500 11 | height: 700 12 | Material.theme: backend.theme.light ? Material.Light : Material.Dark 13 | Material.accent: Material.Orange 14 | 15 | Action { 16 | id: quitAction 17 | text: qsTr("&Quit") 18 | shortcut: StandardKey.Quit 19 | onTriggered: { 20 | Qt.callLater(Qt.quit) 21 | } 22 | } 23 | 24 | Action { 25 | id: lightThemeToggleAction 26 | text: qsTr("&Light") 27 | checkable: true 28 | checked: backend.theme.light 29 | onToggled: { 30 | backend.theme.light = checked 31 | } 32 | } 33 | 34 | menuBar: MenuBar { 35 | Menu { 36 | title: qsTr("&File") 37 | MenuItem { 38 | action: quitAction 39 | } 40 | } 41 | Menu { 42 | title: qsTr("&Window") 43 | Menu { 44 | title: qsTr("&Theme") 45 | MenuItem { 46 | action: lightThemeToggleAction 47 | } 48 | } 49 | } 50 | } 51 | 52 | contentData: BuilderUnit { 53 | anchors.fill: parent 54 | model: backend.builder 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/qml_units/BoolUnit.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import QtQuick.Controls 2.4 3 | import QtQuick.Layouts 1.2 4 | import "qrc:///qml_units" 5 | 6 | Checkbox { 7 | property variant model: null 8 | text: model.name 9 | } 10 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/qml_units/BuilderUnit.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import QtQuick.Controls 2.4 3 | import QtQuick.Layouts 1.2 4 | import "qrc:///qml_units" 5 | 6 | ColumnLayout { 7 | id: builderUnit 8 | property variant model: null 9 | 10 | Label { 11 | Layout.fillWidth: true 12 | text: qsTr("Select product type") 13 | } 14 | 15 | ComboBox { 16 | id: factorySelector 17 | Layout.fillWidth: true 18 | model: builderUnit.model.factoryLabels 19 | onActivated: builderUnit.model.selectFactory(currentIndex) 20 | } 21 | 22 | ScrollView { 23 | Layout.fillWidth: true 24 | Layout.fillHeight: true 25 | clip: true 26 | ScrollBar.horizontal.policy: ScrollBar.AlwaysOff 27 | ColumnLayout { 28 | FactoryUnit { 29 | Layout.preferredWidth: builderUnit.width 30 | Layout.fillHeight: true 31 | model: builderUnit.model.selectedFactory 32 | } 33 | } 34 | } 35 | 36 | Button { 37 | Layout.fillWidth: true 38 | text: qsTr("construct") 39 | onClicked: { 40 | message.text = builderUnit.model.selectedFactory.test() 41 | } 42 | } 43 | 44 | TextArea { 45 | id: message 46 | text: "" 47 | readOnly: true 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/qml_units/CompositeUnit.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import QtQuick.Controls 2.4 3 | import QtQuick.Layouts 1.2 4 | import "qrc:///qml_units" 5 | 6 | RowLayout { 7 | id: compositeUnit 8 | property variant model: null 9 | 10 | Label { 11 | Layout.fillWidth: true 12 | text: compositeUnit.model.name 13 | } 14 | 15 | FactoryUnit { 16 | Layout.fillWidth: true 17 | Layout.fillHeight: true 18 | model: compositeUnit.model.nested 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/qml_units/ConstructorUnit.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import QtQuick.Controls 2.4 3 | import QtQuick.Layouts 1.2 4 | import "qrc:///qml_units" 5 | 6 | ColumnLayout { 7 | id: factoryUnit 8 | property variant model: null 9 | 10 | Repeater { 11 | model: factoryUnit.model.parameters 12 | delegate: Loader { 13 | id: unitLoader 14 | Layout.fillWidth: true 15 | source: modelData.unitUrl 16 | onLoaded: { 17 | unitLoader.item.model = modelData 18 | } 19 | } 20 | } 21 | 22 | Item { 23 | Layout.fillWidth: true 24 | Layout.fillHeight: true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/qml_units/FactoryUnit.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import QtQuick.Controls 2.4 3 | import QtQuick.Layouts 1.2 4 | import "qrc:///qml_units" 5 | 6 | ColumnLayout { 7 | id: factoryUnit 8 | property variant model: null 9 | 10 | ComboBox { 11 | id: constructorSelector 12 | Layout.fillWidth: true 13 | model: factoryUnit.model.constructorLabels 14 | onActivated: factoryUnit.model.selectConstructor(currentIndex) 15 | } 16 | 17 | ConstructorUnit { 18 | Layout.fillWidth: true 19 | Layout.fillHeight: true 20 | model: factoryUnit.model.selectedConstructor 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/qml_units/FloatUnit.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import QtQuick.Controls 2.4 3 | import QtQuick.Layouts 1.2 4 | import "qrc:///qml_units" 5 | 6 | RowLayout { 7 | id: floatUnit 8 | property variant model: null 9 | 10 | Label { 11 | Layout.preferredWidth: 150 12 | text: floatUnit.model.name 13 | } 14 | 15 | TextField { 16 | Layout.fillWidth: true 17 | validator: DoubleValidator { } 18 | text: floatUnit.model.nested.value 19 | onEditingFinished: { 20 | floatUnit.model.nested.value = text 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/qml_units/StringUnit.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import QtQuick.Controls 2.4 3 | import QtQuick.Layouts 1.2 4 | import "qrc:///qml_units" 5 | 6 | RowLayout { 7 | id: stringUnit 8 | property variant model: null 9 | 10 | Label { 11 | Layout.preferredWidth: 150 12 | text: stringUnit.model.name 13 | } 14 | 15 | TextField { 16 | Layout.fillWidth: true 17 | text: stringUnit.model.nested.value 18 | onEditingFinished: { 19 | stringUnit.model.nested.value = text 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/qt_factory.pro: -------------------------------------------------------------------------------- 1 | QMAKE_CXX = /opt/mirror/llvm/bin/clang++ 2 | QMAKE_CXXFLAGS += -std=c++2b \ 3 | -stdlib=libc++ \ 4 | -freflection-ts \ 5 | -freflection-ext \ 6 | -Wno-language-extension-token \ 7 | -Wno-c++98-compat \ 8 | -Wno-c++98-compat-pedantic \ 9 | -Wno-c++20-compat \ 10 | -Wno-c++2a-extensions \ 11 | -Wno-padded \ 12 | -Wno-weak-vtables \ 13 | -Wno-global-constructors \ 14 | -Wno-exit-time-destructors \ 15 | -Wno-extra-semi-stmt \ 16 | -Wno-redundant-parens \ 17 | -Wno-documentation-unknown-command 18 | 19 | QMAKE_LINK = /opt/mirror/llvm/bin/clang++ 20 | QMAKE_LFLAGS += -std=c++2b \ 21 | -stdlib=libc++ \ 22 | -Wl,-rpath,/opt/mirror/llvm/lib \ 23 | -Wl,-rpath,/opt/mirror/llvm/lib/x86_64-unknown-linux-gnu 24 | 25 | TEMPLATE = app 26 | QT += core quick 27 | 28 | TARGET = qt_factory 29 | 30 | INCLUDEPATH += ../../../../include \ 31 | include 32 | 33 | SOURCES += src/Backend.cpp \ 34 | src/Theme.cpp \ 35 | src/BuilderViewModel.cpp \ 36 | src/FactoryViewModel.cpp \ 37 | src/ConstructorViewModel.cpp \ 38 | src/ParameterViewModel.cpp \ 39 | src/AtomicViewModel.cpp \ 40 | main.cpp 41 | 42 | HEADERS += include/Backend.hpp \ 43 | include/Theme.hpp \ 44 | include/BuilderViewModel.hpp \ 45 | include/FactoryViewModel.hpp \ 46 | include/ConstructorViewModel.hpp \ 47 | include/ParameterViewModel.hpp \ 48 | include/AtomicViewModel.hpp 49 | 50 | RESOURCES += qt_factory.qrc 51 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/qt_factory.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | qtquickcontrols2.conf 5 | qml_units/BuilderUnit.qml 6 | qml_units/FactoryUnit.qml 7 | qml_units/ConstructorUnit.qml 8 | qml_units/CompositeUnit.qml 9 | qml_units/BoolUnit.qml 10 | qml_units/FloatUnit.qml 11 | qml_units/StringUnit.qml 12 | 13 | 14 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/qtquickcontrols2.conf: -------------------------------------------------------------------------------- 1 | [Controls] 2 | Style=Material 3 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/src/Backend.cpp: -------------------------------------------------------------------------------- 1 | /// Copyright Matus Chochlik. 2 | /// Distributed under the GNU GENERAL PUBLIC LICENSE version 3. 3 | /// See http://www.gnu.org/licenses/gpl-3.0.txt 4 | /// 5 | #include "Backend.hpp" 6 | #include "BuilderViewModel.hpp" 7 | //------------------------------------------------------------------------------ 8 | // Backend 9 | //------------------------------------------------------------------------------ 10 | Backend::Backend() 11 | : QObject{nullptr} 12 | , _builder{"qt5"} 13 | , _pointFactory{_builder.make()} 14 | , _triangleFactory{_builder.make()} 15 | , _tetrahedronFactory{_builder.make()} { 16 | 17 | _pointFactory->base_unit().view_model().testFunc([this] { 18 | const auto p = _pointFactory->construct({}); 19 | return QString("Distance of constructed point from origin: %1") 20 | .arg(QString::number(double(p.direction().length()))); 21 | }); 22 | 23 | _triangleFactory->base_unit().view_model().testFunc([this] { 24 | const auto t = _triangleFactory->construct({}); 25 | return QString("Area of constructed triangle: %1") 26 | .arg(QString::number(double(t.area()))); 27 | }); 28 | 29 | _tetrahedronFactory->base_unit().view_model().testFunc([this] { 30 | const auto t = _tetrahedronFactory->construct({}); 31 | return QString("Volume of constructed tetrahedron: %1") 32 | .arg(QString::number(double(t.volume()))); 33 | }); 34 | } 35 | //------------------------------------------------------------------------------ 36 | auto Backend::getBuilder() -> BuilderViewModel* { 37 | return &_builder.base_unit().view_model(); 38 | } 39 | //------------------------------------------------------------------------------ 40 | auto Backend::getTheme() noexcept -> Theme* { 41 | return &_theme; 42 | } 43 | //------------------------------------------------------------------------------ 44 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/src/BuilderViewModel.cpp: -------------------------------------------------------------------------------- 1 | /// Copyright Matus Chochlik. 2 | /// Distributed under the GNU GENERAL PUBLIC LICENSE version 3. 3 | /// See http://www.gnu.org/licenses/gpl-3.0.txt 4 | /// 5 | #include "BuilderViewModel.hpp" 6 | #include "FactoryViewModel.hpp" 7 | //------------------------------------------------------------------------------ 8 | // BuilderViewModel 9 | //------------------------------------------------------------------------------ 10 | BuilderViewModel::BuilderViewModel() 11 | : QObject{} {} 12 | //------------------------------------------------------------------------------ 13 | void BuilderViewModel::addFactory(FactoryViewModel& viewModel) { 14 | _factoryViewModels.push_back(&viewModel); 15 | emit factoriesChanged(); 16 | } 17 | //------------------------------------------------------------------------------ 18 | auto BuilderViewModel::getFactoryLabels() -> QStringList { 19 | QStringList labels; 20 | for(auto* viewModel : _factoryViewModels) { 21 | labels.push_back(viewModel->getLabel()); 22 | } 23 | return labels; 24 | } 25 | //------------------------------------------------------------------------------ 26 | auto BuilderViewModel::getSelectedFactory() -> FactoryViewModel* { 27 | if(_selectedIndex >= 0) { 28 | if(_selectedIndex < int(_factoryViewModels.size())) { 29 | return _factoryViewModels[static_cast(_selectedIndex)]; 30 | } 31 | } 32 | return nullptr; 33 | } 34 | //------------------------------------------------------------------------------ 35 | void BuilderViewModel::selectFactory(int index) { 36 | if(_selectedIndex != index) { 37 | _selectedIndex = index; 38 | emit factorySelected(); 39 | } 40 | } 41 | //------------------------------------------------------------------------------ 42 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/src/ConstructorViewModel.cpp: -------------------------------------------------------------------------------- 1 | /// Copyright Matus Chochlik. 2 | /// Distributed under the GNU GENERAL PUBLIC LICENSE version 3. 3 | /// See http://www.gnu.org/licenses/gpl-3.0.txt 4 | /// 5 | #include "ConstructorViewModel.hpp" 6 | #include "ParameterViewModel.hpp" 7 | //------------------------------------------------------------------------------ 8 | // ConstructorViewModel 9 | //------------------------------------------------------------------------------ 10 | ConstructorViewModel::ConstructorViewModel( 11 | bool is_default, 12 | bool is_move, 13 | bool is_copy) 14 | : QObject{} 15 | , _is_default{is_default} 16 | , _is_move{is_move} 17 | , _is_copy{is_copy} {} 18 | //------------------------------------------------------------------------------ 19 | auto ConstructorViewModel::getLabel() -> QString { 20 | QString label; 21 | if(_is_default) { 22 | return ""; 23 | } 24 | 25 | if(_is_move) { 26 | return ""; 27 | } 28 | 29 | if(_is_copy) { 30 | return ""; 31 | } 32 | 33 | label.append("("); 34 | bool first = true; 35 | for(auto* viewModel : _parameterViewModels) { 36 | if(first) { 37 | first = false; 38 | } else { 39 | label.append(", "); 40 | } 41 | label.append(viewModel->getName()); 42 | label.append(": "); 43 | label.append(viewModel->getTypeName()); 44 | } 45 | label.append(")"); 46 | return label; 47 | } 48 | //------------------------------------------------------------------------------ 49 | void ConstructorViewModel::addParameter(ParameterViewModel& viewModel) { 50 | _parameterViewModels.push_back(&viewModel); 51 | emit parametersChanged(); 52 | } 53 | //------------------------------------------------------------------------------ 54 | auto ConstructorViewModel::getParameters() -> QList { 55 | QList result; 56 | for(auto* viewModel : _parameterViewModels) { 57 | result.push_back(viewModel); 58 | } 59 | return result; 60 | } 61 | //------------------------------------------------------------------------------ 62 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/src/ParameterViewModel.cpp: -------------------------------------------------------------------------------- 1 | /// Copyright Matus Chochlik. 2 | /// Distributed under the GNU GENERAL PUBLIC LICENSE version 3. 3 | /// See http://www.gnu.org/licenses/gpl-3.0.txt 4 | /// 5 | #include "ParameterViewModel.hpp" 6 | #include "AtomicViewModel.hpp" 7 | #include "FactoryViewModel.hpp" 8 | //------------------------------------------------------------------------------ 9 | // ParameterViewModel 10 | //------------------------------------------------------------------------------ 11 | ParameterViewModel::ParameterViewModel( 12 | QString typeName, 13 | QString name, 14 | QObject* nestedModel) 15 | : QObject{} 16 | , _typeName{std::move(typeName)} 17 | , _name{std::move(name)} 18 | , _nestedModel{nestedModel} {} 19 | //------------------------------------------------------------------------------ 20 | auto ParameterViewModel::getUnitName() -> QString { 21 | if(auto* atomicViewModel{dynamic_cast(_nestedModel)}) { 22 | return atomicViewModel->getUnitName(); 23 | } 24 | return "Composite"; 25 | } 26 | //------------------------------------------------------------------------------ 27 | auto ParameterViewModel::getUnitUrl() -> QUrl { 28 | return {"qrc:///qml_units/" + getUnitName() + "Unit.qml"}; 29 | } 30 | //------------------------------------------------------------------------------ 31 | auto ParameterViewModel::getTypeName() -> QString { 32 | return _typeName; 33 | } 34 | //------------------------------------------------------------------------------ 35 | auto ParameterViewModel::getName() -> QString { 36 | return _name; 37 | } 38 | //------------------------------------------------------------------------------ 39 | auto ParameterViewModel::getNested() -> QObject* { 40 | return _nestedModel; 41 | } 42 | //------------------------------------------------------------------------------ 43 | void ParameterViewModel::addFactory(FactoryViewModel& viewModel) { 44 | _nestedModel = &viewModel; 45 | emit nestedModelAdded(); 46 | } 47 | //------------------------------------------------------------------------------ 48 | -------------------------------------------------------------------------------- /example/mirror/factory/qt/src/Theme.cpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// Copyright Matus Chochlik. 3 | /// Distributed under the GNU GENERAL PUBLIC LICENSE version 3. 4 | /// See http://www.gnu.org/licenses/gpl-3.0.txt 5 | /// 6 | 7 | #include "Theme.hpp" 8 | //------------------------------------------------------------------------------ 9 | Theme::Theme() 10 | : QObject{nullptr} { 11 | setLight(false); 12 | } 13 | //------------------------------------------------------------------------------ 14 | void Theme::setLight(bool value) { 15 | _light = value; 16 | emit lightChanged(); 17 | } 18 | //------------------------------------------------------------------------------ 19 | auto Theme::getLight() const -> bool { 20 | return _light; 21 | } 22 | //------------------------------------------------------------------------------ 23 | -------------------------------------------------------------------------------- /example/mirror/factory/rapidjson.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/factory/rapidjson.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #include "../testdecl/tetrahedron.hpp" 10 | #include 11 | #include 12 | #include 13 | 14 | static void print_info(const example::tetrahedron& teh) { 15 | std::cout << "volume of the tetrahedron is: " << teh.volume() << std::endl; 16 | std::cout << "area of its base is: " << teh.base().area() << std::endl; 17 | std::cout << "distance of its apex from origin is: " 18 | << teh.apex().direction().length() << std::endl; 19 | } 20 | 21 | template 22 | static void construct_from( 23 | mirror::factory_builder& builder, 24 | const char (&json_str)[N]) { 25 | 26 | rapidjson::Document json_doc; 27 | const rapidjson::ParseResult parse_result{json_doc.Parse(json_str)}; 28 | if(parse_result) { 29 | using namespace mirror; 30 | 31 | auto fac = builder.build(); 32 | print_info(fac.construct({json_doc})); 33 | 34 | } else { 35 | std::cerr << rapidjson::GetParseError_En(parse_result.Code()) 36 | << std::endl; 37 | } 38 | } 39 | 40 | int main() { 41 | using namespace mirror; 42 | factory_builder builder("rjf"); 43 | 44 | construct_from(builder, R"({ 45 | "base": { 46 | "a": { 47 | "x": 1.0, 48 | "y": 0.0, 49 | "z": 0.0 50 | }, 51 | "b": { 52 | "x": 0.0, 53 | "y": 1.0, 54 | "z": 0.0 55 | }, 56 | "c": { 57 | "x": 0.0, 58 | "y": 0.0, 59 | "z": 1.0 60 | } 61 | }, 62 | "apex": { 63 | "v": 1.0 64 | } 65 | })"); 66 | 67 | construct_from(builder, R"([ 68 | [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]], [2.0] 69 | ])"); 70 | 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /example/mirror/fetch_from_sqlite.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/fetch_from_sqlite.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | struct person { 14 | std::uintmax_t person_id; 15 | std::string given_name; 16 | std::string family_name; 17 | std::string email_address; 18 | }; 19 | 20 | int main(int, const char** argv) { 21 | mirror::sqlite3_db db{ 22 | std::filesystem::path{argv[0]}.replace_filename("people.db").string()}; 23 | 24 | std::vector ps; 25 | 26 | db.ensure_table(); 27 | 28 | for(const auto& p : db.fetch("SELECT * FROM person", ps)) { 29 | std::cout << p.given_name << " " << p.family_name << std::endl; 30 | } 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /example/mirror/filter.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/filter.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include "testdecl/tetrahedron.hpp" 9 | #include 10 | #include 11 | #include 12 | 13 | int main() { 14 | for_each( 15 | make_sequence( 16 | mirror(example::vector), 17 | mirror(example::triangle), 18 | mirror(example::tetrahedron)), 19 | [](mirror::metaobject auto mo) { 20 | std::cout << "member functions without parameters: "; 21 | for_each( 22 | filter( 23 | get_member_functions(mo), is_empty(get_parameters(mirror::_1))), 24 | [](auto mf) { std::cout << get_name(mf) << "; "; }); 25 | std::cout << std::endl; 26 | }); 27 | 28 | for_each( 29 | make_sequence( 30 | mirror(example::vector), 31 | mirror(example::triangle), 32 | mirror(example::tetrahedron)), 33 | [](mirror::metaobject auto mo) { 34 | std::cout << "count of constructors with parameters: "; 35 | std::cout << get_size(filter( 36 | get_constructors(mo), not_(is_empty(get_parameters(mirror::_1))))); 37 | std::cout << std::endl; 38 | }); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /example/mirror/find_if.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/find_if.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | 12 | struct mystruct { 13 | using type = char; 14 | 15 | std::string s{"str"}; 16 | float f{1.2F}; 17 | int i{345}; 18 | bool b{false}; 19 | 20 | mystruct() = default; 21 | }; 22 | 23 | int main() { 24 | using mirror::_1; 25 | mystruct x; 26 | 27 | const auto ms = mirror(mystruct); 28 | 29 | const auto found_by_name = 30 | find_if(get_data_members(ms), [](auto me) { return has_name(me, "i"); }); 31 | 32 | if(reflects_variable(found_by_name)) { 33 | std::cout << get_value(found_by_name, x) << std::endl; 34 | } 35 | 36 | const auto found_by_having_type = 37 | find_if(get_data_members(ms), has_type(_1)); 38 | 39 | if(reflects_variable(found_by_having_type)) { 40 | std::cout << get_value(found_by_having_type, x) << std::endl; 41 | } 42 | 43 | const auto found_by_having_trait = find_if( 44 | get_data_members(ms), has_type_with_trait(_1)); 45 | 46 | if(reflects_variable(found_by_having_trait)) { 47 | std::cout << get_value(found_by_having_trait, x) << std::endl; 48 | } 49 | 50 | const auto found_by_being_type = 51 | find_if(get_member_types(ms), is_type(_1)); 52 | 53 | if(reflects_type(found_by_being_type)) { 54 | std::cout << get_name(found_by_being_type) << std::endl; 55 | } 56 | 57 | const auto found_default_ctr = find_if( 58 | transform(get_constructors(ms), get_parameters(_1)), is_empty(_1)); 59 | 60 | if(reflects_object(found_default_ctr)) { 61 | std::cout << "has default constructor" << std::endl; 62 | } 63 | 64 | const auto found_nondefault_ctr = find_if_not( 65 | transform(get_constructors(ms), get_parameters(_1)), is_empty(_1)); 66 | 67 | if(reflects_object(found_nondefault_ctr)) { 68 | std::cout << "has non-default constructor" << std::endl; 69 | } 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /example/mirror/find_longest_name.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/find_longest_name.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include "testdecl/month.hpp" 9 | #include "testdecl/weekday.hpp" 10 | #include 11 | #include 12 | #include 13 | 14 | void print_info(mirror::metaobject auto mo) { 15 | const auto find_enum_with_longest_name = 16 | find_ranking(get_enumerators(mirror::_1), get_size(get_name(mirror::_1))); 17 | 18 | const auto me = find_enum_with_longest_name(mo); 19 | 20 | std::cout << get_name(me) << ", length: " << get_name(me).size() 21 | << ", value: " << int(get_constant(me)) << std::endl; 22 | } 23 | 24 | int main() { 25 | print_info(mirror(example::weekday)); 26 | print_info(mirror(example::month)); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /example/mirror/from_rapidjson.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/from_rapidjson.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include "testdecl/month.hpp" 9 | #include "testdecl/tetrahedron.hpp" 10 | #include "testdecl/weekday.hpp" 11 | #include 12 | #include 13 | #include 14 | 15 | template 16 | void from_json(std::string_view json_str) { 17 | rapidjson::Document json_doc; 18 | const rapidjson::ParseResult parse_result{ 19 | json_doc.Parse(mirror::to_rapidjson(json_str))}; 20 | if(parse_result) { 21 | T value{}; 22 | const auto errors = mirror::serialize::read_rapidjson(value, json_doc); 23 | if(!errors) { 24 | std::cout << "OK: '"; 25 | mirror::serialize::write_rapidjson_stream(value, std::cout); 26 | std::cout << "'" << std::endl; 27 | } else { 28 | std::cerr << "failed to deserialize from '" << json_str << "'!" 29 | << std::endl; 30 | } 31 | } else { 32 | std::cerr << rapidjson::GetParseError_En(parse_result.Code()) 33 | << std::endl; 34 | } 35 | } 36 | 37 | int main() { 38 | from_json("true"); 39 | from_json("null"); 40 | from_json("1"); 41 | from_json("2"); 42 | from_json("3.4"); 43 | from_json>("[false, 12, 3.4]"); 44 | from_json>("[true, false, null]"); 45 | from_json>(R"([])"); 46 | from_json>(R"(["august"])"); 47 | from_json>( 48 | R"(["february", "june", "july", "august", "december"])"); 49 | from_json>( 50 | R"(["monday","wednesday","friday"])"); 51 | from_json( 52 | R"({"_base":{ 53 | "_a":{"_x":1.0,"_y":0.0,"_z":0.0}, 54 | "_b":{"_x":0.0,"_y":1.0,"_z":0.0}, 55 | "_c":{"_x":0.0,"_y":0.0,"_z":1.0} 56 | },"_apex":{"_x":0.0,"_y":0.0,"_z":0.0}})"); 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /example/mirror/good_example.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/good_example.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | struct excellent_example { 14 | void foo() {} 15 | void bar() {} 16 | void baz() {} 17 | }; 18 | 19 | struct good_example { 20 | void qux() {} 21 | void baz() {} 22 | }; 23 | 24 | struct bad_example { 25 | void my_function() {} 26 | }; 27 | 28 | template 29 | concept good_example_class = any_of( 30 | get_member_functions(mirror(T)), 31 | ctre_match<"foo|bar|baz">(get_name(mirror::_1))); 32 | 33 | void review(good_example_class auto) { 34 | std::cout << "what a nice example!\n"; 35 | } 36 | 37 | void review(auto) { 38 | std::cout << "try harder...\n"; 39 | } 40 | 41 | int main() { 42 | review(excellent_example{}); 43 | review(good_example{}); 44 | review(bad_example{}); 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /example/mirror/group_by.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/group_by.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | struct my_interface : mirror::interface { 14 | static auto name() { 15 | return get_name(mirror(my_interface)); 16 | } 17 | 18 | virtual auto foo(int i, int j) -> int = 0; 19 | 20 | auto foo(int i) { 21 | return foo(i, 1); 22 | } 23 | 24 | virtual auto bar(int i, int j) -> int = 0; 25 | 26 | auto bar(int j) { 27 | return bar(1, j); 28 | } 29 | 30 | auto bar() { 31 | return bar(1, 2); 32 | } 33 | }; 34 | 35 | int main() { 36 | using mirror::_1; 37 | using mirror::_2; 38 | 39 | const auto print_name = [](auto mo) { 40 | std::cout << get_name(mo) << "\n"; 41 | }; 42 | 43 | const auto mfs = get_member_functions(mirror(my_interface)); 44 | 45 | auto [static_, non_static] = group_by(mfs, is_static(_1)); 46 | 47 | std::cout << "\nstatic functions:\n"; 48 | for_each(static_, print_name); 49 | 50 | std::cout << "\nnon static functions:\n"; 51 | for_each(non_static, print_name); 52 | 53 | auto [non_virtual, virtual_] = group_by(mfs, is_virtual(_1)); 54 | 55 | std::cout << "\nvirtual functions:\n"; 56 | for_each(virtual_, print_name); 57 | 58 | std::cout << "\nnon virtual functions:\n"; 59 | for_each(non_virtual, print_name); 60 | 61 | std::cout << "\noverload sets:\n"; 62 | for_each(group_by(mfs, get_name(_1)), [&](auto mo) { 63 | std::cout << get_name(get_front(mo)) << ": (" << get_size(mo) << ")\n"; 64 | }); 65 | 66 | std::cout << "\nreturn values:\n"; 67 | for_each(group_by(mfs, get_type(_1), reflect_same(_1, _2)), [&](auto mo) { 68 | std::cout << get_name(get_type(get_front(mo))) << "\n"; 69 | }); 70 | 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /example/mirror/has_overloaded_functions.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/has_overloaded_functions.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | 11 | struct foo { 12 | int plus(int x) { 13 | return x; 14 | } 15 | int plus(int x, int y) { 16 | return x + y; 17 | } 18 | int plus(int x, int y, int z) { 19 | return x + y + z; 20 | } 21 | int minus(int x) { 22 | return -x; 23 | } 24 | int minus(int x, int y) { 25 | return x - y; 26 | } 27 | }; 28 | 29 | struct bar { 30 | int a() { 31 | return 0; 32 | } 33 | int b() { 34 | return 1; 35 | } 36 | int c() { 37 | return 2; 38 | } 39 | }; 40 | 41 | int main() { 42 | const auto has_overloaded_functions = [](auto mo) { 43 | const auto mfs = get_member_functions(mo); 44 | return fold( 45 | mfs, 46 | [mfs](auto mf1) { 47 | return any_of(mfs, [mf1](auto mf2) { 48 | return !reflect_same(mf1, mf2) && 49 | get_name(mf1) == get_name(mf2); 50 | }); 51 | }, 52 | [](auto... b) { return (... || b); }); 53 | }; 54 | 55 | std::cout << has_overloaded_functions(mirror(foo)) << std::endl; 56 | std::cout << has_overloaded_functions(mirror(bar)) << std::endl; 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /example/mirror/has_overloaded_functions_2.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/has_overloaded_functions_2.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | 12 | struct foo { 13 | int plus(int x) { 14 | return x; 15 | } 16 | int plus(int x, int y) { 17 | return x + y; 18 | } 19 | int plus(int x, int y, int z) { 20 | return x + y + z; 21 | } 22 | int minus(int x) { 23 | return -x; 24 | } 25 | int minus(int x, int y) { 26 | return x - y; 27 | } 28 | }; 29 | 30 | struct bar { 31 | int a() { 32 | return 0; 33 | } 34 | int b() { 35 | return 1; 36 | } 37 | int c() { 38 | return 2; 39 | } 40 | }; 41 | 42 | int main() { 43 | using mirror::_1; 44 | const auto has_overloaded_functions = any_of( 45 | group_by(get_member_functions(_1), get_name(_1)), 46 | has_multiple_elements(_1)); 47 | 48 | std::cout << has_overloaded_functions(mirror(foo)) << std::endl; 49 | std::cout << has_overloaded_functions(mirror(bar)) << std::endl; 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /example/mirror/has_padding.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/has_padding.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | 12 | struct S1 { 13 | int i; 14 | float f; 15 | }; 16 | 17 | struct S2 { 18 | char c; 19 | double d; 20 | }; 21 | 22 | template 23 | constexpr auto sum_sizeofs(mirror::type_list) { 24 | return (0Z + ... + sizeof(T)); 25 | } 26 | 27 | template 28 | constexpr auto has_padding() -> bool { 29 | return sizeof(T) > 30 | sum_sizeofs(extract_types(transform( 31 | filter(get_data_members(mirror(T)), not_(is_static(mirror::_1))), 32 | get_type(mirror::_1)))); 33 | } 34 | 35 | template 36 | void print_has_padding() { 37 | std::cout << get_name(remove_all_aliases(mirror(T))) << ": " 38 | << (has_padding() ? "has some" : "has no") << " padding" 39 | << std::endl; 40 | } 41 | 42 | int main() { 43 | print_has_padding(); 44 | print_has_padding(); 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /example/mirror/hello_enums.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/hello_enums.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | 12 | enum class greeting { hello, world, of, reflection }; 13 | 14 | int main() { 15 | 16 | std::cout << join( 17 | get_enumerators(mirror(greeting)), 18 | to_string(get_name(mirror::_1)), 19 | std::string(" ")) 20 | << "!\n"; 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /example/mirror/hello_world.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/hello_world.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | 11 | struct hello {}; 12 | 13 | int main() { 14 | hello world; 15 | 16 | std::cout << get_name(mirror(hello)) << ", " << get_name(mirror(world)) 17 | << std::endl; 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /example/mirror/integral_data_members.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/integral_data_members.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | 12 | struct foo { 13 | double d; 14 | int i; 15 | short s; 16 | char c; 17 | }; 18 | 19 | struct bar { 20 | int i; 21 | float f; 22 | long l; 23 | bool b; 24 | }; 25 | 26 | int main() { 27 | const auto count_integral_members = count_if( 28 | get_data_members(mirror::_1), 29 | has_type_trait(get_type(mirror::_1))); 30 | 31 | std::cout << count_integral_members(mirror(foo)) << std::endl; 32 | std::cout << count_integral_members(mirror(bar)) << std::endl; 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /example/mirror/interface_revision.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/interface_revision.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | template 15 | struct versioned_interface { 16 | public: 17 | constexpr versioned_interface(const versioned_interface&) = delete; 18 | auto operator=(versioned_interface&&) = delete; 19 | auto operator=(const versioned_interface&) = delete; 20 | 21 | static auto revision_id() noexcept -> mirror::hash_t { 22 | using mirror::_1; 23 | return fold( 24 | filter(get_member_functions(mirror(Intf)), is_virtual(_1)), 25 | get_hash(_1) ^ get_hash(get_type(_1)), 26 | [](auto... h) { return (... ^ h); }); 27 | } 28 | 29 | protected: 30 | constexpr versioned_interface() noexcept = default; 31 | 32 | constexpr versioned_interface(versioned_interface&&) noexcept = default; 33 | virtual ~versioned_interface() noexcept = default; 34 | }; 35 | 36 | #define EXAMPLE_REVISION 2 37 | 38 | namespace example { 39 | #if EXAMPLE_REVISION == 1 40 | inline 41 | #endif 42 | namespace v1 { 43 | 44 | struct operations : versioned_interface { 45 | virtual void foo() = 0; 46 | virtual void bar(int) = 0; 47 | virtual auto baz(bool, bool) -> bool = 0; 48 | }; 49 | 50 | } // namespace v1 51 | 52 | #if EXAMPLE_REVISION == 2 53 | inline 54 | #endif 55 | namespace v2 { 56 | 57 | struct operations : versioned_interface { 58 | virtual void foo() = 0; 59 | virtual void bar(long) = 0; 60 | virtual auto baz(bool, bool) -> int = 0; 61 | }; 62 | 63 | } // namespace v2 64 | } // namespace example 65 | 66 | int main() { 67 | std::cout << "version 1: " << std::hex 68 | << example::v1::operations::revision_id() << std::endl; 69 | std::cout << "version 2: " << std::hex 70 | << example::v2::operations::revision_id() << std::endl; 71 | std::cout << "current: " << std::hex << example::operations::revision_id() 72 | << std::endl; 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /example/mirror/invoke.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/invoke.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | //------------------------------------------------------------------------------ 11 | class myclass { 12 | public: 13 | constexpr myclass() noexcept = default; 14 | myclass(int j) noexcept 15 | : _j{j} {} 16 | ~myclass() noexcept = default; 17 | 18 | static void foo() {} 19 | constexpr bool bar() const { 20 | return false; 21 | } 22 | static int baz(int a, int b) noexcept { 23 | return a + b; 24 | } 25 | int operator+(int i) const noexcept { 26 | return _j + i; 27 | } 28 | 29 | private: 30 | int _j{0}; 31 | }; 32 | //------------------------------------------------------------------------------ 33 | int main() { 34 | const myclass x; 35 | const auto mmc = mirror(myclass); 36 | std::cout << get_name(mmc) << std::endl; 37 | 38 | invoke_on(get_element<0>(get_member_functions(mmc)), x); 39 | std::cout << invoke_on(get_element<1>(get_member_functions(mmc)), x) 40 | << std::endl; 41 | std::cout << invoke_on(get_element<2>(get_member_functions(mmc)), x, 5, 5) 42 | << std::endl; 43 | 44 | invoke(get_element<0>(get_member_functions(mmc))); 45 | std::cout << invoke(get_element<1>(get_member_functions(mmc)), x) 46 | << std::endl; 47 | std::cout << invoke(get_element<2>(get_member_functions(mmc)), 21, 21) 48 | << std::endl; 49 | 50 | const auto y = invoke(get_element<1>(get_constructors(mmc)), 4); 51 | 52 | std::cout << invoke(get_element<0>(get_operators(mmc)), y, 3) << std::endl; 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /example/mirror/is_bitfield_enum.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/is_bitfield_enum.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include "testdecl/weekday.hpp" 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | int main() { 15 | const auto is_bitfield_enum = 16 | is_sorted(get_enumerators(mirror::_1), [](auto l, auto r) { 17 | if constexpr(has_type_trait(get_type(l))) { 18 | return false; 19 | } else { 20 | auto to_underlying = [](auto e) { 21 | return static_cast>(e); 22 | }; 23 | return to_underlying(get_constant(l)) << 1U == 24 | to_underlying(get_constant(r)); 25 | } 26 | }); 27 | 28 | std::cout << is_bitfield_enum(mirror(example::weekday_bit)) << std::endl; 29 | std::cout << is_bitfield_enum(mirror(example::weekday)) << std::endl; 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /example/mirror/list_structure.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/list_structure.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | struct foo { 16 | int i; 17 | float f; 18 | std::string s; 19 | }; 20 | 21 | struct bar { 22 | long l; 23 | double d; 24 | char c; 25 | bool b; 26 | }; 27 | 28 | int main() { 29 | using mirror::_1; 30 | const auto get_type_name_list = 31 | join(get_data_members(_1), get_full_name(get_type(_1)), ", "); 32 | 33 | std::cout << '{' << get_type_name_list(mirror(foo)) << '}' << std::endl; 34 | std::cout << '{' << get_type_name_list(mirror(bar)) << '}' << std::endl; 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /example/mirror/metaobject_concept.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/metaobject_concept.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | 11 | int main() { 12 | const auto meta_int = mirror(int); 13 | static_assert(mirror::metaobject); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /example/mirror/next_weekday.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/next_weekday.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | 12 | enum class weekdays : int { 13 | monday, 14 | tuesday, 15 | wednesday, 16 | thursday, 17 | friday, 18 | saturday, 19 | sunday 20 | }; 21 | 22 | static weekdays next_day(weekdays d) { 23 | return weekdays((int(d) + 1) % 7); 24 | } 25 | 26 | static void print_next_day(std::string_view n) { 27 | if(auto opt_day{mirror::string_to_enum(n)}) { 28 | std::cout << n << " -> " << mirror::enum_to_string(next_day(*opt_day)) 29 | << std::endl; 30 | } 31 | } 32 | 33 | int main() { 34 | for_each(get_enumerators(mirror(weekdays)), [](auto mo) { 35 | print_next_day(get_name(mo)); 36 | }); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /example/mirror/overload_arity.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/overload_arity.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | struct foo { 14 | int plus(int x) { 15 | return x; 16 | } 17 | int plus(int x, int y) { 18 | return x + y; 19 | } 20 | int plus(int x, int y, int z) { 21 | return x + y + z; 22 | } 23 | int minus(int x) { 24 | return -x; 25 | } 26 | int minus(int x, int y) { 27 | return x - y; 28 | } 29 | }; 30 | 31 | int main() { 32 | using mirror::_1; 33 | const auto highest_arity_overload = find_ranking( 34 | filter(get_member_functions(_1), ctre_match<"plus">(get_name(_1))), 35 | get_size(get_parameters(_1))); 36 | 37 | std::cout << '(' 38 | << join_to_string( 39 | get_parameters(highest_arity_overload(mirror(foo))), 40 | get_display_name(get_type(_1)), 41 | ", ") 42 | << ')' << std::endl; 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /example/mirror/people.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE person ( 2 | person_id integer primary key autoincrement, 3 | given_name varchar, 4 | family_name varchar, 5 | email_address varchar); 6 | 7 | INSERT INTO person (given_name, family_name, email_address) 8 | VALUES("Matúš", "Chochlík", "user@example.com"); 9 | -------------------------------------------------------------------------------- /example/mirror/print_enumerators.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/print_enumerators.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include "testdecl/weekday.hpp" 9 | #include 10 | #include 11 | #include 12 | 13 | int main() { 14 | for_each(get_enumerators(mirror(example::weekday)), [](auto mo) { 15 | std::cout << get_name(mo) << ": " << int(get_constant(mo)) << std::endl; 16 | }); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /example/mirror/print_full_name.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/print_full_name.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | 11 | namespace calendar { 12 | 13 | enum class weekday : int { 14 | monday = 1, 15 | tuesday, 16 | wednesday, 17 | thursday, 18 | friday, 19 | saturday, 20 | sunday 21 | }; 22 | 23 | struct event { 24 | weekday get_day() const { 25 | return _day; 26 | } 27 | 28 | void set_time(int hour, int minute) noexcept { 29 | _hour = hour; 30 | _minute = minute; 31 | } 32 | 33 | weekday _day{weekday::monday}; 34 | int _hour{0}; 35 | int _minute{0}; 36 | }; 37 | 38 | } // namespace calendar 39 | 40 | int main() { 41 | std::cout << get_full_name(mirror(calendar::weekday)) << std::endl; 42 | std::cout << get_full_name(mirror(calendar::weekday::monday)) << std::endl; 43 | std::cout << get_full_name(mirror(int)) << std::endl; 44 | std::cout << get_full_name(mirror(int&)) << std::endl; 45 | std::cout << get_full_name(mirror(int**)) << std::endl; 46 | std::cout << get_full_name(mirror(int volatile* const*)) << std::endl; 47 | std::cout << get_full_name(mirror(int*[][1][2][3])) << std::endl; 48 | std::cout << get_full_name(mirror(const std::string&)) << std::endl; 49 | std::cout << get_full_name(mirror(int(float, bool) noexcept)) << std::endl; 50 | 51 | using F1 = void(); 52 | std::cout << get_full_name(mirror(F1)) << std::endl; 53 | 54 | using F2 = F1*(bool) noexcept; 55 | std::cout << get_full_name(mirror(F2)) << std::endl; 56 | 57 | using F3 = F2*(int&, float volatile* const*); 58 | std::cout << get_full_name(mirror(F3)) << std::endl; 59 | 60 | using M1 = decltype(&calendar::event::get_day); 61 | std::cout << get_full_name(mirror(M1)) << std::endl; 62 | 63 | using F4 = M1*(std::string); 64 | std::cout << get_full_name(mirror(F4*)) << std::endl; 65 | 66 | using M2 = decltype(&calendar::event::set_time); 67 | std::cout << get_full_name(mirror(M2)) << std::endl; 68 | 69 | using F5 = M2(calendar::event) noexcept; 70 | std::cout << get_full_name(mirror(F5*)) << std::endl; 71 | 72 | using A1 = decltype(&calendar::event::_day); 73 | std::cout << get_full_name(mirror(A1)) << std::endl; 74 | 75 | using F6 = A1(float); 76 | std::cout << get_full_name(mirror(F6*)) << std::endl; 77 | 78 | return 0; 79 | } 80 | -------------------------------------------------------------------------------- /example/mirror/print_months.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/print_months.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include "testdecl/month.hpp" 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | int main() { 15 | const auto info = make_array( 16 | get_enumerators(mirror(example::month)), 17 | [](auto me) { return std::make_tuple(get_constant(me), get_name(me)); }); 18 | for(const auto& [value, name] : info) { 19 | std::cout << std::setw(2) << int(value) << ": " << name << std::endl; 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /example/mirror/print_op_results.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/print_op_results.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | static void do_print_value(std::string_view value) { 19 | std::cout << std::quoted(value); 20 | } 21 | 22 | static void do_print_value(bool value) { 23 | std::cout << std::boolalpha << value; 24 | } 25 | 26 | static void do_print_value(std::integral auto value) { 27 | std::cout << value; 28 | } 29 | 30 | static void print_value(mirror::metaobject auto value) { 31 | if(reflects_object(value)) { 32 | std::cout << "metaobject(" << get_id(value) << ")"; 33 | } else { 34 | std::cout << "no_metaobject"; 35 | } 36 | } 37 | 38 | static void print_value(auto opt_value) { 39 | using mirror::has_value; 40 | if(has_value(opt_value)) { 41 | using mirror::extract; 42 | do_print_value(extract(opt_value)); 43 | } else { 44 | std::cout << "N/A"; 45 | } 46 | } 47 | 48 | void print_info(mirror::metaobject auto mo) { 49 | const auto mes = flatten(transform( 50 | mirror::all_metaobject_operation_kinds(), get_enumerators(mirror::_1))); 51 | 52 | const auto maxl = apply_to_init_list( 53 | mes, get_size(get_name(mirror::_1)), [](auto l) { return std::max(l); }); 54 | 55 | std::cout << "meta-info for " << get_display_name(mo) << std::endl; 56 | for_each(mes, [&](mirror::metaobject auto me) { 57 | std::cout << " " << get_name(me) << ": " 58 | << std::string(maxl - get_name(me).size(), ' '); 59 | print_value(try_apply(mo)); 60 | std::cout << std::endl; 61 | }); 62 | std::cout << std::endl; 63 | } 64 | 65 | int main(int argc, const char**) { 66 | print_info(mirror(int)); 67 | print_info(mirror(std)); 68 | print_info(mirror(std::string)); 69 | print_info(mirror(argc)); 70 | return argc - 1; 71 | } 72 | -------------------------------------------------------------------------------- /example/mirror/print_struct.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/print_struct.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | 11 | template 12 | void print_struct(const S& x) { 13 | std::cout << get_name(get_aliased(mirror(S))); 14 | std::cout << '('; 15 | for_each_info( 16 | get_data_members(get_aliased(mirror(S))), [&](auto mo, auto info) { 17 | if(!info.is_first()) { 18 | std::cout << ", "; 19 | } 20 | std::cout << get_name(mo) << ": " << get_value(mo, x); 21 | }); 22 | std::cout << ')' << std::endl; 23 | } 24 | 25 | struct mystruct { 26 | std::string s{"str"}; 27 | float f{1.2F}; 28 | int i{345}; 29 | bool b{false}; 30 | }; 31 | 32 | int main() { 33 | mystruct x; 34 | print_struct(x); 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /example/mirror/print_traits.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/print_traits.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include "testdecl/weekday.hpp" 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | void print_traits(mirror::metaobject auto mo) { 18 | const auto mes = get_enumerators(mirror(mirror::meta_trait)); 19 | const auto maxl = get_top_value(mes, get_size(get_name(mirror::_1))); 20 | 21 | std::cout << "traits of " << get_display_name(mo) << std::endl; 22 | for_each(mes, [&](mirror::metaobject auto me) { 23 | std::cout << " " << get_name(me) << ": " << std::boolalpha 24 | << std::string(maxl - get_name(me).size(), ' ') 25 | << has_trait(mo) << std::endl; 26 | }); 27 | std::cout << std::endl; 28 | } 29 | 30 | int main(int argc, const char**) { 31 | print_traits(mirror(int)); 32 | print_traits(mirror(std)); 33 | print_traits(mirror(std::string)); 34 | print_traits(mirror(argc)); 35 | print_traits(mirror(example::weekday)); 36 | print_traits(mirror(example::weekday::friday)); 37 | return argc - 1; 38 | } 39 | -------------------------------------------------------------------------------- /example/mirror/puml_class_diagram.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/puml_class_diagram.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #include "testdecl/cards.hpp" 10 | #include 11 | #include 12 | #include 13 | 14 | int main() { 15 | mirror::metadata_registry r; 16 | example::register_cards(r); 17 | const auto& md_cards = r.find(mirror(example::cards)); 18 | 19 | mirror::puml_class_diagram puml; 20 | puml.generate(std::cout, r.filtered([&](const auto& md) { 21 | return md.scope() == md_cards; 22 | })); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /example/mirror/remove_if.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/remove_if.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include "testdecl/tetrahedron.hpp" 9 | #include 10 | #include 11 | #include 12 | 13 | int main() { 14 | for_each( 15 | make_sequence( 16 | mirror(example::vector), 17 | mirror(example::triangle), 18 | mirror(example::tetrahedron)), 19 | [](mirror::metaobject auto mo) { 20 | std::cout << "non-static member functions: "; 21 | std::cout << join_to_string( 22 | remove_if(get_member_functions(mo), is_static(mirror::_1)), 23 | get_name(mirror::_1), 24 | "; "); 25 | std::cout << std::endl; 26 | }); 27 | 28 | for_each( 29 | make_sequence( 30 | mirror(example::vector), 31 | mirror(example::triangle), 32 | mirror(example::tetrahedron)), 33 | [](mirror::metaobject auto mo) { 34 | std::cout << "count of constructors with parameters: "; 35 | std::cout << get_size(remove_if( 36 | get_constructors(mo), is_empty(get_parameters(mirror::_1)))); 37 | std::cout << std::endl; 38 | }); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /example/mirror/repeat_message_args.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/repeat_message_args.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | struct options { 16 | std::string message{"Hello world!"}; 17 | std::chrono::milliseconds interval{500}; 18 | int count{3}; 19 | }; 20 | 21 | template 22 | static auto parse(T& opts, const mirror::program_args& args) -> bool { 23 | bool parsed = true; 24 | const auto mo = mirror(T); 25 | for(const auto& arg : args) { 26 | for_each(get_data_members(mo), [&](auto mdm) { 27 | if(arg.is_long_tag(get_name(mdm))) { 28 | if(const auto opt{mirror::from_string( 29 | arg.next(), get_reflected_type(get_type(mdm)))}; 30 | mirror::has_value(opt)) { 31 | get_reference(mdm, opts) = mirror::extract(opt); 32 | } else { 33 | std::cerr << "invalid value '" << arg.next() 34 | << "' for option " << arg << "!" << std::endl; 35 | parsed = false; 36 | } 37 | } 38 | }); 39 | } 40 | return parsed; 41 | } 42 | 43 | int main(int argc, const char** argv) { 44 | const mirror::program_args args{argc, argv}; 45 | options opts; 46 | if(parse(opts, args)) { 47 | for(int i : std::ranges::views::iota(1, opts.count + 1)) { 48 | std::cout << i << ": " << opts.message << std::endl; 49 | std::this_thread::sleep_for(opts.interval); 50 | } 51 | return 0; 52 | } else { 53 | return 1; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /example/mirror/repeat_message_json.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/repeat_message_json.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | struct options { 17 | std::string message{"Hello world!"}; 18 | std::optional interval{500}; 19 | int count{3}; 20 | }; 21 | 22 | static auto parse(options& opts, std::istream& cfg_in) -> bool { 23 | const auto errors = mirror::serialize::read_rapidjson_stream(opts, cfg_in); 24 | return !errors; 25 | } 26 | 27 | static std::string fake_config_file() { 28 | return {R"({ 29 | "message": "Hello reflection!", 30 | "interval": [], 31 | "count": 4 32 | })"}; 33 | } 34 | 35 | int main() { 36 | options opts; 37 | std::stringstream cfg_in{fake_config_file()}; 38 | if(parse(opts, cfg_in)) { 39 | for(int i : std::ranges::views::iota(1, opts.count + 1)) { 40 | std::cout << i << ": " << opts.message << std::endl; 41 | if(opts.interval) { 42 | std::this_thread::sleep_for(*opts.interval); 43 | } 44 | } 45 | return 0; 46 | } else { 47 | return 1; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /example/mirror/same_structure.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/same_structure.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | struct foo { 16 | int i; 17 | float f; 18 | std::string s; 19 | }; 20 | 21 | struct bar { 22 | int j; 23 | float e; 24 | std::string z; 25 | }; 26 | 27 | struct baz { 28 | long l; 29 | double d; 30 | char c; 31 | bool b; 32 | }; 33 | 34 | int main() { 35 | using mirror::metaobject; 36 | auto have_same_structure = [](metaobject auto ml, metaobject auto mr) { 37 | using mirror::_1; 38 | const auto structure_hash = 39 | fold(get_data_members(_1), get_hash(get_type(_1)), [](auto... h) { 40 | return (... ^ h); 41 | }); 42 | return structure_hash(ml) == structure_hash(mr); 43 | }; 44 | 45 | std::cout << std::boolalpha << have_same_structure(mirror(foo), mirror(bar)) 46 | << std::endl; 47 | std::cout << std::boolalpha << have_same_structure(mirror(foo), mirror(baz)) 48 | << std::endl; 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /example/mirror/sort_by.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/sort_by.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | struct my_interface : mirror::interface { 14 | virtual auto foo(int i, int j) -> int = 0; 15 | 16 | auto foo(int i) { 17 | return foo(i, 1); 18 | } 19 | 20 | auto foo() { 21 | return foo(1, 2); 22 | } 23 | 24 | virtual auto bar(int i, int j) -> int = 0; 25 | 26 | auto bar(int j) { 27 | return bar(1, j); 28 | } 29 | 30 | static auto name() { 31 | return get_name(mirror(my_interface)); 32 | } 33 | }; 34 | 35 | int main() { 36 | using mirror::_1; 37 | 38 | const auto print_name = [](auto mo) { 39 | std::cout << get_name(mo) << "\n"; 40 | }; 41 | 42 | const auto mfs = get_member_functions(mirror(my_interface)); 43 | 44 | auto [non_static, static_] = group_and_sort_by(mfs, is_static(_1)); 45 | 46 | std::cout << "\nstatic functions:\n"; 47 | for_each(static_, print_name); 48 | 49 | std::cout << "\nnon static functions:\n"; 50 | for_each(non_static, print_name); 51 | 52 | auto [non_virtual, virtual_] = 53 | sort_by(group_by(mfs, is_virtual(_1)), is_virtual(get_front(_1))); 54 | 55 | std::cout << "\nvirtual functions:\n"; 56 | for_each(virtual_, print_name); 57 | 58 | std::cout << "\nnon virtual functions:\n"; 59 | for_each(non_virtual, print_name); 60 | 61 | std::cout << "\noverload sets:\n"; 62 | for_each(sort_by(group_by(mfs, get_name(_1)), get_size(_1)), [&](auto mo) { 63 | std::cout << get_name(get_front(mo)) << ": (" << get_size(mo) << ")\n"; 64 | }); 65 | 66 | std::cout << "\nfunctions with most parameters:\n"; 67 | for_each( 68 | sort_by( 69 | get_front(reverse_group_and_sort_by(mfs, get_size(get_parameters(_1)))), 70 | get_name(_1)), 71 | print_name); 72 | 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /example/mirror/testdecl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | 7 | add_library( 8 | mirror-testdecl STATIC 9 | register_month 10 | register_weekday 11 | register_tetrahedron 12 | register_cards 13 | ) 14 | 15 | target_link_libraries( 16 | mirror-testdecl 17 | PUBLIC Mirror 18 | ) 19 | 20 | set_target_properties( 21 | mirror-testdecl 22 | PROPERTIES 23 | FOLDER "Example/Mirror" 24 | ) 25 | 26 | -------------------------------------------------------------------------------- /example/mirror/testdecl/month.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_TESTDECL_MONTH_HPP 10 | #define MIRROR_TESTDECL_MONTH_HPP 11 | 12 | #include 13 | 14 | namespace example { 15 | 16 | enum class month : int { 17 | january = 1, 18 | february, 19 | march, 20 | april, 21 | may, 22 | june, 23 | july, 24 | august, 25 | september, 26 | october, 27 | november, 28 | december 29 | }; 30 | 31 | void register_month(mirror::metadata_registry&); 32 | 33 | } // namespace example 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /example/mirror/testdecl/register_cards.cpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #include "cards.hpp" 10 | #include 11 | 12 | namespace example { 13 | 14 | void register_cards(mirror::metadata_registry& r) { 15 | r.add(mirror(cards)); 16 | r.add(mirror(cards::rank)); 17 | r.add(mirror(cards::suit)); 18 | r.add(mirror(cards::card)); 19 | r.add(mirror(cards::deck)); 20 | r.add(mirror(cards::player)); 21 | r.add(mirror(cards::dealer)); 22 | r.add(mirror(cards::game)); 23 | } 24 | 25 | } // namespace example 26 | 27 | -------------------------------------------------------------------------------- /example/mirror/testdecl/register_month.cpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #include "month.hpp" 10 | #include 11 | 12 | namespace example { 13 | 14 | void register_month(mirror::metadata_registry& r) { 15 | r.add(mirror(month)); 16 | } 17 | 18 | } // namespace example 19 | 20 | -------------------------------------------------------------------------------- /example/mirror/testdecl/register_tetrahedron.cpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #include "tetrahedron.hpp" 10 | #include 11 | 12 | namespace example { 13 | 14 | void register_tetrahedron(mirror::metadata_registry& r) { 15 | r.add(mirror(point)); 16 | r.add(mirror(vector)); 17 | r.add(mirror(triangle)); 18 | r.add(mirror(tetrahedron)); 19 | } 20 | 21 | } // namespace example 22 | 23 | -------------------------------------------------------------------------------- /example/mirror/testdecl/register_weekday.cpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #include "weekday.hpp" 10 | #include 11 | 12 | namespace example { 13 | 14 | void register_weekday(mirror::metadata_registry& r) { 15 | r.add(mirror(weekday)); 16 | } 17 | 18 | } // namespace example 19 | 20 | -------------------------------------------------------------------------------- /example/mirror/testdecl/weekday.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_TESTDECL_WEEKDAY_HPP 10 | #define MIRROR_TESTDECL_WEEKDAY_HPP 11 | 12 | #include 13 | #include 14 | 15 | namespace example { 16 | 17 | enum class weekday : int { 18 | monday = 1, 19 | tuesday, 20 | wednesday, 21 | thursday, 22 | friday, 23 | saturday, 24 | sunday 25 | }; 26 | 27 | enum class weekday_bit : std::uint8_t { 28 | monday = 0x1, 29 | tuesday = 0x2, 30 | wednesday = 0x4, 31 | thursday = 0x8, 32 | friday = 0x10, 33 | saturday = 0x20, 34 | sunday = 0x40 35 | }; 36 | 37 | void register_weekday(mirror::metadata_registry&); 38 | 39 | } // namespace example 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /example/mirror/to_json_string.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/to_json_string.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include "testdecl/tetrahedron.hpp" 9 | #include "testdecl/weekday.hpp" 10 | #include 11 | #include 12 | #include 13 | 14 | template 15 | void print_json(const T& value) { 16 | using mirror::extract; 17 | using mirror::has_value; 18 | using mirror::serialize::to_json_string; 19 | if(const auto str{to_json_string(value)}; has_value(str)) { 20 | std::cout << extract(str) << std::endl; 21 | } 22 | } 23 | 24 | int main() { 25 | print_json(true); 26 | print_json(mirror::tribool{mirror::indeterminate}); 27 | print_json(1234567890L); 28 | print_json(123.456F); 29 | print_json(456.789); 30 | print_json("mirror"); 31 | print_json(std::string("foo")); 32 | print_json(std::optional{}); 33 | print_json(std::optional{example::weekday::friday}); 34 | print_json(std::array{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}}); 35 | print_json(std::array{{"foo", "bar", "baz", "qux"}}); 36 | print_json(std::vector{ 37 | example::weekday::monday, 38 | example::weekday::tuesday, 39 | example::weekday::wednesday, 40 | example::weekday::thursday, 41 | example::weekday::friday, 42 | example::weekday::saturday, 43 | example::weekday::sunday}); 44 | print_json(example::tetrahedron{ 45 | {{1.F, 0.F, 0.F}, {0.F, 1.F, 0.F}, {0.F, 0.F, 1.F}}, {0.F}}); 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /example/mirror/to_rapidjson.cpp: -------------------------------------------------------------------------------- 1 | /// @example mirror/to_rapidjson.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include "testdecl/tetrahedron.hpp" 9 | #include "testdecl/weekday.hpp" 10 | #include 11 | #include 12 | 13 | template 14 | void print_json(const T& value) { 15 | rapidjson::Document doc; 16 | mirror::serialize::write_rapidjson(value, doc); 17 | 18 | rapidjson::OStreamWrapper stream(std::cout); 19 | rapidjson::Writer writer(stream); 20 | doc.Accept(writer); 21 | std::cout << std::endl; 22 | } 23 | 24 | int main() { 25 | print_json(true); 26 | print_json(mirror::tribool{mirror::indeterminate}); 27 | print_json(1234567890L); 28 | print_json(123.456F); 29 | print_json(456.789); 30 | print_json("mirror"); 31 | print_json(std::string("foo")); 32 | print_json(std::optional{}); 33 | print_json(std::optional{example::weekday::friday}); 34 | print_json(std::array{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}}); 35 | print_json(std::array{{"foo", "bar", "baz", "qux"}}); 36 | print_json(std::vector{ 37 | example::weekday::monday, 38 | example::weekday::tuesday, 39 | example::weekday::wednesday, 40 | example::weekday::thursday, 41 | example::weekday::friday, 42 | example::weekday::saturday, 43 | example::weekday::sunday}); 44 | print_json(example::tetrahedron{ 45 | {{1.F, 0.F, 0.F}, {0.F, 1.F, 0.F}, {0.F, 0.F, 1.F}}, {0.F}}); 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /example/reflexpr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | include(Example.cmake) 7 | 8 | reflexpr_add_simple_example(dependency_injection) 9 | reflexpr_add_simple_example(enum_to_string) 10 | reflexpr_add_simple_example(enum_to_string_map) 11 | reflexpr_add_simple_example(named_parameters) 12 | reflexpr_add_simple_example(string_to_enum) 13 | -------------------------------------------------------------------------------- /example/reflexpr/Example.cmake: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | add_custom_target(reflexpr-examples ALL) 7 | set_target_properties( 8 | reflexpr-examples 9 | PROPERTIES FOLDER "Example/ReflectionTS" 10 | ) 11 | 12 | function(reflexpr_install_example TARGET_NAME) 13 | install( 14 | TARGETS ${TARGET_NAME} 15 | DESTINATION share/mirror/example/reflexpr 16 | ) 17 | endfunction() 18 | 19 | function(reflexpr_add_simple_example EXAMPLE_NAME) 20 | add_executable( 21 | reflexpr-${EXAMPLE_NAME} 22 | EXCLUDE_FROM_ALL 23 | "${EXAMPLE_NAME}.cpp" 24 | ) 25 | add_dependencies(reflexpr-examples reflexpr-${EXAMPLE_NAME}) 26 | target_link_libraries( 27 | reflexpr-${EXAMPLE_NAME} 28 | PUBLIC ReflectionTS 29 | ) 30 | 31 | set_target_properties( 32 | reflexpr-${EXAMPLE_NAME} 33 | PROPERTIES 34 | BUILD_RPATH "${MIRROR_LIBCXX_RPATH}" 35 | FOLDER "Example/ReflectionTS" 36 | ) 37 | reflexpr_install_example(reflexpr-${EXAMPLE_NAME}) 38 | endfunction() 39 | -------------------------------------------------------------------------------- /example/reflexpr/enum_to_string.cpp: -------------------------------------------------------------------------------- 1 | /// @example reflexpr/enum_to_string.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | 12 | enum class weekdays { 13 | monday, 14 | tuesday, 15 | wednesday, 16 | thursday, 17 | friday, 18 | saturday, 19 | sunday 20 | }; 21 | 22 | namespace meta = std::experimental::reflect; 23 | 24 | template 25 | struct enum_to_string_helper { 26 | template 27 | static std::string_view find(E e) { 28 | return _do_find(e, MEC{}...); 29 | } 30 | 31 | template 32 | static std::string_view _do_find(E e, ME1, MEs... mes) { 33 | if(meta::get_constant_v == e) { 34 | return {meta::get_name_v}; 35 | } 36 | return _do_find(e, mes...); 37 | } 38 | 39 | template 40 | static std::string_view _do_find(E) { 41 | return {}; 42 | } 43 | }; 44 | 45 | template 46 | std::string_view enum_to_string(E e) { 47 | return meta::unpack_sequence_t< 48 | enum_to_string_helper, 49 | meta::get_enumerators_t>::find(e); 50 | } 51 | 52 | int main() { 53 | std::cout << enum_to_string(weekdays::monday) << std::endl; 54 | std::cout << enum_to_string(weekdays::tuesday) << std::endl; 55 | std::cout << enum_to_string(weekdays::wednesday) << std::endl; 56 | std::cout << enum_to_string(weekdays::thursday) << std::endl; 57 | std::cout << enum_to_string(weekdays::friday) << std::endl; 58 | std::cout << enum_to_string(weekdays::saturday) << std::endl; 59 | std::cout << enum_to_string(weekdays::sunday) << std::endl; 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /example/reflexpr/enum_to_string_map.cpp: -------------------------------------------------------------------------------- 1 | /// @example reflexpr/enum_to_string_map.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | enum class weekdays { 14 | monday, 15 | tuesday, 16 | wednesday, 17 | thursday, 18 | friday, 19 | saturday, 20 | sunday 21 | }; 22 | 23 | namespace meta = std::experimental::reflect; 24 | 25 | template 26 | class enum_to_string { 27 | public: 28 | std::string_view operator()(E e) const { 29 | const auto pos = _map.find(e); 30 | if(pos != _map.end()) { 31 | return pos->second; 32 | } 33 | return {}; 34 | } 35 | 36 | private: 37 | template 38 | struct helper { 39 | static auto make_map() { 40 | std::map res; 41 | (..., 42 | res.emplace(meta::get_constant_v, meta::get_name_v)); 43 | return res; 44 | } 45 | }; 46 | 47 | static auto _make_map() { 48 | return meta::unpack_sequence_t< 49 | helper, 50 | meta::get_enumerators_t>::make_map(); 51 | } 52 | const std::map _map{_make_map()}; 53 | }; 54 | 55 | int main() { 56 | const enum_to_string ets; 57 | 58 | std::cout << ets(weekdays::monday) << std::endl; 59 | std::cout << ets(weekdays::tuesday) << std::endl; 60 | std::cout << ets(weekdays::wednesday) << std::endl; 61 | std::cout << ets(weekdays::thursday) << std::endl; 62 | std::cout << ets(weekdays::friday) << std::endl; 63 | std::cout << ets(weekdays::saturday) << std::endl; 64 | std::cout << ets(weekdays::sunday) << std::endl; 65 | 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /example/reflexpr/string_to_enum.cpp: -------------------------------------------------------------------------------- 1 | /// @example reflexpr/string_to_enum.cpp 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | enum class weekdays { 14 | monday = 1, 15 | tuesday, 16 | wednesday, 17 | thursday, 18 | friday, 19 | saturday, 20 | sunday 21 | }; 22 | 23 | namespace meta = std::experimental::reflect; 24 | 25 | template 26 | struct string_to_enum_helper { 27 | template 28 | struct _impl { 29 | static std::optional find(std::string_view n) { 30 | return _do_find(n, MEC{}...); 31 | } 32 | 33 | template 34 | static std::optional _do_find(std::string_view n, ME1, MEs... mes) { 35 | if(std::string_view{meta::get_name_v} == n) { 36 | return {meta::get_constant_v}; 37 | } 38 | return _do_find(n, mes...); 39 | } 40 | 41 | static std::optional _do_find(std::string_view) { 42 | return {}; 43 | } 44 | }; 45 | 46 | static std::optional find(std::string_view n) { 47 | return meta:: 48 | unpack_sequence_t<_impl, meta::get_enumerators_t>::find( 49 | n); 50 | } 51 | }; 52 | 53 | template 54 | static std::optional string_to_enum(std::string_view n) { 55 | return string_to_enum_helper::find(n); 56 | } 57 | 58 | template 59 | void print(std::optional d) { 60 | if(d) { 61 | std::cout << std::underlying_type_t(*d) << std::endl; 62 | } else { 63 | std::cout << "N/A" << std::endl; 64 | } 65 | } 66 | 67 | int main() { 68 | print(string_to_enum("monday")); 69 | print(string_to_enum("tuesday")); 70 | print(string_to_enum("wednesday")); 71 | print(string_to_enum("thursday")); 72 | print(string_to_enum("friday")); 73 | print(string_to_enum("saturday")); 74 | print(string_to_enum("sunday")); 75 | 76 | return 0; 77 | } 78 | -------------------------------------------------------------------------------- /include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | add_custom_target(doc-fixed-headers) 7 | 8 | add_subdirectory(reflexpr) 9 | add_subdirectory(mirror) 10 | -------------------------------------------------------------------------------- /include/mirror/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | add_library(mirror-headers INTERFACE) 7 | 8 | target_include_directories( 9 | mirror-headers 10 | INTERFACE 11 | $ 12 | $ 13 | $ 14 | $ 15 | $ 16 | ) 17 | 18 | target_compile_options( 19 | mirror-headers 20 | INTERFACE 21 | -std=c++2b -stdlib=libc++ 22 | -freflection-ts -freflection-ext 23 | -pedantic -Wall -Werror -Weverything 24 | -Wno-language-extension-token 25 | -Wno-c++98-compat -Wno-c++98-compat-pedantic 26 | -Wno-c++20-compat -Wno-c++2a-extensions 27 | -Wno-padded 28 | -Wno-weak-vtables 29 | -Wno-documentation-unknown-command 30 | ) 31 | 32 | target_link_options( 33 | mirror-headers 34 | INTERFACE -std=c++2b -stdlib=libc++ 35 | ) 36 | 37 | target_link_libraries( 38 | mirror-headers 39 | INTERFACE 40 | Threads::Threads 41 | Mirror::Deps::System 42 | Mirror::Deps::SQLite3 43 | ) 44 | 45 | file(GLOB_RECURSE HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" *.hpp) 46 | 47 | foreach(FILENAME ${HEADERS}) 48 | set_property( 49 | TARGET mirror-headers 50 | APPEND PROPERTY PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME} 51 | ) 52 | endforeach() 53 | -------------------------------------------------------------------------------- /include/mirror/all.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_ALL_HPP 10 | #define MIRROR_ALL_HPP 11 | 12 | #include "enum_utils.hpp" 13 | #include "full_name.hpp" 14 | #include "hash.hpp" 15 | #include "init_list.hpp" 16 | #include "make_array.hpp" 17 | #include "make_tuple.hpp" 18 | #include "operations.hpp" 19 | #include "placeholder.hpp" 20 | #include "program_args.hpp" 21 | #include "sequence.hpp" 22 | #include "traits.hpp" 23 | 24 | #endif // MIRROR_ALL_HPP 25 | 26 | -------------------------------------------------------------------------------- /include/mirror/base_type.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_BASE_TYPE_HPP 10 | #define MIRROR_BASE_TYPE_HPP 11 | 12 | #include "primitives.hpp" 13 | 14 | namespace mirror { 15 | 16 | template 17 | static constexpr auto _mirror_base_type(std::type_identity) { 18 | return remove_all_aliases(mirror(T)); 19 | } 20 | 21 | template 22 | static constexpr auto _mirror_base_type(std::type_identity) { 23 | return _mirror_base_type(std::type_identity{}); 24 | } 25 | 26 | template 27 | static constexpr auto _mirror_base_type(std::type_identity) { 28 | return _mirror_base_type(std::type_identity{}); 29 | } 30 | 31 | template 32 | static constexpr auto _mirror_base_type(std::type_identity) { 33 | return _mirror_base_type(std::type_identity{}); 34 | } 35 | 36 | template 37 | static constexpr auto _mirror_base_type(std::type_identity) { 38 | return _mirror_base_type(std::type_identity{}); 39 | } 40 | 41 | template 42 | static constexpr auto _mirror_base_type(std::type_identity) { 43 | return _mirror_base_type(std::type_identity{}); 44 | } 45 | 46 | template 47 | static constexpr auto _mirror_base_type(std::type_identity) { 48 | return _mirror_base_type(std::type_identity{}); 49 | } 50 | 51 | static constexpr auto 52 | get_base_type(metaobject auto mo) requires(reflects_type(mo)) { 53 | return _mirror_base_type(get_reflected_type(mo)); 54 | } 55 | 56 | } // namespace mirror 57 | 58 | #endif // MIRROR_BASE_TYPE_HPP 59 | 60 | -------------------------------------------------------------------------------- /include/mirror/branch_predict.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | #ifndef MIRROR_BRANCH_PREDICT_HPP 9 | #define MIRROR_BRANCH_PREDICT_HPP 10 | 11 | #if defined __GNUC__ 12 | #define MIRROR_LIKELY(EXPR) __builtin_expect(!!(EXPR), 1) 13 | #else 14 | #define MIRROR_LIKELY(EXPR) (!!(EXPR)) 15 | #endif 16 | 17 | #if defined __GNUC__ 18 | #define MIRROR_UNLIKELY(EXPR) __builtin_expect(!!(EXPR), 0) 19 | #else 20 | #define MIRROR_UNLIKELY(EXPR) (!!(EXPR)) 21 | #endif 22 | 23 | #endif // MIRROR_BRANCH_PREDICT_HPP 24 | -------------------------------------------------------------------------------- /include/mirror/ctre_match.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_CTRE_MATCH_HPP 10 | #define MIRROR_CTRE_MATCH_HPP 11 | 12 | #include "diagnostic.hpp" 13 | #include "placeholder.hpp" 14 | 15 | MIRROR_DIAG_PUSH() 16 | #if defined(__clang__) 17 | MIRROR_DIAG_OFF(class-varargs) 18 | MIRROR_DIAG_OFF(ctad-maybe-unsupported) 19 | MIRROR_DIAG_OFF(newline-eof) 20 | MIRROR_DIAG_OFF(reserved-macro-identifier) 21 | #endif 22 | #include 23 | MIRROR_DIAG_POP() 24 | 25 | namespace mirror { 26 | 27 | template 28 | constexpr auto ctre_match(std::string_view s) noexcept { 29 | return ctre::match(s); 30 | } 31 | 32 | template 33 | constexpr auto ctre_match(placeholder_expr e) noexcept { 34 | return placeholder_expr{[e](auto mo) { 35 | return ctre::match(e(mo)); 36 | }}; 37 | } 38 | 39 | } // namespace mirror 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/mirror/diagnostic.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_DIAGNOSTIC_HPP 10 | #define MIRROR_DIAGNOSTIC_HPP 11 | 12 | #include "preprocessor.hpp" 13 | 14 | #if defined(__clang__) 15 | #define MIRROR_DIAG_PRAGMA(EXPR) MIRROR_PRAGMA(clang diagnostic EXPR) 16 | #elif defined(__GNUC__) 17 | #define MIRROR_DIAG_PRAGMA(EXPR) MIRROR_PRAGMA(GCC diagnostic EXPR) 18 | #endif 19 | 20 | #if defined(__clang__) || defined(__GNUC__) 21 | 22 | #define MIRROR_DIAG_OFF(EXPR) \ 23 | MIRROR_DIAG_PRAGMA(ignored MIRROR_STRINGIFY(MIRROR_JOIN(-W, EXPR))) 24 | 25 | #define MIRROR_DIAG_PUSH() MIRROR_DIAG_PRAGMA(push) 26 | #define MIRROR_DIAG_POP() MIRROR_DIAG_PRAGMA(pop) 27 | 28 | #endif 29 | 30 | #endif // MIRROR_DIAGNOSTIC_HPP 31 | -------------------------------------------------------------------------------- /include/mirror/element_type.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_ELEMENT_TYPE_HPP 10 | #define MIRROR_ELEMENT_TYPE_HPP 11 | 12 | #include "primitives.hpp" 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace mirror { 19 | 20 | template 21 | static constexpr auto _mirror_element_type(std::type_identity) { 22 | return no_metaobject; 23 | } 24 | 25 | template 26 | static constexpr auto _mirror_element_type(std::type_identity) { 27 | return remove_all_aliases(mirror(E)); 28 | } 29 | 30 | template 31 | static constexpr auto _mirror_element_type(std::type_identity) { 32 | return remove_all_aliases(mirror(E)); 33 | } 34 | 35 | template 36 | static constexpr auto 37 | _mirror_element_type(std::type_identity>) { 38 | return remove_all_aliases(mirror(E)); 39 | } 40 | 41 | template 42 | static constexpr auto _mirror_element_type(std::type_identity>) { 43 | return remove_all_aliases(mirror(E)); 44 | } 45 | 46 | template 47 | static constexpr auto 48 | _mirror_element_type(std::type_identity>) { 49 | return remove_all_aliases(mirror(E)); 50 | } 51 | 52 | template 53 | static constexpr auto 54 | _mirror_element_type(std::type_identity>) { 55 | return remove_all_aliases(mirror(E)); 56 | } 57 | 58 | static constexpr auto 59 | get_element_type(metaobject auto mo) requires(reflects_type(mo)) { 60 | return _mirror_element_type(get_reflected_type(mo)); 61 | } 62 | 63 | } // namespace mirror 64 | 65 | #endif // MIRROR_ELEMENT_TYPE_HPP 66 | 67 | -------------------------------------------------------------------------------- /include/mirror/enum_utils.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_ENUM_UTILS_HPP 10 | #define MIRROR_ENUM_UTILS_HPP 11 | 12 | #include "placeholder.hpp" 13 | #include "primitives.hpp" 14 | #include 15 | 16 | namespace mirror { 17 | 18 | /// @brief Returns the name of the specified enumerator. 19 | /// @ingroup utilities 20 | /// @see string_to_enum 21 | template 22 | auto enum_to_string(E e) noexcept -> string_view { 23 | return choose( 24 | std::string_view{}, 25 | get_enumerators(mirror(E)), 26 | has_value(_1, e), 27 | get_name(_1)); 28 | } 29 | 30 | /// @brief Finds the value of enum type @c E with the specified name. 31 | /// @ingroup utilities 32 | /// @see enum_to_string 33 | template 34 | auto string_to_enum(string_view s) noexcept -> std::optional { 35 | return choose( 36 | std::optional{}, 37 | get_enumerators(mirror(E)), 38 | has_name(_1, s), 39 | get_value(_1)); 40 | } 41 | 42 | } // namespace mirror 43 | 44 | #endif // MIRROR_ENUM_UTILS_HPP 45 | 46 | -------------------------------------------------------------------------------- /include/mirror/interface.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_INTERFACE_HPP 10 | #define MIRROR_INTERFACE_HPP 11 | 12 | namespace mirror { 13 | //------------------------------------------------------------------------------ 14 | /// @brief Base template for abstract interfaces, implements common functionality. 15 | /// @ingroup utilities 16 | /// @see abstract 17 | template 18 | class interface { 19 | public: 20 | /// @brief Not copyable. 21 | constexpr interface(const interface&) = delete; 22 | 23 | /// @brief Not move assignable. 24 | auto operator=(interface&&) = delete; 25 | 26 | /// @brief Not copy assignable. 27 | auto operator=(const interface&) = delete; 28 | 29 | protected: 30 | /// @brief Default constructible by derived. 31 | constexpr interface() noexcept = default; 32 | 33 | /// @brief Move constructible by derived. 34 | constexpr interface(interface&&) noexcept = default; 35 | virtual ~interface() noexcept = default; 36 | }; 37 | //------------------------------------------------------------------------------ 38 | /// @brief Base template for polymorphic classes, implements common functionality. 39 | /// @ingroup utilities 40 | /// @see interface 41 | template 42 | class abstract { 43 | protected: 44 | /// @brief Default constructible by derived. 45 | constexpr abstract() noexcept = default; 46 | 47 | /// @brief Move constructible by derived. 48 | constexpr abstract(abstract&&) noexcept = default; 49 | 50 | /// @brief Copy constructible by derived. 51 | constexpr abstract(const abstract&) noexcept = default; 52 | 53 | /// @brief Move assignable by derived. 54 | auto operator=(abstract&&) noexcept -> abstract& = default; 55 | 56 | /// @brief Copy assignable by derived. 57 | auto operator=(const abstract&) noexcept -> abstract& = default; 58 | virtual ~abstract() noexcept = default; 59 | }; 60 | //------------------------------------------------------------------------------ 61 | } // namespace mirror 62 | 63 | #endif // MIRROR_INTERFACE_HPP 64 | -------------------------------------------------------------------------------- /include/mirror/make_tuple.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_MAKE_TUPLE_HPP 10 | #define MIRROR_MAKE_TUPLE_HPP 11 | 12 | #include "sequence.hpp" 13 | #include 14 | 15 | namespace mirror { 16 | 17 | #if defined(MIRROR_DOXYGEN) 18 | /// @brief Makes a default-initialized tuple from metaobjects reflecting types. 19 | /// @ingroup sequence_operations 20 | /// @see get_reflected_type_t 21 | /// @see make_array 22 | /// @see make_array_of 23 | /// 24 | /// This function un-reflects the types reflected by metaobjects in a sequence 25 | /// and returns a default-initialized instantiation of std::tuple. 26 | constexpr auto make_value_tuple(metaobject_sequence mo); 27 | #else 28 | template <__metaobject_id... M> 29 | constexpr auto make_value_tuple(unpacked_metaobject_sequence) { 30 | return std::tuple< 31 | std::remove_cv_t>...>{}; 32 | } 33 | 34 | template <__metaobject_id M> 35 | constexpr auto make_value_tuple(wrapped_metaobject mo) requires( 36 | __metaobject_is_meta_object_sequence(M)) { 37 | return make_value_tuple(unpack(mo)); 38 | } 39 | #endif 40 | } // namespace mirror 41 | 42 | #endif // MIRROR_MAKE_TUPLE_HPP 43 | 44 | -------------------------------------------------------------------------------- /include/mirror/overload.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_OVERLOAD_HPP 10 | #define MIRROR_OVERLOAD_HPP 11 | 12 | #include 13 | 14 | namespace mirror { 15 | 16 | template 17 | struct overload; 18 | 19 | template 20 | struct overload : Func { 21 | overload(const Func& func) 22 | : Func{func} {} 23 | 24 | overload(Func&& func) 25 | : Func{std::move(func)} {} 26 | 27 | using Func::operator(); 28 | }; 29 | 30 | template 31 | struct overload 32 | : Func 33 | , overload { 34 | template 35 | overload(const Func& func, F&&... funcs) 36 | : Func{func} 37 | , overload{std::forward(funcs)...} {} 38 | 39 | template 40 | overload(Func&& func, F&&... funcs) 41 | : Func{std::move(func)} 42 | , overload{std::forward(funcs)...} {} 43 | 44 | using Func::operator(); 45 | using overload::operator(); 46 | }; 47 | 48 | template 49 | overload(const F&...) -> overload; 50 | 51 | } // namespace mirror 52 | 53 | #endif // MIRROR_OVERLOAD_HPP 54 | -------------------------------------------------------------------------------- /include/mirror/preprocessor.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_PREPROCESSOR_HPP 10 | #define MIRROR_PREPROCESSOR_HPP 11 | 12 | #define MIRROR_STRINGIFY(EXPR) MIRROR_DO_STRINGIFY(EXPR) 13 | #define MIRROR_DO_STRINGIFY(EXPR) #EXPR 14 | 15 | #define MIRROR_JOIN(L, R) MIRROR_DO_JOIN(L, R) 16 | #define MIRROR_DO_JOIN(L, R) MIRROR_DO_JOIN2(L, R) 17 | #define MIRROR_DO_JOIN2(L, R) L##R 18 | 19 | #if defined(__clang__) || defined(__GNUC__) 20 | 21 | #define MIRROR_PRAGMA(x) _Pragma(MIRROR_STRINGIFY(x)) 22 | 23 | #elif defined(_MSC_VER) 24 | 25 | #define MIRROR_PRAGMA(x) __pragma(x) 26 | 27 | #endif 28 | 29 | #endif // MIRROR_PREPROCESSOR_HPP 30 | -------------------------------------------------------------------------------- /include/mirror/rapidjson.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_UTILS_RAPIDJSON_HPP 10 | #define MIRROR_UTILS_RAPIDJSON_HPP 11 | 12 | #include 13 | 14 | MIRROR_DIAG_PUSH() 15 | #if defined(__clang__) 16 | MIRROR_DIAG_OFF(zero-as-null-pointer-constant) 17 | #endif 18 | 19 | #include 20 | 21 | #if defined(__clang__) 22 | MIRROR_DIAG_POP() 23 | #endif 24 | 25 | namespace mirror { 26 | 27 | static inline auto to_rapidjson(std::string_view v) noexcept { 28 | return rapidjson::GenericStringRef( 29 | v.data(), rapidjson::SizeType(v.size())); 30 | } 31 | 32 | static inline auto from_rapidjson(rapidjson::GenericStringRef v) noexcept { 33 | return std::string_view(v.s, static_cast(v.length)); 34 | } 35 | 36 | } // namespace mirror 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /include/mirror/registry_fwd.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_REGISTRY_FWD_HPP 10 | #define MIRROR_REGISTRY_FWD_HPP 11 | 12 | namespace mirror { 13 | 14 | class metadata; 15 | class metadata_registry; 16 | 17 | } // namespace mirror 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/mirror/serialize/read_backend.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_SERIALIZE_READ_BACKEND_HPP 10 | #define MIRROR_SERIALIZE_READ_BACKEND_HPP 11 | 12 | #include "../extract.hpp" 13 | #include "result.hpp" 14 | #include 15 | 16 | namespace mirror::serialize { 17 | struct read_driver; 18 | 19 | template 20 | concept read_backend = requires(T v) { 21 | { v.enum_as_string(std::declval()) } 22 | ->std::convertible_to; 23 | 24 | { v.begin(std::declval()) } 25 | ->extractable; 26 | 27 | { 28 | v.read( 29 | std::declval(), 30 | std::declval(), 31 | std::declval()) 32 | } 33 | ->std::same_as; 34 | 35 | { 36 | v.begin_list( 37 | std::declval(), std::declval()) 38 | } 39 | ->extractable; 40 | 41 | { 42 | v.begin_element( 43 | std::declval(), std::declval()) 44 | } 45 | ->extractable; 46 | 47 | { v.separate_element(std::declval()) } 48 | ->std::same_as; 49 | 50 | { 51 | v.finish_element( 52 | std::declval(), std::declval()) 53 | } 54 | ->std::same_as; 55 | 56 | { v.finish_list(std::declval()) } 57 | ->std::same_as; 58 | 59 | { 60 | v.begin_record( 61 | std::declval(), std::declval()) 62 | } 63 | ->extractable; 64 | 65 | { 66 | v.begin_attribute( 67 | std::declval(), 68 | std::declval()) 69 | } 70 | ->extractable; 71 | 72 | { v.separate_attribute(std::declval()) } 73 | ->std::same_as; 74 | 75 | { 76 | v.finish_attribute( 77 | std::declval(), 78 | std::declval()) 79 | } 80 | ->std::same_as; 81 | 82 | { v.finish_record(std::declval()) } 83 | ->std::same_as; 84 | 85 | { v.finish(std::declval()) } 86 | ->std::same_as; 87 | }; 88 | 89 | }; // namespace mirror::serialize 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /include/mirror/serialize/write_backend.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_SERIALIZE_WRITE_BACKEND_HPP 10 | #define MIRROR_SERIALIZE_WRITE_BACKEND_HPP 11 | 12 | #include "../extract.hpp" 13 | #include "result.hpp" 14 | #include 15 | 16 | namespace mirror::serialize { 17 | struct write_driver; 18 | 19 | template 20 | concept write_backend = requires(T v) { 21 | { v.enum_as_string(std::declval()) } 22 | ->std::convertible_to; 23 | 24 | { v.begin(std::declval()) } 25 | ->extractable; 26 | 27 | { 28 | v.write( 29 | std::declval(), 30 | std::declval(), 31 | std::declval()) 32 | } 33 | ->std::same_as; 34 | 35 | { 36 | v.begin_list( 37 | std::declval(), std::declval()) 38 | } 39 | ->extractable; 40 | 41 | { 42 | v.begin_element( 43 | std::declval(), std::declval()) 44 | } 45 | ->extractable; 46 | 47 | { v.separate_element(std::declval()) } 48 | ->std::same_as; 49 | 50 | { 51 | v.finish_element( 52 | std::declval(), std::declval()) 53 | } 54 | ->std::same_as; 55 | 56 | { v.finish_list(std::declval()) } 57 | ->std::same_as; 58 | 59 | { 60 | v.begin_record( 61 | std::declval(), std::declval()) 62 | } 63 | ->extractable; 64 | 65 | { 66 | v.begin_attribute( 67 | std::declval(), 68 | std::declval()) 69 | } 70 | ->extractable; 71 | 72 | { v.separate_attribute(std::declval()) } 73 | ->std::same_as; 74 | 75 | { 76 | v.finish_attribute( 77 | std::declval(), 78 | std::declval()) 79 | } 80 | ->std::same_as; 81 | 82 | { v.finish_record(std::declval()) } 83 | ->std::same_as; 84 | 85 | { v.finish(std::declval()) } 86 | ->std::same_as; 87 | }; 88 | 89 | } // namespace mirror::serialize 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /include/mirror/serialize/write_json.hpp: -------------------------------------------------------------------------------- 1 | /// @file 2 | /// 3 | /// Copyright Matus Chochlik. 4 | /// Distributed under the Boost Software License, Version 1.0. 5 | /// See accompanying file LICENSE_1_0.txt or copy at 6 | /// http://www.boost.org/LICENSE_1_0.txt 7 | /// 8 | 9 | #ifndef MIRROR_SERIALIZE_WRITE_JSON_HPP 10 | #define MIRROR_SERIALIZE_WRITE_JSON_HPP 11 | 12 | #include "write_rapidjson.hpp" 13 | 14 | namespace mirror::serialize { 15 | //------------------------------------------------------------------------------ 16 | template 17 | auto write_json_stream(const T& value, std::ostream& out) -> write_errors { 18 | return write_rapidjson_stream(value, out); 19 | } 20 | //------------------------------------------------------------------------------ 21 | template 22 | auto write_json_string(const T& value, std::string& str) -> write_errors { 23 | return write_rapidjson_string(value, str); 24 | } 25 | //------------------------------------------------------------------------------ 26 | template 27 | auto to_json_string(const T& value) -> std::variant { 28 | std::string str; 29 | if(const auto errors{write_json_string(value, str)}) { 30 | return {errors}; 31 | } 32 | return {str}; 33 | } 34 | //------------------------------------------------------------------------------ 35 | } // namespace mirror::serialize 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /include/reflexpr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | add_library(reflexpr-headers INTERFACE) 7 | 8 | target_include_directories( 9 | reflexpr-headers 10 | INTERFACE 11 | $ 12 | $ 13 | ) 14 | 15 | target_compile_options( 16 | reflexpr-headers 17 | INTERFACE 18 | -std=c++2b -stdlib=libc++ 19 | -freflection-ts -freflection-ext 20 | -pedantic -Wall -Werror -Weverything 21 | -Wno-language-extension-token 22 | -Wno-c++98-compat -Wno-c++98-compat-pedantic 23 | -Wno-c++20-compat -Wno-c++2a-extensions 24 | -Wno-padded 25 | -Wno-documentation-unknown-command 26 | ) 27 | 28 | target_link_options( 29 | reflexpr-headers 30 | INTERFACE -std=c++20 -stdlib=libc++ 31 | ) 32 | -------------------------------------------------------------------------------- /source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | add_library(ReflectionTS INTERFACE IMPORTED GLOBAL) 7 | target_link_libraries(ReflectionTS INTERFACE reflexpr-headers) 8 | 9 | add_library(Mirror INTERFACE IMPORTED GLOBAL) 10 | target_link_libraries(Mirror INTERFACE mirror-headers) 11 | 12 | set( 13 | MIRROR_EXPORT_TARGETS 14 | mirror-headers 15 | ) 16 | 17 | install( 18 | TARGETS ${MIRROR_EXPORT_TARGETS} 19 | EXPORT Reflection 20 | LIBRARY DESTINATION lib 21 | ARCHIVE DESTINATION lib 22 | RUNTIME DESTINATION bin 23 | INCLUDES DESTINATION include 24 | PUBLIC_HEADER DESTINATION include 25 | ) 26 | 27 | install( 28 | EXPORT Reflection 29 | NAMESPACE Mirror:: 30 | FILE Reflection.cmake 31 | DESTINATION lib/cmake/Mirror 32 | ) 33 | -------------------------------------------------------------------------------- /toolchain.cmake.bak: -------------------------------------------------------------------------------- 1 | # Copyright Matus Chochlik. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt 5 | # 6 | # Copy this file to `toolchain.cmake` and change as necessary. 7 | # Update if the llvm install prefix path is different 8 | set(MIRROR_LLVM_PREFIX /opt/mirror/llvm) 9 | set(CMAKE_BUILD_TYPE Debug) 10 | set(CMAKE_CXX_COMPILER ${MIRROR_LLVM_PREFIX}/bin/clang++) 11 | # set(CMAKE_CXX_COMPILER_LAUNCHER ccache) 12 | # set(CMAKE_EXE_LINKER_FLAGS -fuse-ld=lld) 13 | # set(CMAKE_SHARED_LINKER_FLAGS -fuse-ld=lld) 14 | 15 | -------------------------------------------------------------------------------- /tools/build_llvm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Matus Chochlik. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt 6 | # 7 | tool_dir=$(realpath "$(dirname ${0})") 8 | root_dir=$(dirname "${tool_dir}") 9 | llvm_install_dir=/opt/mirror/llvm 10 | llvm_build_dir="${tool_dir}/_build" 11 | compile_jobs=$(grep -c -e 'processor\s\+:\s\+[0-9]\+' < /proc/cpuinfo) 12 | link_jobs=$(grep MemTotal /proc/meminfo | awk '{printf "%.0f", $2/(1024*1024*6)}') 13 | clean="false" 14 | 15 | if [[ -x "$(which distcc)" ]] 16 | then compile_jobs="$(distcc -j)" 17 | fi 18 | 19 | if [[ -f "${root_dir}/LLVM_PREFIX" ]] 20 | then llvm_install_dir=$(< "${root_dir}/LLVM_PREFIX") 21 | fi 22 | 23 | while getopts "b:i:C:L:c" arg 24 | do 25 | case ${arg} in 26 | b) llvm_build_dir=${OPTARG};; 27 | i) llvm_install_dir=${OPTARG};; 28 | C) compile_jobs=${OPTARG};; 29 | L) link_jobs=${OPTARG};; 30 | c) clean="true";; 31 | *) exit 1;; 32 | esac 33 | done 34 | 35 | if [[ "x${llvm_build_dir}" == "x" ]] 36 | then echo "invalid build directory path '${llvm_build_dir}'"; exit 2 37 | fi 38 | 39 | if [[ "x${clean}" == "xtrue" ]] 40 | then rm -rf "${llvm_build_dir}/*" 41 | fi 42 | 43 | cmake_args=() 44 | cmake_args+=(-G Ninja) 45 | cmake_args+=(-DCMAKE_INSTALL_PREFIX="${llvm_install_dir}") 46 | if [[ -f "${tool_dir}/toolchain.cmake" ]] 47 | then cmake_args+=(-DCMAKE_TOOLCHAIN_FILE="${tool_dir}/toolchain.cmake") 48 | fi 49 | 50 | ninja_args=(-j ${compile_jobs}) 51 | 52 | mkdir -p "${llvm_build_dir}" && \ 53 | pushd "${llvm_build_dir}" && \ 54 | cmake \ 55 | "${cmake_args[@]}" \ 56 | -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" \ 57 | -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \ 58 | -DLLVM_INCLUDE_BENCHMARKS=Off \ 59 | -DLLVM_PARALLEL_COMPILE_JOBS=${compile_jobs} \ 60 | -DLLVM_PARALLEL_LINK_JOBS=${link_jobs} \ 61 | "${root_dir}/submodules/llvm-project/llvm" && \ 62 | time ninja "${ninja_args[@]}" install install-cxx install-cxxabi && \ 63 | popd 64 | -------------------------------------------------------------------------------- /tools/toolchain.cmake.bak: -------------------------------------------------------------------------------- 1 | # Copy this file to `toolchain.cmake` and change as necessary 2 | set(CMAKE_BUILD_TYPE Release) 3 | set(CMAKE_C_COMPILER clang) 4 | set(CMAKE_CXX_COMPILER clang++) 5 | set(CMAKE_C_COMPILER_LAUNCHER distcc ccache) 6 | set(CMAKE_CXX_COMPILER_LAUNCHER distcc ccache) 7 | set(LLVM_USE_LINKER lld) 8 | set(CMAKE_EXE_LINKER_FLAGS -fuse-ld=${LLVM_USE_LINKER}) 9 | set(CMAKE_SHARED_LINKER_FLAGS -fuse-ld=${LLVM_USE_LINKER}) 10 | 11 | --------------------------------------------------------------------------------