xo-type: + DAtomicType [WIP]
This commit is contained in:
commit
c9944a27aa
31 changed files with 1262 additions and 0 deletions
25
src/type/CMakeLists.txt
Normal file
25
src/type/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# xo-type/src/type/CMakeLists.txt
|
||||
|
||||
set(SELF_LIB xo_type)
|
||||
set(SELF_SRCS
|
||||
init_type.cpp
|
||||
type_register_facets.cpp
|
||||
type_register_types.cpp
|
||||
Metatype.cpp
|
||||
DAtomicType.cpp
|
||||
IType_DAtomicType.cpp
|
||||
IGCObject_DAtomicType.cpp
|
||||
)
|
||||
|
||||
xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS})
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# input dependencies
|
||||
#
|
||||
# NOTE: dependency set here must be kept consistent with
|
||||
# xo-type/cmake/xo_typeConfig.cmake.in
|
||||
|
||||
xo_dependency(${SELF_LIB} xo_alloc2)
|
||||
xo_dependency(${SELF_LIB} xo_facet)
|
||||
|
||||
# end src/type/CMakeLists.txt
|
||||
42
src/type/DAtomicType.cpp
Normal file
42
src/type/DAtomicType.cpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/** @file DAtomicType.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Mar 2026
|
||||
**/
|
||||
|
||||
#include "AtomicType.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
DAtomicType *
|
||||
DAtomicType::_make(obj<AAllocator> mm, Metatype mtype)
|
||||
{
|
||||
void * mem = mm.alloc_for<DAtomicType>();
|
||||
|
||||
return new (mem) DAtomicType(mtype);
|
||||
}
|
||||
|
||||
// ----- GCObject facet -----
|
||||
|
||||
std::size_t
|
||||
DAtomicType::shallow_size() const noexcept
|
||||
{
|
||||
return sizeof(DAtomicType);
|
||||
}
|
||||
|
||||
DAtomicType *
|
||||
DAtomicType::shallow_copy(obj<AAllocator> mm) const noexcept
|
||||
{
|
||||
return mm.std_copy_for(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DAtomicType::forward_children(obj<ACollector>) noexcept
|
||||
{
|
||||
return this->shallow_size();
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DAtomicType.cpp */
|
||||
39
src/type/IGCObject_DAtomicType.cpp
Normal file
39
src/type/IGCObject_DAtomicType.cpp
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/** @file IGCObject_DAtomicType.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IGCObject_DAtomicType.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IGCObject_DAtomicType.json5]
|
||||
**/
|
||||
|
||||
#include "atomic/IGCObject_DAtomicType.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IGCObject_DAtomicType::shallow_size(const DAtomicType & self) noexcept -> size_type
|
||||
{
|
||||
return self.shallow_size();
|
||||
}
|
||||
|
||||
auto
|
||||
IGCObject_DAtomicType::shallow_copy(const DAtomicType & self, obj<AAllocator> mm) noexcept -> Opaque
|
||||
{
|
||||
return self.shallow_copy(mm);
|
||||
}
|
||||
|
||||
auto
|
||||
IGCObject_DAtomicType::forward_children(DAtomicType & self, obj<ACollector> gc) noexcept -> size_type
|
||||
{
|
||||
return self.forward_children(gc);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IGCObject_DAtomicType.cpp */
|
||||
42
src/type/IType_Any.cpp
Normal file
42
src/type/IType_Any.cpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/** @file IType_Any.cpp
|
||||
*
|
||||
**/
|
||||
|
||||
#include "type/IType_Any.hpp"
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
using xo::facet::DVariantPlaceholder;
|
||||
using xo::facet::typeseq;
|
||||
using xo::facet::valid_facet_implementation;
|
||||
|
||||
void
|
||||
IType_Any::_fatal()
|
||||
{
|
||||
/* control here on uninitialized IAllocator_Any.
|
||||
* Initialized instance will have specific implementation type
|
||||
*/
|
||||
std::cerr << "fatal"
|
||||
<< ": attempt to call uninitialized"
|
||||
<< " IType_Any method"
|
||||
<< std::endl;
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
typeseq
|
||||
IType_Any::s_typeseq = typeseq::id<DVariantPlaceholder>();
|
||||
|
||||
bool
|
||||
IType_Any::_valid
|
||||
= valid_facet_implementation<AType, IType_Any>();
|
||||
|
||||
// nonconst methods
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IType_Any.cpp */
|
||||
28
src/type/IType_DAtomicType.cpp
Normal file
28
src/type/IType_DAtomicType.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/** @file IType_DAtomicType.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IType_DAtomicType.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IType_DAtomicType.json5]
|
||||
**/
|
||||
|
||||
#include "atomic/IType_DAtomicType.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IType_DAtomicType::metatype(const DAtomicType & self) noexcept -> Metatype
|
||||
{
|
||||
return self.metatype();
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IType_DAtomicType.cpp */
|
||||
32
src/type/Metatype.cpp
Normal file
32
src/type/Metatype.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/** @file Metatype.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Nar 2026
|
||||
**/
|
||||
|
||||
#include "Metatype.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
const char *
|
||||
Metatype::_descr() const noexcept
|
||||
{
|
||||
switch (code_) {
|
||||
case code::t_any: return "any";
|
||||
case code::t_bool: return "bool";
|
||||
case code::t_i64: return "i64";
|
||||
case code::t_f64: return "f64";
|
||||
case code::t_str: return "str";
|
||||
case code::t_sum: return "sum";
|
||||
case code::t_list: return "list";
|
||||
case code::t_array: return "array";
|
||||
case code::t_function: return "function";
|
||||
case code::t_struct: return "struct";
|
||||
case code::t_unit: return "unit";
|
||||
}
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end Metatype.cpp */
|
||||
40
src/type/init_type.cpp
Normal file
40
src/type/init_type.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/** @file init_type.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#include "init_type.hpp"
|
||||
#include "type_register_facets.hpp"
|
||||
#include "type_register_types.hpp"
|
||||
#include <xo/alloc2/CollectorTypeRegistry.hpp>
|
||||
#include <xo/alloc2/init_alloc2.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::scm::type_register_facets;
|
||||
using xo::scm::type_register_types;
|
||||
using xo::mm::CollectorTypeRegistry;
|
||||
|
||||
void
|
||||
InitSubsys<S_type_tag>::init()
|
||||
{
|
||||
type_register_facets();
|
||||
|
||||
CollectorTypeRegistry::instance().register_types(&type_register_types);
|
||||
}
|
||||
|
||||
InitEvidence
|
||||
InitSubsys<S_type_tag>::require()
|
||||
{
|
||||
InitEvidence retval;
|
||||
|
||||
/* direct subsystem deps for xo-type/ */
|
||||
retval ^= InitSubsys<S_alloc2_tag>::require();
|
||||
|
||||
/* xo-type/'s own initialization code */
|
||||
retval ^= Subsystem::provide<S_type_tag>("type", &init);
|
||||
|
||||
return retval;
|
||||
}
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end init_type.cpp */
|
||||
35
src/type/type_register_facets.cpp
Normal file
35
src/type/type_register_facets.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/** @file type_register_facets.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Feb 2026
|
||||
**/
|
||||
|
||||
#include "type_register_facets.hpp"
|
||||
|
||||
#include <xo/type/AtomicType.hpp>
|
||||
#include <xo/facet/FacetRegistry.hpp>
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::mm::AGCObject;
|
||||
using xo::facet::FacetRegistry;
|
||||
//using xo::facet::TypeRegistry;
|
||||
using xo::reflect::typeseq;
|
||||
|
||||
namespace scm {
|
||||
|
||||
bool
|
||||
type_register_facets()
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
FacetRegistry::register_impl<AGCObject, DAtomicType>();
|
||||
|
||||
log && log(xtag("DAtomicType.tseq", typeseq::id<DAtomicType>()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end type_register_facets.cpp */
|
||||
34
src/type/type_register_types.cpp
Normal file
34
src/type/type_register_types.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/** @file type_register_types.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Dec 2025
|
||||
**/
|
||||
|
||||
#include "type_register_types.hpp"
|
||||
|
||||
#include "AtomicType.hpp"
|
||||
#include <xo/alloc2/Collector.hpp>
|
||||
#include <xo/facet/FacetRegistry.hpp>
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::mm::ACollector;
|
||||
using xo::mm::AGCObject;
|
||||
using xo::facet::impl_for;
|
||||
using xo::scope;
|
||||
|
||||
namespace scm {
|
||||
bool
|
||||
type_register_types(obj<ACollector> gc)
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= gc.install_type(impl_for<AGCObject, DAtomicType>());
|
||||
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end type_register_types.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue