From e5cb3ff96b6312039d27cfad64e18d9999420b8b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 14 Dec 2025 11:29:54 -0500 Subject: [PATCH] + xo-object2 --- xo-object2/CMakeLists.txt | 32 ++++++++++++++ xo-object2/cmake/xo-bootstrap-macros.cmake | 35 +++++++++++++++ xo-object2/cmake/xo_object2Config.cmake.in | 7 +++ xo-object2/include/xo/object2/DFloat.hpp | 14 ++++++ xo-object2/include/xo/object2/DInteger.hpp | 14 ++++++ .../include/xo/object2/IGCObject_DFloat.hpp | 30 +++++++++++++ .../include/xo/object2/IGCObject_DInteger.hpp | 30 +++++++++++++ xo-object2/src/object2/CMakeLists.txt | 12 +++++ xo-object2/src/object2/IGCObject_DFloat.cpp | 44 +++++++++++++++++++ xo-object2/src/object2/IGCObject_DInteger.cpp | 44 +++++++++++++++++++ 10 files changed, 262 insertions(+) create mode 100644 xo-object2/CMakeLists.txt create mode 100644 xo-object2/cmake/xo-bootstrap-macros.cmake create mode 100644 xo-object2/cmake/xo_object2Config.cmake.in create mode 100644 xo-object2/include/xo/object2/DFloat.hpp create mode 100644 xo-object2/include/xo/object2/DInteger.hpp create mode 100644 xo-object2/include/xo/object2/IGCObject_DFloat.hpp create mode 100644 xo-object2/include/xo/object2/IGCObject_DInteger.hpp create mode 100644 xo-object2/src/object2/CMakeLists.txt create mode 100644 xo-object2/src/object2/IGCObject_DFloat.cpp create mode 100644 xo-object2/src/object2/IGCObject_DInteger.cpp diff --git a/xo-object2/CMakeLists.txt b/xo-object2/CMakeLists.txt new file mode 100644 index 00000000..7d3a714e --- /dev/null +++ b/xo-object2/CMakeLists.txt @@ -0,0 +1,32 @@ +# xo-object2/CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) + +project(xo_object2 VERSION 0.1) + +include(GNUInstallDirs) +include(cmake/xo-bootstrap-macros.cmake) + +xo_cxx_toplevel_options3() + +# ---------------------------------------------------------------- +# c++ settings + +set(PROJECT_CXX_FLAGS "") +#set(PROJECT_CXX_FLAGS "-fconcepts-diagnostics-depth=2") # gcc-only! +add_definitions(${PROJECT_CXX_FLAGS}) + +# ---------------------------------------------------------------- + +# must complete definition of expression lib before configuring examples +add_subdirectory(src/object2) +#add_subdirectory(utest) +#xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) + +# ---------------------------------------------------------------- +# docs targets depend on other library/utest/exec targets above, +# --> must come after them. +# +#add_subdirectory(docs) + +# end CMakeLists.txt diff --git a/xo-object2/cmake/xo-bootstrap-macros.cmake b/xo-object2/cmake/xo-bootstrap-macros.cmake new file mode 100644 index 00000000..aba31169 --- /dev/null +++ b/xo-object2/cmake/xo-bootstrap-macros.cmake @@ -0,0 +1,35 @@ +# ---------------------------------------------------------------- +# 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 ("${XO_CMAKE_CONFIG_EXECUTABLE}" STREQUAL "XO_CMAKE_CONFIG_EXECUTABLE-NOT_FOUND") + message(FATAL "could not find xo-cmake-config executable") +endif() + +message(STATUS "XO_CMAKE_CONFIG_EXECUTABLE=${XO_CMAKE_CONFIG_EXECUTABLE}") + +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() diff --git a/xo-object2/cmake/xo_object2Config.cmake.in b/xo-object2/cmake/xo_object2Config.cmake.in new file mode 100644 index 00000000..c32a8368 --- /dev/null +++ b/xo-object2/cmake/xo_object2Config.cmake.in @@ -0,0 +1,7 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +#find_dependency(indentlog) +find_dependency(xo_alloc2) +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/xo-object2/include/xo/object2/DFloat.hpp b/xo-object2/include/xo/object2/DFloat.hpp new file mode 100644 index 00000000..52a3ba43 --- /dev/null +++ b/xo-object2/include/xo/object2/DFloat.hpp @@ -0,0 +1,14 @@ +/** @file DFloat.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +namespace xo { + namespace scm { + using DFloat = double; + } /*nmaespace obj*/ +} /*namespace xo*/ + +/* end DFloat.hpp */ diff --git a/xo-object2/include/xo/object2/DInteger.hpp b/xo-object2/include/xo/object2/DInteger.hpp new file mode 100644 index 00000000..ded9e805 --- /dev/null +++ b/xo-object2/include/xo/object2/DInteger.hpp @@ -0,0 +1,14 @@ +/** @file DInteger.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +namespace xo { + namespace scm { + using DInteger = double; + } /*nmaespace obj*/ +} /*namespace xo*/ + +/* end DInteger.hpp */ diff --git a/xo-object2/include/xo/object2/IGCObject_DFloat.hpp b/xo-object2/include/xo/object2/IGCObject_DFloat.hpp new file mode 100644 index 00000000..59f4c349 --- /dev/null +++ b/xo-object2/include/xo/object2/IGCObject_DFloat.hpp @@ -0,0 +1,30 @@ +/** @file IGCObject_DFloat.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +#include "xo/alloc2/AAllocator.hpp" +#include "xo/alloc2/AGCObject.hpp" +#include "xo/alloc2/IGCObject_Xfer.hpp" +#include "DFloat.hpp" + +namespace xo { + namespace scm { + /* changes here coordinate with: + * IGCObject_Xfer + */ + struct IGCObject_DFloat { + public: + using AAllocator = xo::mm::AAllocator; + using size_type = std::size_t; + + static size_type shallow_size(const DFloat & d) noexcept; + static DFloat * shallow_copy(const DFloat & d, obj mm) noexcept; + static size_type forward_children(DFloat & d) noexcept; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DFloat.hpp */ diff --git a/xo-object2/include/xo/object2/IGCObject_DInteger.hpp b/xo-object2/include/xo/object2/IGCObject_DInteger.hpp new file mode 100644 index 00000000..0c36062d --- /dev/null +++ b/xo-object2/include/xo/object2/IGCObject_DInteger.hpp @@ -0,0 +1,30 @@ +/** @file IGCObject_DInteger.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +#include "xo/alloc2/AAllocator.hpp" +#include "xo/alloc2/AGCObject.hpp" +#include "xo/alloc2/IGCObject_Xfer.hpp" +#include "DInteger.hpp" + +namespace xo { + namespace scm { + /* changes here coordinate with: + * IGCObject_Xfer + */ + struct IGCObject_DInteger { + public: + using AAllocator = xo::mm::AAllocator; + using size_type = std::size_t; + + static size_type shallow_size(const DInteger & d) noexcept; + static DInteger * shallow_copy(const DInteger & d, obj mm) noexcept; + static size_type forward_children(DInteger & d) noexcept; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DInteger.hpp */ diff --git a/xo-object2/src/object2/CMakeLists.txt b/xo-object2/src/object2/CMakeLists.txt new file mode 100644 index 00000000..25b46ba1 --- /dev/null +++ b/xo-object2/src/object2/CMakeLists.txt @@ -0,0 +1,12 @@ +# object2/CMakeLists.txt + +set(SELF_LIB xo_object2) +set(SELF_SRCS + IGCObject_DFloat.cpp + IGCObject_DInteger.cpp + ) + +xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) +# note: deps here must also appear in cmake/xo_alloc2Config.cmake.in +xo_dependency(${SELF_LIB} xo_alloc2) +#xo_dependency(${SELF_LIB} indentlog) diff --git a/xo-object2/src/object2/IGCObject_DFloat.cpp b/xo-object2/src/object2/IGCObject_DFloat.cpp new file mode 100644 index 00000000..2c339b09 --- /dev/null +++ b/xo-object2/src/object2/IGCObject_DFloat.cpp @@ -0,0 +1,44 @@ +/** @file IGCObject_DFloat.cpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#include "IGCObject_DFloat.hpp" +#include "AAllocator.hpp" +#include "xo/facet/obj.hpp" +#include + +namespace xo { + using xo::mm::AAllocator; + using xo::facet::obj; + using std::size_t; + + namespace scm { + size_t + IGCObject_DFloat::shallow_size(const DFloat &) noexcept + { + return sizeof(DFloat); + } + + DFloat * + IGCObject_DFloat::shallow_copy(const DFloat & src, + obj mm) noexcept + { + DFloat * copy = (DFloat *)mm.alloc(sizeof(DFloat)); + + if (copy) + *copy = src; + + return copy; + } + + size_t + IGCObject_DFloat::forward_children(DFloat &) noexcept + { + return sizeof(DFloat); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DFloat.cpp */ diff --git a/xo-object2/src/object2/IGCObject_DInteger.cpp b/xo-object2/src/object2/IGCObject_DInteger.cpp new file mode 100644 index 00000000..0fd2b2e6 --- /dev/null +++ b/xo-object2/src/object2/IGCObject_DInteger.cpp @@ -0,0 +1,44 @@ +/** @file IGCObject_DInteger.cpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#include "IGCObject_DInteger.hpp" +#include "AAllocator.hpp" +#include "xo/facet/obj.hpp" +#include + +namespace xo { + using xo::mm::AAllocator; + using xo::facet::obj; + using std::size_t; + + namespace scm { + size_t + IGCObject_DInteger::shallow_size(const DInteger &) noexcept + { + return sizeof(DInteger); + } + + DInteger * + IGCObject_DInteger::shallow_copy(const DInteger & src, + obj mm) noexcept + { + DInteger * copy = (DInteger *)mm.alloc(sizeof(DInteger)); + + if (copy) + *copy = src; + + return copy; + } + + size_t + IGCObject_DInteger::forward_children(DInteger &) noexcept + { + return sizeof(DInteger); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DInteger.cpp */