Merge branch 'claude0'
This commit is contained in:
commit
6d30aec8f9
12 changed files with 473 additions and 85 deletions
|
|
@ -75,15 +75,16 @@ set(DOX_EXCLUDE_PATTERNS [=[
|
|||
# in reverse topological order i.e. dependencies first
|
||||
|
||||
add_subdirectory(xo-cmake)
|
||||
add_subdirectory(xo-facet) # sep iface,data
|
||||
add_subdirectory(xo-indentlog)
|
||||
add_subdirectory(xo-reflectutil) # header-only reflect support
|
||||
add_subdirectory(xo-arena) # arena allocator (DArena)
|
||||
add_subdirectory(xo-facet) # sep iface,data
|
||||
add_subdirectory(xo-allocutil)
|
||||
add_subdirectory(xo-refcnt)
|
||||
add_subdirectory(xo-subsys)
|
||||
add_subdirectory(xo-randomgen)
|
||||
add_subdirectory(xo-flatstring)
|
||||
add_subdirectory(xo-pyutil)
|
||||
add_subdirectory(xo-reflectutil)
|
||||
add_subdirectory(xo-reflect)
|
||||
add_subdirectory(xo-pyreflect)
|
||||
add_subdirectory(xo-ratio)
|
||||
|
|
|
|||
41
xo-arena/CMakeLists.txt
Normal file
41
xo-arena/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# xo-arena/CMakeLists.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(xo_arena VERSION 1.0)
|
||||
enable_language(CXX)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(cmake/xo-bootstrap-macros.cmake)
|
||||
|
||||
xo_cxx_toplevel_options3()
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# c++ settings
|
||||
|
||||
# one-time project-specific c++ flags. usually empty
|
||||
set(PROJECT_CXX_FLAGS "")
|
||||
add_definitions(${PROJECT_CXX_FLAGS})
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# output targets
|
||||
|
||||
#add_subdirectory(utest)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# header-only library
|
||||
|
||||
set(SELF_LIB xo_arena)
|
||||
xo_add_headeronly_library(${SELF_LIB})
|
||||
xo_install_library4(${SELF_LIB} ${PROJECT_NAME}Targets)
|
||||
xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# input dependencies
|
||||
#
|
||||
# NOTE: dependency set here must be kept consistent with
|
||||
# xo-arena/cmake/xo_arenaConfig.cmake.in
|
||||
|
||||
#xo_headeronly_dependency(${SELF_LIB} xo_flatstring)
|
||||
|
||||
# end CMakeLists.txt
|
||||
33
xo-arena/cmake/xo-bootstrap-macros.cmake
Normal file
33
xo-arena/cmake/xo-bootstrap-macros.cmake
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# ----------------------------------------------------------------
|
||||
# for example:
|
||||
# $ PREFIX=/usr/local # for example
|
||||
# $ cmake -DCMAKE_MODULE_PATH=prefix -DCMAKE_INSTALL_PREFIX=$PREFIX -B .build
|
||||
#
|
||||
# will get
|
||||
# CMAKE_MODULE_PATH
|
||||
# from xo-cmake-config --cmake-module-path
|
||||
#
|
||||
# and expect .cmake macros in
|
||||
# CMAKE_MODULE_PATH/xo_macros/xo_cxx.cmake
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
find_program(XO_CMAKE_CONFIG_EXECUTABLE NAMES xo-cmake-config REQUIRED)
|
||||
|
||||
if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "prefix"))
|
||||
message(FATAL "could not find xo-cmake-config executable")
|
||||
endif()
|
||||
|
||||
if (NOT XO_SUBMODULE_BUILD)
|
||||
if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix))
|
||||
# default to typical install location for xo-project-macros
|
||||
execute_process(COMMAND ${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH)
|
||||
message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# needs to have been installed somewhere on CMAKE_MODULE_PATH,
|
||||
# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX)
|
||||
#
|
||||
include(xo_macros/xo_cxx)
|
||||
|
||||
xo_cxx_bootstrap_message()
|
||||
12
xo-arena/cmake/xo_arenaConfig.cmake.in
Normal file
12
xo-arena/cmake/xo_arenaConfig.cmake.in
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
@PACKAGE_INIT@
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
# note: changes to find_dependency() calls here
|
||||
# must coordinate with xo_dependency() calls
|
||||
# in CMakeLists.txt
|
||||
#
|
||||
#find_dependency(xo_flatstring)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
||||
check_required_components("@PROJECT_NAME@")
|
||||
0
xo-arena/include/xo/arena/.gitkeep
Normal file
0
xo-arena/include/xo/arena/.gitkeep
Normal file
282
xo-cmake/bin/scaffold-headeronly
Executable file
282
xo-cmake/bin/scaffold-headeronly
Executable file
|
|
@ -0,0 +1,282 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# scaffold-headeronly - Create a new xo library subdirectory
|
||||
#
|
||||
# Usage: scaffold-headeronly [--mode=headeronly|shared] <name>
|
||||
# where <name> is the short name (e.g., "arena" creates "xo-arena")
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [--mode=headeronly|shared] <name>"
|
||||
echo " Creates xo-<name>/ with library scaffolding"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --mode=headeronly Create header-only library (default)"
|
||||
echo " --mode=shared Create shared library with src/ directory"
|
||||
echo ""
|
||||
echo "Example: $0 arena"
|
||||
echo " Creates xo-arena/CMakeLists.txt"
|
||||
echo " xo-arena/cmake/xo-bootstrap-macros.cmake"
|
||||
echo " xo-arena/cmake/xo_arenaConfig.cmake.in"
|
||||
echo " xo-arena/include/xo/arena/"
|
||||
echo ""
|
||||
echo "Example: $0 --mode=shared mylib"
|
||||
echo " Creates xo-mylib/CMakeLists.txt"
|
||||
echo " xo-mylib/cmake/xo-bootstrap-macros.cmake"
|
||||
echo " xo-mylib/cmake/xo_mylibConfig.cmake.in"
|
||||
echo " xo-mylib/include/xo/mylib/"
|
||||
echo " xo-mylib/src/CMakeLists.txt"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Default mode
|
||||
MODE="headeronly"
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--mode=*)
|
||||
MODE="${1#--mode=}"
|
||||
if [[ "$MODE" != "headeronly" && "$MODE" != "shared" ]]; then
|
||||
echo "Error: --mode must be 'headeronly' or 'shared'"
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
usage
|
||||
;;
|
||||
-*)
|
||||
echo "Error: unknown option $1"
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
NAME="$1"
|
||||
|
||||
# Validate name: alphanumeric and underscores only
|
||||
if [[ ! "$NAME" =~ ^[a-zA-Z][a-zA-Z0-9_]*$ ]]; then
|
||||
echo "Error: name must start with letter and contain only alphanumeric/underscores"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Derive names
|
||||
DIR_NAME="xo-${NAME}"
|
||||
LIB_NAME="xo_${NAME}"
|
||||
PROJECT_NAME="xo_${NAME}"
|
||||
|
||||
# Get script directory to find umbrella root
|
||||
XO_UMBRELLA_ROOT=$(git rev-parse --show-toplevel)
|
||||
|
||||
TARGET_DIR="${XO_UMBRELLA_ROOT}/${DIR_NAME}"
|
||||
|
||||
if [[ -d "$TARGET_DIR" ]]; then
|
||||
echo "Error: ${TARGET_DIR} already exists"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Creating ${DIR_NAME} (${MODE}) in ${XO_UMBRELLA_ROOT}..."
|
||||
|
||||
# Create directories
|
||||
mkdir -p "${TARGET_DIR}/cmake"
|
||||
mkdir -p "${TARGET_DIR}/include/xo/${NAME}"
|
||||
|
||||
if [[ "$MODE" == "shared" ]]; then
|
||||
mkdir -p "${TARGET_DIR}/src"
|
||||
fi
|
||||
|
||||
# Create CMakeLists.txt (different content based on mode)
|
||||
if [[ "$MODE" == "headeronly" ]]; then
|
||||
cat > "${TARGET_DIR}/CMakeLists.txt" << EOF
|
||||
# ${DIR_NAME}/CMakeLists.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(${PROJECT_NAME} VERSION 1.0)
|
||||
enable_language(CXX)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(cmake/xo-bootstrap-macros.cmake)
|
||||
|
||||
xo_cxx_toplevel_options3()
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# c++ settings
|
||||
|
||||
# one-time project-specific c++ flags. usually empty
|
||||
set(PROJECT_CXX_FLAGS "")
|
||||
add_definitions(\${PROJECT_CXX_FLAGS})
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# output targets
|
||||
|
||||
#add_subdirectory(utest)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# header-only library
|
||||
|
||||
set(SELF_LIB ${LIB_NAME})
|
||||
xo_add_headeronly_library(\${SELF_LIB})
|
||||
xo_install_library4(\${SELF_LIB} \${PROJECT_NAME}Targets)
|
||||
xo_export_cmake_config(\${PROJECT_NAME} \${PROJECT_VERSION} \${PROJECT_NAME}Targets)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# input dependencies
|
||||
#
|
||||
# NOTE: dependency set here must be kept consistent with
|
||||
# ${DIR_NAME}/cmake/${LIB_NAME}Config.cmake.in
|
||||
|
||||
#xo_headeronly_dependency(\${SELF_LIB} xo_flatstring)
|
||||
|
||||
# end CMakeLists.txt
|
||||
EOF
|
||||
else
|
||||
# Shared library mode
|
||||
cat > "${TARGET_DIR}/CMakeLists.txt" << EOF
|
||||
# ${DIR_NAME}/CMakeLists.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(${PROJECT_NAME} VERSION 1.0)
|
||||
enable_language(CXX)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(cmake/xo-bootstrap-macros.cmake)
|
||||
|
||||
xo_cxx_toplevel_options3()
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# c++ settings
|
||||
|
||||
# one-time project-specific c++ flags. usually empty
|
||||
set(PROJECT_CXX_FLAGS "")
|
||||
add_definitions(\${PROJECT_CXX_FLAGS})
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# output targets
|
||||
|
||||
add_subdirectory(src)
|
||||
#add_subdirectory(utest)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# cmake export
|
||||
|
||||
xo_export_cmake_config(\${PROJECT_NAME} \${PROJECT_VERSION} \${PROJECT_NAME}Targets)
|
||||
|
||||
# end CMakeLists.txt
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Create cmake/xo-bootstrap-macros.cmake
|
||||
cat > "${TARGET_DIR}/cmake/xo-bootstrap-macros.cmake" << EOF
|
||||
# ----------------------------------------------------------------
|
||||
# for example:
|
||||
# $ PREFIX=/usr/local # for example
|
||||
# $ cmake -DCMAKE_MODULE_PATH=prefix -DCMAKE_INSTALL_PREFIX=\$PREFIX -B .build
|
||||
#
|
||||
# will get
|
||||
# CMAKE_MODULE_PATH
|
||||
# from xo-cmake-config --cmake-module-path
|
||||
#
|
||||
# and expect .cmake macros in
|
||||
# CMAKE_MODULE_PATH/xo_macros/xo_cxx.cmake
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
find_program(XO_CMAKE_CONFIG_EXECUTABLE NAMES xo-cmake-config REQUIRED)
|
||||
|
||||
if (("\${CMAKE_MODULE_PATH}" STREQUAL "") OR ("\${CMAKE_MODULE_PATH}" STREQUAL "prefix"))
|
||||
message(FATAL "could not find xo-cmake-config executable")
|
||||
endif()
|
||||
|
||||
if (NOT XO_SUBMODULE_BUILD)
|
||||
if (("\${CMAKE_MODULE_PATH}" STREQUAL "") OR ("\${CMAKE_MODULE_PATH}" STREQUAL prefix))
|
||||
# default to typical install location for xo-project-macros
|
||||
execute_process(COMMAND \${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH)
|
||||
message(STATUS "CMAKE_MODULE_PATH=\${CMAKE_MODULE_PATH}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# needs to have been installed somewhere on CMAKE_MODULE_PATH,
|
||||
# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX)
|
||||
#
|
||||
include(xo_macros/xo_cxx)
|
||||
|
||||
xo_cxx_bootstrap_message()
|
||||
EOF
|
||||
|
||||
# Create cmake/xo_${NAME}Config.cmake.in
|
||||
cat > "${TARGET_DIR}/cmake/${LIB_NAME}Config.cmake.in" << EOF
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
# note: changes to find_dependency() calls here
|
||||
# must coordinate with xo_dependency() calls
|
||||
# in CMakeLists.txt
|
||||
#
|
||||
#find_dependency(xo_flatstring)
|
||||
|
||||
include("\${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
||||
check_required_components("@PROJECT_NAME@")
|
||||
EOF
|
||||
|
||||
# Create src/CMakeLists.txt for shared library mode
|
||||
if [[ "$MODE" == "shared" ]]; then
|
||||
cat > "${TARGET_DIR}/src/CMakeLists.txt" << EOF
|
||||
# ${DIR_NAME}/src/CMakeLists.txt
|
||||
|
||||
set(SELF_LIB ${LIB_NAME})
|
||||
set(SELF_SRCS
|
||||
# Add source files here, e.g.:
|
||||
# ${NAME}.cpp
|
||||
)
|
||||
|
||||
xo_add_shared_library4(\${SELF_LIB} \${PROJECT_NAME}Targets \${PROJECT_VERSION} 1 \${SELF_SRCS})
|
||||
xo_install_include_tree3(include/xo/${NAME})
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# input dependencies
|
||||
#
|
||||
# NOTE: dependency set here must be kept consistent with
|
||||
# ${DIR_NAME}/cmake/${LIB_NAME}Config.cmake.in
|
||||
|
||||
#xo_dependency(\${SELF_LIB} xo_indentlog)
|
||||
|
||||
# end src/CMakeLists.txt
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Create placeholder .gitkeep in include dir
|
||||
touch "${TARGET_DIR}/include/xo/${NAME}/.gitkeep"
|
||||
|
||||
echo ""
|
||||
echo "Created ${DIR_NAME}/ (${MODE}) with:"
|
||||
echo " ${DIR_NAME}/CMakeLists.txt"
|
||||
echo " ${DIR_NAME}/cmake/xo-bootstrap-macros.cmake"
|
||||
echo " ${DIR_NAME}/cmake/${LIB_NAME}Config.cmake.in"
|
||||
echo " ${DIR_NAME}/include/xo/${NAME}/"
|
||||
if [[ "$MODE" == "shared" ]]; then
|
||||
echo " ${DIR_NAME}/src/CMakeLists.txt"
|
||||
fi
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
if [[ "$MODE" == "headeronly" ]]; then
|
||||
echo " 1. Add header files to ${DIR_NAME}/include/xo/${NAME}/"
|
||||
echo " 2. Add ${DIR_NAME} to umbrella CMakeLists.txt"
|
||||
echo " 3. Uncomment dependencies as needed in CMakeLists.txt and Config.cmake.in"
|
||||
else
|
||||
echo " 1. Add header files to ${DIR_NAME}/include/xo/${NAME}/"
|
||||
echo " 2. Add source files to ${DIR_NAME}/src/ and update src/CMakeLists.txt SELF_SRCS"
|
||||
echo " 3. Add ${DIR_NAME} to umbrella CMakeLists.txt"
|
||||
echo " 4. Uncomment dependencies as needed in src/CMakeLists.txt and Config.cmake.in"
|
||||
fi
|
||||
|
|
@ -25,6 +25,10 @@ add_subdirectory(utest)
|
|||
|
||||
set(SELF_LIB xo_facet)
|
||||
xo_add_headeronly_library(${SELF_LIB})
|
||||
|
||||
# note: dependencies here must coordinate with cmake/xo_facetConfig.cmake.in
|
||||
xo_headeronly_dependency(${SELF_LIB} xo_reflectutil)
|
||||
|
||||
xo_install_library4(${SELF_LIB} ${PROJECT_NAME}Targets)
|
||||
xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
@PACKAGE_INIT@
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
#find_dependency(indentlog)
|
||||
#find_dependency(xo_flatstring)
|
||||
# note: dependencies here must coordinate with xo-facet/CMakeLists.txt
|
||||
find_dependency(xo_reflectutil)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
||||
check_required_components("@PROJECT_NAME@")
|
||||
|
|
|
|||
|
|
@ -1,87 +1,19 @@
|
|||
/** @file typeseq.hpp
|
||||
*
|
||||
* @brief Re-export typeseq from xo-arena for backwards compatibility
|
||||
*
|
||||
* @author Roland Conybeare, Dec 2025
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdint>
|
||||
#include <xo/reflectutil/typeseq.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
/**
|
||||
* Tag here so we can preserve header-only implementation
|
||||
* and still have static variable
|
||||
*/
|
||||
template<typename Tag = class typeseq_tag>
|
||||
struct typeseq_impl {
|
||||
explicit typeseq_impl(int32_t s) : seqno_{s} {}
|
||||
|
||||
/** Can't have this be constexpr.
|
||||
* We need ids in shared libraries to be generated
|
||||
* at load time to avoid false positives
|
||||
*
|
||||
* Return unique id number for each type.
|
||||
* Numbers are sequentially allocated, so can use
|
||||
* as vector indices
|
||||
*
|
||||
* Conversely note that built-in typeinfo may
|
||||
* return false negatives across library boundaries
|
||||
* when using clang.
|
||||
**/
|
||||
template <typename T>
|
||||
static typeseq_impl<Tag> id() {
|
||||
static bool armed = true;
|
||||
static int32_t id = 0;
|
||||
|
||||
if (armed) {
|
||||
armed = false;
|
||||
id = ++s_next_id;
|
||||
}
|
||||
|
||||
return typeseq_impl(id);
|
||||
|
||||
}
|
||||
|
||||
/** 'anonymous' sentinel type.
|
||||
* Niche uses for this, e.g. untyped allocator
|
||||
**/
|
||||
static typeseq_impl<Tag> anon() {
|
||||
return typeseq_impl(-1);
|
||||
}
|
||||
|
||||
int32_t seqno() const { return seqno_; }
|
||||
|
||||
private:
|
||||
static int32_t s_next_id;
|
||||
|
||||
int32_t seqno_;
|
||||
};
|
||||
|
||||
template <typename Tag>
|
||||
int32_t typeseq_impl<Tag>::s_next_id = 0;
|
||||
|
||||
template <typename Tag>
|
||||
inline bool
|
||||
operator==(const typeseq_impl<Tag> & lhs, const typeseq_impl<Tag> & rhs) {
|
||||
return lhs.seqno() == rhs.seqno();
|
||||
}
|
||||
|
||||
template <typename Tag>
|
||||
inline bool
|
||||
operator!=(const typeseq_impl<Tag> & lhs, const typeseq_impl<Tag> & rhs) {
|
||||
return lhs.seqno() != rhs.seqno();
|
||||
}
|
||||
|
||||
template <typename Tag>
|
||||
inline std::ostream &
|
||||
operator<<(std::ostream & s, const typeseq_impl<Tag> & x) {
|
||||
s << x.seqno();
|
||||
return s;
|
||||
}
|
||||
|
||||
using typeseq = typeseq_impl<>;
|
||||
// Re-export from xo::arena namespace
|
||||
using xo::reflect::typeseq_impl;
|
||||
using xo::reflect::typeseq;
|
||||
}
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets
|
|||
# ----------------------------------------------------------------
|
||||
# dependencies
|
||||
|
||||
xo_headeronly_dependency(${SELF_LIB} xo_flatstring)
|
||||
#xo_headeronly_dependency(${SELF_LIB} xo_flatstring)
|
||||
#xo_headeronly_dependency(${SELF_LIB} randomgen)
|
||||
# etc..
|
||||
|
||||
|
|
|
|||
|
|
@ -6,12 +6,7 @@ include(CMakeFindDependencyMacro)
|
|||
# must coordinate with xo_dependency() calls
|
||||
# in xo-reactor/src/reactor/CMakeLists.txt
|
||||
#
|
||||
find_dependency(xo_flatstring)
|
||||
#find_dependency(subsys)
|
||||
#find_dependency(Eigen3)
|
||||
#find_dependency(webutil)
|
||||
#find_dependency(printjson)
|
||||
#find_dependency(callback)
|
||||
#find_dependency(xo_flatstring)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
||||
check_required_components("@PROJECT_NAME@")
|
||||
|
|
|
|||
88
xo-reflectutil/include/xo/reflectutil/typeseq.hpp
Normal file
88
xo-reflectutil/include/xo/reflectutil/typeseq.hpp
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/** @file typeseq.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Dec 2025
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdint>
|
||||
|
||||
namespace xo {
|
||||
namespace reflect {
|
||||
/**
|
||||
* Tag here so we can preserve header-only implementation
|
||||
* and still have static variable
|
||||
*/
|
||||
template<typename Tag = class typeseq_tag>
|
||||
struct typeseq_impl {
|
||||
explicit typeseq_impl(int32_t s) : seqno_{s} {}
|
||||
|
||||
/** Can't have this be constexpr.
|
||||
* We need ids in shared libraries to be generated
|
||||
* at load time to avoid false positives
|
||||
*
|
||||
* Return unique id number for each type.
|
||||
* Numbers are sequentially allocated, so can use
|
||||
* as vector indices
|
||||
*
|
||||
* Conversely note that built-in typeinfo may
|
||||
* return false negatives across library boundaries
|
||||
* when using clang.
|
||||
**/
|
||||
template <typename T>
|
||||
static typeseq_impl<Tag> id() {
|
||||
static bool armed = true;
|
||||
static int32_t id = 0;
|
||||
|
||||
if (armed) {
|
||||
armed = false;
|
||||
id = ++s_next_id;
|
||||
}
|
||||
|
||||
return typeseq_impl(id);
|
||||
|
||||
}
|
||||
|
||||
/** 'anonymous' sentinel type.
|
||||
* Niche uses for this, e.g. untyped allocator
|
||||
**/
|
||||
static typeseq_impl<Tag> anon() {
|
||||
return typeseq_impl(-1);
|
||||
}
|
||||
|
||||
int32_t seqno() const { return seqno_; }
|
||||
|
||||
private:
|
||||
static int32_t s_next_id;
|
||||
|
||||
int32_t seqno_;
|
||||
};
|
||||
|
||||
template <typename Tag>
|
||||
int32_t typeseq_impl<Tag>::s_next_id = 0;
|
||||
|
||||
template <typename Tag>
|
||||
inline bool
|
||||
operator==(const typeseq_impl<Tag> & lhs, const typeseq_impl<Tag> & rhs) {
|
||||
return lhs.seqno() == rhs.seqno();
|
||||
}
|
||||
|
||||
template <typename Tag>
|
||||
inline bool
|
||||
operator!=(const typeseq_impl<Tag> & lhs, const typeseq_impl<Tag> & rhs) {
|
||||
return lhs.seqno() != rhs.seqno();
|
||||
}
|
||||
|
||||
template <typename Tag>
|
||||
inline std::ostream &
|
||||
operator<<(std::ostream & s, const typeseq_impl<Tag> & x) {
|
||||
s << x.seqno();
|
||||
return s;
|
||||
}
|
||||
|
||||
using typeseq = typeseq_impl<>;
|
||||
} /*namespace reflect*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end typeseq.hpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue