diff --git a/CMakeLists.txt b/CMakeLists.txt index 835a4d9..d708341 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # object-introspection -cmake_minimum_required(VERSION 3.19) +cmake_minimum_required(VERSION 3.20) project(object-introspection) # Lets find_program() locate SETUID binaries diff --git a/include/oi/types/st.h b/include/oi/types/st.h new file mode 100644 index 0000000..8e1dcb1 --- /dev/null +++ b/include/oi/types/st.h @@ -0,0 +1,151 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef OI_TYPES_ST_H +#define OI_TYPES_ST_H 1 + +namespace ObjectIntrospection { +namespace types { +namespace st { + +template +class Unit { + public: + Unit(DataBuffer db) : _buf(db) { + } + + size_t offset() { + return _buf.offset(); + } + + template + T cast() { + return T(_buf); + } + + template + Unit delegate(F const& cb) { + return cb(*this); + } + + private: + DataBuffer _buf; +}; + +template +class VarInt { + public: + VarInt(DataBuffer db) : _buf(db) { + } + + Unit write(uint64_t val) { + while (val >= 128) { + _buf.write_byte(0x80 | (val & 0x7f)); + val >>= 7; + } + _buf.write_byte(uint8_t(val)); + return Unit(_buf); + } + + private: + DataBuffer _buf; +}; + +template +class Pair { + public: + Pair(DataBuffer db) : _buf(db) { + } + template + T2 write(U val) { + Unit second = T1(_buf).write(val); + return second.template cast(); + } + template + T2 delegate(F const& cb) { + T1 first = T1(_buf); + Unit second = cb(first); + return second.template cast(); + } + + private: + DataBuffer _buf; +}; + +template +class Sum { + private: + template + struct Selector; + template + struct Selector { + using type = typename std::conditional< + I == 0, + Head, + typename Selector::type>::type; + }; + template + struct Selector { + using type = int; + }; + + public: + Sum(DataBuffer db) : _buf(db) { + } + template + typename Selector::type write() { + Pair, typename Selector::type> + buf(_buf); + return buf.write(I); + } + template + Unit delegate(F const& cb) { + auto tail = write(); + return cb(tail); + } + + private: + DataBuffer _buf; +}; + +template +class ListContents { + public: + ListContents(DataBuffer db) : _buf(db) { + } + + template + ListContents delegate(F const& cb) { + T head = T(_buf); + Unit tail = cb(head); + return tail.template cast>(); + } + + Unit finish() { + return {_buf}; + } + + private: + DataBuffer _buf; +}; + +template +using List = Pair, ListContents>; + +} // namespace st +} // namespace types +} // namespace ObjectIntrospection + +#endif diff --git a/oi/CodeGen.cpp b/oi/CodeGen.cpp index 93f08ec..6918521 100644 --- a/oi/CodeGen.cpp +++ b/oi/CodeGen.cpp @@ -103,6 +103,7 @@ void addIncludes(const TypeGraph& typeGraph, std::set includes{"cstddef"}; if (features[Feature::TypedDataSegment]) { includes.emplace("functional"); + includes.emplace("oi/types/st.h"); } for (const Type& t : typeGraph.finalTypes) { if (const auto* c = dynamic_cast(&t)) { @@ -425,7 +426,7 @@ void addGetSizeFuncDefs(const TypeGraph& typeGraph, void addStandardTypeHandlers(std::string& code) { code += R"( template - StaticTypes::Unit + types::st::Unit getSizeType(const T &t, typename TypeHandler::type returnArg) { JLOG("obj @"); JLOGPTR(&t); @@ -436,8 +437,8 @@ void addStandardTypeHandlers(std::string& code) { code += R"( template struct TypeHandler> { - using type = StaticTypes::List::type>; - static StaticTypes::Unit getSizeType( + using type = types::st::List::type>; + static types::st::Unit getSizeType( const OIArray &container, typename TypeHandler>::type returnArg) { auto tail = returnArg.write(N); @@ -463,7 +464,7 @@ void getClassTypeHandler(const Class& c, std::string& code) { const auto& member = c.members[i]; if (i != c.members.size() - 1) { - typeStaticType += "StaticTypes::Pair'); if (typeStaticType.empty()) { - typeStaticType = "StaticTypes::Unit"; + typeStaticType = "types::st::Unit"; } } @@ -513,7 +514,7 @@ template class TypeHandler { public: using type = %2%; - static StaticTypes::Unit %3%( + static types::st::Unit %3%( const %1%& t, typename TypeHandler::type returnArg) { %4% @@ -622,7 +623,7 @@ void CodeGen::generate( std::string& code, struct drgn_type* drgnType /* TODO: this argument should not be required */ ) { - code = headers::OITraceCode_cpp; + code = headers::oi_OITraceCode_cpp; if (!config_.features[Feature::TypedDataSegment]) { defineMacros(code); } @@ -632,7 +633,6 @@ void CodeGen::generate( if (config_.features[Feature::TypedDataSegment]) { FuncGen::DefineDataSegmentDataBuffer(code); - FuncGen::DefineStaticTypes(code); code += "using namespace ObjectIntrospection;\n"; code += "namespace OIInternal {\nnamespace {\n"; diff --git a/oi/FuncGen.cpp b/oi/FuncGen.cpp index af68eab..faa78f6 100644 --- a/oi/FuncGen.cpp +++ b/oi/FuncGen.cpp @@ -286,11 +286,11 @@ void FuncGen::DefineTopLevelGetSizeRefTyped(std::string& testCode, JLOGPTR(&t); using DataBufferType = OIInternal::TypeHandler::type; DataBufferType db = DataBuffer::DataSegment(dataSegOffset); - StaticTypes::Unit out = OIInternal::getSizeType(t, db); - StaticTypes::Unit final = out.template cast out = OIInternal::getSizeType(t, db); + types::st::Unit final = out.template cast, - StaticTypes::VarInt + types::st::VarInt, + types::st::VarInt >>() .write(123456789) .write(123456789); @@ -469,19 +469,19 @@ void FuncGen::DefineBasicTypeHandlers(std::string& testCode) { private: static auto choose_type() { if constexpr(std::is_pointer_v) { - return std::type_identity, - StaticTypes::Sum, + return std::type_identity, + types::st::Sum, typename TypeHandler>::type >>>(); } else { - return std::type_identity>(); + return std::type_identity>(); } } public: using type = typename decltype(choose_type())::type; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const T& t, typename TypeHandler::type returnArg) { if constexpr(std::is_pointer_v) { @@ -507,145 +507,9 @@ void FuncGen::DefineBasicTypeHandlers(std::string& testCode) { template class TypeHandler { public: - using type = StaticTypes::Unit; + using type = types::st::Unit; }; )"; testCode.append(handlers); } - -void FuncGen::DefineStaticTypes(std::string& testCode) { - constexpr std::string_view unitType = R"( - template - class Unit { - public: - Unit(DataBuffer db) : _buf(db) {} - - size_t offset() { - return _buf.offset(); - } - - template - T cast() { - return T(_buf); - } - - template - Unit - delegate(F const& cb) { - return cb(*this); - } - - private: - DataBuffer _buf; - }; - )"; - - constexpr std::string_view varintType = R"( - template - class VarInt { - public: - VarInt(DataBuffer db) : _buf(db) {} - - Unit write(uint64_t val) { - while (val >= 128) { - _buf.write_byte(0x80 | (val & 0x7f)); - val >>= 7; - } - _buf.write_byte(uint8_t(val)); - return Unit(_buf); - } - - private: - DataBuffer _buf; - }; - )"; - - constexpr std::string_view pairType = R"( - template - class Pair { - public: - Pair(DataBuffer db) : _buf(db) {} - template - T2 write(U val) { - Unit second = T1(_buf).write(val); - return second.template cast(); - } - template - T2 delegate(F const& cb) { - T1 first = T1(_buf); - Unit second = cb(first); - return second.template cast(); - } - private: - DataBuffer _buf; - }; - )"; - - constexpr std::string_view sumType = R"( - template - class Sum { - private: - template - struct Selector; - template - struct Selector { - using type = typename std::conditional::type>::type; - }; - template - struct Selector { - using type = int; - }; - public: - Sum(DataBuffer db) : _buf(db) {} - template - typename Selector::type write() { - Pair, typename Selector::type> buf(_buf); - return buf.write(I); - } - template - Unit delegate(F const& cb) { - auto tail = write(); - return cb(tail); - } - private: - DataBuffer _buf; - }; - )"; - - constexpr std::string_view listType = R"( - template - class ListContents { - public: - ListContents(DataBuffer db) : _buf(db) {} - - template - ListContents delegate(F const& cb) { - T head = T(_buf); - Unit tail = cb(head); - return tail.template cast>(); - } - - Unit finish() { - return { _buf }; - } - private: - DataBuffer _buf; - }; - - template - using List = Pair, ListContents>; - )"; - - testCode.append("namespace ObjectIntrospection {\n"); - testCode.append("namespace StaticTypes {\n"); - - testCode.append(unitType); - testCode.append(varintType); - testCode.append(pairType); - testCode.append(sumType); - testCode.append(listType); - - testCode.append("} // namespace StaticTypes {\n"); - testCode.append("} // namespace ObjectIntrospection {\n"); -} diff --git a/oi/FuncGen.h b/oi/FuncGen.h index 59ec165..e496598 100644 --- a/oi/FuncGen.h +++ b/oi/FuncGen.h @@ -69,6 +69,5 @@ class FuncGen { const std::string& ctype); static void DefineDataSegmentDataBuffer(std::string& testCode); - static void DefineStaticTypes(std::string& testCode); static void DefineBasicTypeHandlers(std::string& testCode); }; diff --git a/oi/Headers.h b/oi/Headers.h index b7b0d7b..32eb9a3 100644 --- a/oi/Headers.h +++ b/oi/Headers.h @@ -19,7 +19,8 @@ namespace ObjectIntrospection { namespace headers { // These externs are provided by our build system. See resources/CMakeLists.txt -extern const std::string_view OITraceCode_cpp; +extern const std::string_view oi_OITraceCode_cpp; +extern const std::string_view oi_types_st_h; } // namespace headers } // namespace ObjectIntrospection diff --git a/oi/OICompiler.cpp b/oi/OICompiler.cpp index b951516..bff2ee3 100644 --- a/oi/OICompiler.cpp +++ b/oi/OICompiler.cpp @@ -40,6 +40,7 @@ #include #include +#include "oi/Headers.h" #include "oi/Metrics.h" extern "C" { @@ -514,6 +515,15 @@ bool OICompiler::compile(const std::string& code, path.c_str(), clang::frontend::IncludeDirGroup::System, false, false); } + if (config.features[Feature::TypedDataSegment]) { + compInv->getPreprocessorOpts().addRemappedFile( + "/synthetic/headers/oi/types/st.h", + MemoryBuffer::getMemBuffer(headers::oi_types_st_h).release()); + headerSearchOptions.AddPath( + "/synthetic/headers", clang::frontend::IncludeDirGroup::IndexHeaderMap, + false, false); + } + compInv->getFrontendOpts().OutputFile = objectPath; compInv->getTargetOpts().Triple = llvm::Triple::normalize(llvm::sys::getProcessTriple()); diff --git a/oi/OIDebugger.cpp b/oi/OIDebugger.cpp index 54c9f52..a45bd4f 100644 --- a/oi/OIDebugger.cpp +++ b/oi/OIDebugger.cpp @@ -2908,7 +2908,7 @@ std::optional OIDebugger::generateCode(const irequest& req) { return std::nullopt; } - std::string code(headers::OITraceCode_cpp); + std::string code(headers::oi_OITraceCode_cpp); auto codegen = OICodeGen::buildFromConfig(generatorConfig, *symbols); if (!codegen) { diff --git a/oi/OIGenerator.cpp b/oi/OIGenerator.cpp index 6d0cca4..e0c6ef6 100644 --- a/oi/OIGenerator.cpp +++ b/oi/OIGenerator.cpp @@ -135,7 +135,7 @@ fs::path OIGenerator::generateForType(const OICodeGen::Config& generatorConfig, return {}; } - std::string code(headers::OITraceCode_cpp); + std::string code(headers::oi_OITraceCode_cpp); codegen->setRootType(type); codegen->setLinkageName(linkageName); diff --git a/oi/OILibraryImpl.cpp b/oi/OILibraryImpl.cpp index a44a3f8..290d016 100644 --- a/oi/OILibraryImpl.cpp +++ b/oi/OILibraryImpl.cpp @@ -161,7 +161,7 @@ int OILibraryImpl::compileCode() { return Response::OIL_COMPILATION_FAILURE; } - std::string code(headers::OITraceCode_cpp); + std::string code(headers::oi_OITraceCode_cpp); auto codegen = OICodeGen::buildFromConfig(generatorConfig, *symbols); if (!codegen) { diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 983eaf3..4e40051 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -8,12 +8,25 @@ function(embed_headers output) file(APPEND ${output} "namespace headers {\n\n") set(HEADERS + ../include/oi/types/st.h ../oi/OITraceCode.cpp ) foreach(header ${HEADERS}) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${header}) + + file(REAL_PATH ${header} file_real_path) + set(include_path ${CMAKE_CURRENT_SOURCE_DIR}/../include) + + cmake_path(IS_PREFIX include_path ${file_real_path} NORMALIZE in_include) + if (${in_include}) + file(RELATIVE_PATH file_rel_path ${include_path} ${file_real_path}) + else() + file(RELATIVE_PATH file_rel_path ${CMAKE_CURRENT_SOURCE_DIR}/.. ${file_real_path}) + endif() + + string(MAKE_C_IDENTIFIER ${file_rel_path} varname) get_filename_component(filename ${header} NAME) - string(MAKE_C_IDENTIFIER ${filename} varname) + file(READ ${header} contents) file(APPEND ${output} "const std::string_view ${varname} = R\"CONTENTS(${contents})CONTENTS\";\n\n") endforeach() diff --git a/types/README.md b/types/README.md index b121be7..92fd307 100644 --- a/types/README.md +++ b/types/README.md @@ -49,7 +49,7 @@ This document describes the format of the container definition files contained i A `TypeHandler` class describes both what a type will write into the data segment and how to write it. It consists of two major parts: - `using type = ...;` - describe what it will write into the data segment. -- `static StaticTypes::Unit getSizeType(...)` - a function which takes a +- `static types::st::Unit getSizeType(...)` - a function which takes a const reference to a container and a `::type` by value and fills in the type. Example: @@ -57,9 +57,9 @@ Example: template struct TypeHandler> { using type = - StaticTypes::Pair, StaticTypes::VarInt>; + types::st::Pair, types::st::VarInt>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const std::string & container, typename TypeHandler>::type returnArg) { bool sso = ((uintptr_t)container.data() < diff --git a/types/array_type.toml b/types/array_type.toml index a63cc48..32479ed 100644 --- a/types/array_type.toml +++ b/types/array_type.toml @@ -32,9 +32,9 @@ void getSizeType(const %1% &container, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::List::type>; + using type = types::st::List::type>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1% &container, typename TypeHandler>::type returnArg) { auto tail = returnArg.write(container.size()); diff --git a/types/cxx11_list_type.toml b/types/cxx11_list_type.toml index 47bcc70..437846c 100644 --- a/types/cxx11_list_type.toml +++ b/types/cxx11_list_type.toml @@ -36,11 +36,11 @@ void getSizeType(const %1% &container, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair, - StaticTypes::List::type>>; + using type = types::st::Pair, + types::st::List::type>>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1% & container, typename TypeHandler>::type returnArg) { auto tail = returnArg.write((uintptr_t)&container) diff --git a/types/cxx11_string_type.toml b/types/cxx11_string_type.toml index c57a69b..6b14254 100644 --- a/types/cxx11_string_type.toml +++ b/types/cxx11_string_type.toml @@ -40,9 +40,9 @@ handler = """ template struct TypeHandler> { using type = - StaticTypes::Pair, StaticTypes::VarInt>; + types::st::Pair, types::st::VarInt>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1% & container, typename TypeHandler>::type returnArg) { bool sso = ((uintptr_t)container.data() < diff --git a/types/deque_list_type.toml b/types/deque_list_type.toml index 021b280..eb0015d 100644 --- a/types/deque_list_type.toml +++ b/types/deque_list_type.toml @@ -36,11 +36,11 @@ void getSizeType(const %1% &container, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair, - StaticTypes::List::type>>; + using type = types::st::Pair, + types::st::List::type>>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { auto tail = returnArg.write((uintptr_t)&container) diff --git a/types/fb_string_type.toml b/types/fb_string_type.toml index d869d01..fba5d81 100644 --- a/types/fb_string_type.toml +++ b/types/fb_string_type.toml @@ -41,16 +41,16 @@ void getSizeType(const %1% &container, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair, - StaticTypes::Pair, - StaticTypes::Pair, - StaticTypes::VarInt + using type = types::st::Pair, + types::st::Pair, + types::st::Pair, + types::st::VarInt >>>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { auto last = returnArg.write((uintptr_t)container.data()) diff --git a/types/list_type.toml b/types/list_type.toml index 0c7c965..78ef5c5 100644 --- a/types/list_type.toml +++ b/types/list_type.toml @@ -36,11 +36,11 @@ void getSizeType(const %1% &container, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair, - StaticTypes::List::type>>; + using type = types::st::Pair, + types::st::List::type>>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1% & container, typename TypeHandler>::type returnArg) { auto tail = returnArg.write((uintptr_t)&container) diff --git a/types/multi_map_type.toml b/types/multi_map_type.toml index 558eaae..8e6c447 100644 --- a/types/multi_map_type.toml +++ b/types/multi_map_type.toml @@ -36,12 +36,12 @@ void getSizeType(const %1% &container, size_t& returnAr handler = """ template struct TypeHandler> { - using type = StaticTypes::List::type, typename TypeHandler::type >>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { auto tail = returnArg.write(container.size()); diff --git a/types/optional_type.toml b/types/optional_type.toml index 52cc7c3..19c9755 100644 --- a/types/optional_type.toml +++ b/types/optional_type.toml @@ -31,12 +31,12 @@ void getSizeType(const %1%& container, size_t& returnArg) { handler = """ template struct TypeHandler> { - using type = StaticTypes::Sum, + using type = types::st::Sum, typename TypeHandler::type >; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { if (container) { diff --git a/types/pair_type.toml b/types/pair_type.toml index b82f3a0..d82a719 100644 --- a/types/pair_type.toml +++ b/types/pair_type.toml @@ -29,11 +29,11 @@ void getSizeType(const %1% &container, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair::type, typename TypeHandler::type>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1% & container, typename TypeHandler>::type returnArg) { return OIInternal::getSizeType( diff --git a/types/priority_queue_container_adapter_type.toml b/types/priority_queue_container_adapter_type.toml index d0ac527..cc0b33c 100644 --- a/types/priority_queue_container_adapter_type.toml +++ b/types/priority_queue_container_adapter_type.toml @@ -36,11 +36,11 @@ void getSizeType(const %1% &containerAdapter, size_t& returnA handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair, + using type = types::st::Pair, typename TypeHandler::type>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { auto tail = returnArg.write((uintptr_t)&container); diff --git a/types/queue_container_adapter_type.toml b/types/queue_container_adapter_type.toml index 03d7625..10891f8 100644 --- a/types/queue_container_adapter_type.toml +++ b/types/queue_container_adapter_type.toml @@ -35,11 +35,11 @@ void getSizeType(const %1% &containerAdapter, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair, + using type = types::st::Pair, typename TypeHandler::type>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1% & container, typename TypeHandler>::type returnArg) { auto tail = returnArg.write((uintptr_t)&container); diff --git a/types/ref_wrapper_type.toml b/types/ref_wrapper_type.toml index 3f0647e..9c87b2a 100644 --- a/types/ref_wrapper_type.toml +++ b/types/ref_wrapper_type.toml @@ -33,14 +33,14 @@ void getSizeType(const %1% &ref, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair, - StaticTypes::Sum, + using type = types::st::Pair, + types::st::Sum, typename TypeHandler::type >>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { auto r0 = returnArg.write((uintptr_t)&(container.get())); diff --git a/types/seq_type.toml b/types/seq_type.toml index 40dd7ad..07cb7fb 100644 --- a/types/seq_type.toml +++ b/types/seq_type.toml @@ -38,13 +38,13 @@ void getSizeType(const %1% &container, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair< - DB, StaticTypes::VarInt, - StaticTypes::Pair< - DB, StaticTypes::VarInt, - StaticTypes::List::type>>>; + using type = types::st::Pair< + DB, types::st::VarInt, + types::st::Pair< + DB, types::st::VarInt, + types::st::List::type>>>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1% & container, typename TypeHandler>::type returnArg) { auto tail = returnArg.write((uintptr_t)&container) diff --git a/types/set_type.toml b/types/set_type.toml index c5f94df..8cf4312 100644 --- a/types/set_type.toml +++ b/types/set_type.toml @@ -39,11 +39,11 @@ void getSizeType(const %1% &container, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair, - StaticTypes::List::type>>; + using type = types::st::Pair, + types::st::List::type>>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { constexpr size_t nodeSize = sizeof(typename %1%::node_type); diff --git a/types/shrd_ptr_type.toml b/types/shrd_ptr_type.toml index 32ffe3f..fff8f54 100644 --- a/types/shrd_ptr_type.toml +++ b/types/shrd_ptr_type.toml @@ -39,15 +39,15 @@ template struct TypeHandler> { using type = typename std::conditional< std::is_void::value, - StaticTypes::Unit, - StaticTypes::Pair, - StaticTypes::Sum, + types::st::Unit, + types::st::Pair, + types::st::Sum, typename TypeHandler::type >>>::type; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { if constexpr (!std::is_void::value) { diff --git a/types/sorted_vec_set_type.toml b/types/sorted_vec_set_type.toml index 0c963b1..1f9f690 100644 --- a/types/sorted_vec_set_type.toml +++ b/types/sorted_vec_set_type.toml @@ -34,11 +34,11 @@ void getSizeType(const %1% &conta handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair, + using type = types::st::Pair, typename TypeHandler::type>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { auto tail = returnArg.write((uintptr_t)&container); diff --git a/types/stack_container_adapter_type.toml b/types/stack_container_adapter_type.toml index 4cc279b..67187bb 100644 --- a/types/stack_container_adapter_type.toml +++ b/types/stack_container_adapter_type.toml @@ -35,11 +35,11 @@ void getSizeType(const %1% &containerAdapter, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair, + using type = types::st::Pair, typename TypeHandler::type>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1% & container, typename TypeHandler>::type returnArg) { auto tail = returnArg.write((uintptr_t)&container); diff --git a/types/std_map_type.toml b/types/std_map_type.toml index b980c9c..57f4fe7 100644 --- a/types/std_map_type.toml +++ b/types/std_map_type.toml @@ -40,14 +40,14 @@ void getSizeType(const %1% &container, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair, - StaticTypes::List, + types::st::List::type, typename TypeHandler::type >>>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { constexpr size_t nodeSize = sizeof(typename %1%::node_type); diff --git a/types/std_unordered_map_type.toml b/types/std_unordered_map_type.toml index b71860d..6b6b558 100644 --- a/types/std_unordered_map_type.toml +++ b/types/std_unordered_map_type.toml @@ -42,16 +42,16 @@ void getSizeType(const %1% &container, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair, - StaticTypes::Pair, - StaticTypes::List, + types::st::Pair, + types::st::List::type, typename TypeHandler::type >>>>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { constexpr size_t nodeSize = sizeof(typename %1%::node_type); diff --git a/types/std_variant.toml b/types/std_variant.toml index a1b4953..d8d5f9b 100644 --- a/types/std_variant.toml +++ b/types/std_variant.toml @@ -39,9 +39,9 @@ void getSizeType(const %1% &container, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::Sum::type..., StaticTypes::Unit>; + using type = types::st::Sum::type..., types::st::Unit>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { return getSizeTypeRecursive(container, returnArg); @@ -49,7 +49,7 @@ struct TypeHandler> { private: template - static StaticTypes::Unit getSizeTypeRecursive( + static types::st::Unit getSizeTypeRecursive( const %1%& container, typename TypeHandler>::type returnArg) { if constexpr (I < sizeof...(Types)) { diff --git a/types/uniq_ptr_type.toml b/types/uniq_ptr_type.toml index a411c97..cee22a7 100644 --- a/types/uniq_ptr_type.toml +++ b/types/uniq_ptr_type.toml @@ -40,15 +40,15 @@ template struct TypeHandler> { using type = typename std::conditional< std::is_void::value, - StaticTypes::Unit, - StaticTypes::Pair, - StaticTypes::Sum, + types::st::Unit, + types::st::Pair, + types::st::Sum, typename TypeHandler::type >>>::type; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { if constexpr (!std::is_void::value) { diff --git a/types/unordered_set_type.toml b/types/unordered_set_type.toml index 0d700f3..380d0b8 100644 --- a/types/unordered_set_type.toml +++ b/types/unordered_set_type.toml @@ -40,13 +40,13 @@ void getSizeType(const %1% &container, size_t& ret handler = """ template struct TypeHandler> { - using type = StaticTypes::Pair< - DB, StaticTypes::VarInt, - StaticTypes::Pair< - DB, StaticTypes::VarInt, - StaticTypes::List::type>>>; + using type = types::st::Pair< + DB, types::st::VarInt, + types::st::Pair< + DB, types::st::VarInt, + types::st::List::type>>>; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { constexpr size_t nodeSize = sizeof(typename %1%::node_type); diff --git a/types/weak_ptr_type.toml b/types/weak_ptr_type.toml index a27792a..9c02b8a 100644 --- a/types/weak_ptr_type.toml +++ b/types/weak_ptr_type.toml @@ -27,9 +27,9 @@ void getSizeType(const %1% &s_ptr, size_t& returnArg) handler = """ template struct TypeHandler> { - using type = StaticTypes::Unit; + using type = types::st::Unit; - static StaticTypes::Unit getSizeType( + static types::st::Unit getSizeType( const %1%& container, typename TypeHandler>::type returnArg) { return returnArg;