mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-12 21:56:54 +00:00
static types: place in own header for testing
This commit is contained in:
parent
8e48c6ca52
commit
6aead62652
@ -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
|
||||
|
151
include/oi/types/st.h
Normal file
151
include/oi/types/st.h
Normal file
@ -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 <typename DataBuffer>
|
||||
class Unit {
|
||||
public:
|
||||
Unit(DataBuffer db) : _buf(db) {
|
||||
}
|
||||
|
||||
size_t offset() {
|
||||
return _buf.offset();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T cast() {
|
||||
return T(_buf);
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
Unit<DataBuffer> delegate(F const& cb) {
|
||||
return cb(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
DataBuffer _buf;
|
||||
};
|
||||
|
||||
template <typename DataBuffer>
|
||||
class VarInt {
|
||||
public:
|
||||
VarInt(DataBuffer db) : _buf(db) {
|
||||
}
|
||||
|
||||
Unit<DataBuffer> write(uint64_t val) {
|
||||
while (val >= 128) {
|
||||
_buf.write_byte(0x80 | (val & 0x7f));
|
||||
val >>= 7;
|
||||
}
|
||||
_buf.write_byte(uint8_t(val));
|
||||
return Unit<DataBuffer>(_buf);
|
||||
}
|
||||
|
||||
private:
|
||||
DataBuffer _buf;
|
||||
};
|
||||
|
||||
template <typename DataBuffer, typename T1, typename T2>
|
||||
class Pair {
|
||||
public:
|
||||
Pair(DataBuffer db) : _buf(db) {
|
||||
}
|
||||
template <class U>
|
||||
T2 write(U val) {
|
||||
Unit<DataBuffer> second = T1(_buf).write(val);
|
||||
return second.template cast<T2>();
|
||||
}
|
||||
template <typename F>
|
||||
T2 delegate(F const& cb) {
|
||||
T1 first = T1(_buf);
|
||||
Unit<DataBuffer> second = cb(first);
|
||||
return second.template cast<T2>();
|
||||
}
|
||||
|
||||
private:
|
||||
DataBuffer _buf;
|
||||
};
|
||||
|
||||
template <typename DataBuffer, typename... Types>
|
||||
class Sum {
|
||||
private:
|
||||
template <size_t I, typename... Elements>
|
||||
struct Selector;
|
||||
template <size_t I, typename Head, typename... Tail>
|
||||
struct Selector<I, Head, Tail...> {
|
||||
using type = typename std::conditional<
|
||||
I == 0,
|
||||
Head,
|
||||
typename Selector<I - 1, Tail...>::type>::type;
|
||||
};
|
||||
template <size_t I>
|
||||
struct Selector<I> {
|
||||
using type = int;
|
||||
};
|
||||
|
||||
public:
|
||||
Sum(DataBuffer db) : _buf(db) {
|
||||
}
|
||||
template <size_t I>
|
||||
typename Selector<I, Types...>::type write() {
|
||||
Pair<DataBuffer, VarInt<DataBuffer>, typename Selector<I, Types...>::type>
|
||||
buf(_buf);
|
||||
return buf.write(I);
|
||||
}
|
||||
template <size_t I, typename F>
|
||||
Unit<DataBuffer> delegate(F const& cb) {
|
||||
auto tail = write<I>();
|
||||
return cb(tail);
|
||||
}
|
||||
|
||||
private:
|
||||
DataBuffer _buf;
|
||||
};
|
||||
|
||||
template <typename DataBuffer, typename T>
|
||||
class ListContents {
|
||||
public:
|
||||
ListContents(DataBuffer db) : _buf(db) {
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
ListContents<DataBuffer, T> delegate(F const& cb) {
|
||||
T head = T(_buf);
|
||||
Unit<DataBuffer> tail = cb(head);
|
||||
return tail.template cast<ListContents<DataBuffer, T>>();
|
||||
}
|
||||
|
||||
Unit<DataBuffer> finish() {
|
||||
return {_buf};
|
||||
}
|
||||
|
||||
private:
|
||||
DataBuffer _buf;
|
||||
};
|
||||
|
||||
template <typename DataBuffer, typename T>
|
||||
using List = Pair<DataBuffer, VarInt<DataBuffer>, ListContents<DataBuffer, T>>;
|
||||
|
||||
} // namespace st
|
||||
} // namespace types
|
||||
} // namespace ObjectIntrospection
|
||||
|
||||
#endif
|
@ -103,6 +103,7 @@ void addIncludes(const TypeGraph& typeGraph,
|
||||
std::set<std::string_view> 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<const Container*>(&t)) {
|
||||
@ -425,7 +426,7 @@ void addGetSizeFuncDefs(const TypeGraph& typeGraph,
|
||||
void addStandardTypeHandlers(std::string& code) {
|
||||
code += R"(
|
||||
template <typename DB, typename T>
|
||||
StaticTypes::Unit<DB>
|
||||
types::st::Unit<DB>
|
||||
getSizeType(const T &t, typename TypeHandler<DB, T>::type returnArg) {
|
||||
JLOG("obj @");
|
||||
JLOGPTR(&t);
|
||||
@ -436,8 +437,8 @@ void addStandardTypeHandlers(std::string& code) {
|
||||
code += R"(
|
||||
template<typename DB, typename T0, long unsigned int N>
|
||||
struct TypeHandler<DB, OIArray<T0, N>> {
|
||||
using type = StaticTypes::List<DB, typename TypeHandler<DB, T0>::type>;
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
using type = types::st::List<DB, typename TypeHandler<DB, T0>::type>;
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const OIArray<T0, N> &container,
|
||||
typename TypeHandler<DB, OIArray<T0,N>>::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<DB, ";
|
||||
typeStaticType += "types::st::Pair<DB, ";
|
||||
pairs++;
|
||||
}
|
||||
|
||||
@ -479,7 +480,7 @@ void getClassTypeHandler(const Class& c, std::string& code) {
|
||||
typeStaticType += std::string(pairs, '>');
|
||||
|
||||
if (typeStaticType.empty()) {
|
||||
typeStaticType = "StaticTypes::Unit<DB>";
|
||||
typeStaticType = "types::st::Unit<DB>";
|
||||
}
|
||||
}
|
||||
|
||||
@ -513,7 +514,7 @@ template <typename DB>
|
||||
class TypeHandler<DB, %1%> {
|
||||
public:
|
||||
using type = %2%;
|
||||
static StaticTypes::Unit<DB> %3%(
|
||||
static types::st::Unit<DB> %3%(
|
||||
const %1%& t,
|
||||
typename TypeHandler<DB, %1%>::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";
|
||||
|
158
oi/FuncGen.cpp
158
oi/FuncGen.cpp
@ -286,11 +286,11 @@ void FuncGen::DefineTopLevelGetSizeRefTyped(std::string& testCode,
|
||||
JLOGPTR(&t);
|
||||
using DataBufferType = OIInternal::TypeHandler<DataBuffer::DataSegment, OIInternal::__ROOT_TYPE__>::type;
|
||||
DataBufferType db = DataBuffer::DataSegment(dataSegOffset);
|
||||
StaticTypes::Unit<DataBuffer::DataSegment> out = OIInternal::getSizeType<DataBuffer::DataSegment>(t, db);
|
||||
StaticTypes::Unit<DataBuffer::DataSegment> final = out.template cast<StaticTypes::Pair<
|
||||
types::st::Unit<DataBuffer::DataSegment> out = OIInternal::getSizeType<DataBuffer::DataSegment>(t, db);
|
||||
types::st::Unit<DataBuffer::DataSegment> final = out.template cast<types::st::Pair<
|
||||
DataBuffer::DataSegment,
|
||||
StaticTypes::VarInt<DataBuffer::DataSegment>,
|
||||
StaticTypes::VarInt<DataBuffer::DataSegment>
|
||||
types::st::VarInt<DataBuffer::DataSegment>,
|
||||
types::st::VarInt<DataBuffer::DataSegment>
|
||||
>>()
|
||||
.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<T>) {
|
||||
return std::type_identity<StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
StaticTypes::Sum<DB,
|
||||
StaticTypes::Unit<DB>,
|
||||
return std::type_identity<types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
types::st::Sum<DB,
|
||||
types::st::Unit<DB>,
|
||||
typename TypeHandler<DB, std::remove_pointer_t<T>>::type
|
||||
>>>();
|
||||
} else {
|
||||
return std::type_identity<StaticTypes::Unit<DB>>();
|
||||
return std::type_identity<types::st::Unit<DB>>();
|
||||
}
|
||||
}
|
||||
public:
|
||||
using type = typename decltype(choose_type())::type;
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const T& t,
|
||||
typename TypeHandler<DB, T>::type returnArg) {
|
||||
if constexpr(std::is_pointer_v<T>) {
|
||||
@ -507,145 +507,9 @@ void FuncGen::DefineBasicTypeHandlers(std::string& testCode) {
|
||||
template <typename DB>
|
||||
class TypeHandler<DB, void> {
|
||||
public:
|
||||
using type = StaticTypes::Unit<DB>;
|
||||
using type = types::st::Unit<DB>;
|
||||
};
|
||||
)";
|
||||
|
||||
testCode.append(handlers);
|
||||
}
|
||||
|
||||
void FuncGen::DefineStaticTypes(std::string& testCode) {
|
||||
constexpr std::string_view unitType = R"(
|
||||
template <typename DataBuffer>
|
||||
class Unit {
|
||||
public:
|
||||
Unit(DataBuffer db) : _buf(db) {}
|
||||
|
||||
size_t offset() {
|
||||
return _buf.offset();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T cast() {
|
||||
return T(_buf);
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
Unit<DataBuffer>
|
||||
delegate(F const& cb) {
|
||||
return cb(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
DataBuffer _buf;
|
||||
};
|
||||
)";
|
||||
|
||||
constexpr std::string_view varintType = R"(
|
||||
template <typename DataBuffer>
|
||||
class VarInt {
|
||||
public:
|
||||
VarInt(DataBuffer db) : _buf(db) {}
|
||||
|
||||
Unit<DataBuffer> write(uint64_t val) {
|
||||
while (val >= 128) {
|
||||
_buf.write_byte(0x80 | (val & 0x7f));
|
||||
val >>= 7;
|
||||
}
|
||||
_buf.write_byte(uint8_t(val));
|
||||
return Unit<DataBuffer>(_buf);
|
||||
}
|
||||
|
||||
private:
|
||||
DataBuffer _buf;
|
||||
};
|
||||
)";
|
||||
|
||||
constexpr std::string_view pairType = R"(
|
||||
template <typename DataBuffer, typename T1, typename T2>
|
||||
class Pair {
|
||||
public:
|
||||
Pair(DataBuffer db) : _buf(db) {}
|
||||
template <class U>
|
||||
T2 write(U val) {
|
||||
Unit<DataBuffer> second = T1(_buf).write(val);
|
||||
return second.template cast<T2>();
|
||||
}
|
||||
template <typename F>
|
||||
T2 delegate(F const& cb) {
|
||||
T1 first = T1(_buf);
|
||||
Unit<DataBuffer> second = cb(first);
|
||||
return second.template cast<T2>();
|
||||
}
|
||||
private:
|
||||
DataBuffer _buf;
|
||||
};
|
||||
)";
|
||||
|
||||
constexpr std::string_view sumType = R"(
|
||||
template <typename DataBuffer, typename... Types>
|
||||
class Sum {
|
||||
private:
|
||||
template <size_t I, typename... Elements>
|
||||
struct Selector;
|
||||
template <size_t I, typename Head, typename... Tail>
|
||||
struct Selector<I, Head, Tail...> {
|
||||
using type = typename std::conditional<I == 0, Head, typename Selector<I - 1, Tail...>::type>::type;
|
||||
};
|
||||
template<size_t I>
|
||||
struct Selector<I> {
|
||||
using type = int;
|
||||
};
|
||||
public:
|
||||
Sum(DataBuffer db) : _buf(db) {}
|
||||
template <size_t I>
|
||||
typename Selector<I, Types...>::type write() {
|
||||
Pair<DataBuffer, VarInt<DataBuffer>, typename Selector<I, Types...>::type> buf(_buf);
|
||||
return buf.write(I);
|
||||
}
|
||||
template <size_t I, typename F>
|
||||
Unit<DataBuffer> delegate(F const& cb) {
|
||||
auto tail = write<I>();
|
||||
return cb(tail);
|
||||
}
|
||||
private:
|
||||
DataBuffer _buf;
|
||||
};
|
||||
)";
|
||||
|
||||
constexpr std::string_view listType = R"(
|
||||
template <typename DataBuffer, typename T>
|
||||
class ListContents {
|
||||
public:
|
||||
ListContents(DataBuffer db) : _buf(db) {}
|
||||
|
||||
template<typename F>
|
||||
ListContents<DataBuffer, T> delegate(F const& cb) {
|
||||
T head = T(_buf);
|
||||
Unit<DataBuffer> tail = cb(head);
|
||||
return tail.template cast<ListContents<DataBuffer, T>>();
|
||||
}
|
||||
|
||||
Unit<DataBuffer> finish() {
|
||||
return { _buf };
|
||||
}
|
||||
private:
|
||||
DataBuffer _buf;
|
||||
};
|
||||
|
||||
template <typename DataBuffer, typename T>
|
||||
using List = Pair<DataBuffer, VarInt<DataBuffer>, ListContents<DataBuffer, T>>;
|
||||
)";
|
||||
|
||||
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");
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <boost/range/combine.hpp>
|
||||
#include <boost/scope_exit.hpp>
|
||||
|
||||
#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());
|
||||
|
@ -2908,7 +2908,7 @@ std::optional<std::string> 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) {
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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()
|
||||
|
@ -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<DB> getSizeType(...)` - a function which takes a
|
||||
- `static types::st::Unit<DB> 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 <typename DB, typename T0>
|
||||
struct TypeHandler<DB, std::string<T0>> {
|
||||
using type =
|
||||
StaticTypes::Pair<DB, StaticTypes::VarInt<DB>, StaticTypes::VarInt<DB>>;
|
||||
types::st::Pair<DB, types::st::VarInt<DB>, types::st::VarInt<DB>>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const std::string<T0> & container,
|
||||
typename TypeHandler<DB, std::string<T0>>::type returnArg) {
|
||||
bool sso = ((uintptr_t)container.data() <
|
||||
|
@ -32,9 +32,9 @@ void getSizeType(const %1%<T,N> &container, size_t& returnArg)
|
||||
handler = """
|
||||
template<typename DB, typename T0, long unsigned int N>
|
||||
struct TypeHandler<DB, %1%<T0, N>> {
|
||||
using type = StaticTypes::List<DB, typename TypeHandler<DB, T0>::type>;
|
||||
using type = types::st::List<DB, typename TypeHandler<DB, T0>::type>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0, N> &container,
|
||||
typename TypeHandler<DB, %1%<T0,N>>::type returnArg) {
|
||||
auto tail = returnArg.write(container.size());
|
||||
|
@ -36,11 +36,11 @@ void getSizeType(const %1%<T, Allocator> &container, size_t& returnArg)
|
||||
handler = """
|
||||
template <typename DB, typename T0, typename T1>
|
||||
struct TypeHandler<DB, %1% <T0, T1>> {
|
||||
using type = StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
StaticTypes::List<DB, typename TypeHandler<DB, T0>::type>>;
|
||||
using type = types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
types::st::List<DB, typename TypeHandler<DB, T0>::type>>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1% <T0, T1> & container,
|
||||
typename TypeHandler<DB, %1% <T0, T1>>::type returnArg) {
|
||||
auto tail = returnArg.write((uintptr_t)&container)
|
||||
|
@ -40,9 +40,9 @@ handler = """
|
||||
template <typename DB, typename T0>
|
||||
struct TypeHandler<DB, %1% <T0>> {
|
||||
using type =
|
||||
StaticTypes::Pair<DB, StaticTypes::VarInt<DB>, StaticTypes::VarInt<DB>>;
|
||||
types::st::Pair<DB, types::st::VarInt<DB>, types::st::VarInt<DB>>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1% <T0> & container,
|
||||
typename TypeHandler<DB, %1% <T0>>::type returnArg) {
|
||||
bool sso = ((uintptr_t)container.data() <
|
||||
|
@ -36,11 +36,11 @@ void getSizeType(const %1%<T, Allocator> &container, size_t& returnArg)
|
||||
handler = """
|
||||
template <typename DB, typename T0, typename T1>
|
||||
struct TypeHandler<DB, %1%<T0, T1>> {
|
||||
using type = StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
StaticTypes::List<DB, typename TypeHandler<DB, T0>::type>>;
|
||||
using type = types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
types::st::List<DB, typename TypeHandler<DB, T0>::type>>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0, T1>& container,
|
||||
typename TypeHandler<DB, %1%<T0, T1>>::type returnArg) {
|
||||
auto tail = returnArg.write((uintptr_t)&container)
|
||||
|
@ -41,16 +41,16 @@ void getSizeType(const %1%<E, T, A, Storage> &container, size_t& returnArg)
|
||||
handler = """
|
||||
template <typename DB, typename T0, typename T1, typename T2, typename T3>
|
||||
struct TypeHandler<DB, %1%<T0, T1, T2, T3>> {
|
||||
using type = StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
StaticTypes::VarInt<DB>
|
||||
using type = types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
types::st::VarInt<DB>
|
||||
>>>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0, T1, T2, T3>& container,
|
||||
typename TypeHandler<DB, %1%<T0, T1, T2, T3>>::type returnArg) {
|
||||
auto last = returnArg.write((uintptr_t)container.data())
|
||||
|
@ -36,11 +36,11 @@ void getSizeType(const %1%<T, Allocator> &container, size_t& returnArg)
|
||||
handler = """
|
||||
template <typename DB, typename T0, typename T1>
|
||||
struct TypeHandler<DB, %1% <T0, T1>> {
|
||||
using type = StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
StaticTypes::List<DB, typename TypeHandler<DB, T0>::type>>;
|
||||
using type = types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
types::st::List<DB, typename TypeHandler<DB, T0>::type>>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1% <T0, T1> & container,
|
||||
typename TypeHandler<DB, %1% <T0, T1>>::type returnArg) {
|
||||
auto tail = returnArg.write((uintptr_t)&container)
|
||||
|
@ -36,12 +36,12 @@ void getSizeType(const %1%<Key,T,Compare,Allocator> &container, size_t& returnAr
|
||||
handler = """
|
||||
template <typename DB, typename T0, typename T1, typename T2, typename T3>
|
||||
struct TypeHandler<DB, %1%<T0, T1, T2, T3>> {
|
||||
using type = StaticTypes::List<DB, StaticTypes::Pair<DB,
|
||||
using type = types::st::List<DB, types::st::Pair<DB,
|
||||
typename TypeHandler<DB, T0>::type,
|
||||
typename TypeHandler<DB, T1>::type
|
||||
>>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0, T1, T2, T3>& container,
|
||||
typename TypeHandler<DB, %1%<T0, T1, T2, T3>>::type returnArg) {
|
||||
auto tail = returnArg.write(container.size());
|
||||
|
@ -31,12 +31,12 @@ void getSizeType(const %1%<T>& container, size_t& returnArg) {
|
||||
handler = """
|
||||
template <typename DB, typename T0>
|
||||
struct TypeHandler<DB, %1%<T0>> {
|
||||
using type = StaticTypes::Sum<DB,
|
||||
StaticTypes::Unit<DB>,
|
||||
using type = types::st::Sum<DB,
|
||||
types::st::Unit<DB>,
|
||||
typename TypeHandler<DB, T0>::type
|
||||
>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0>& container,
|
||||
typename TypeHandler<DB, %1%<T0>>::type returnArg) {
|
||||
if (container) {
|
||||
|
@ -29,11 +29,11 @@ void getSizeType(const %1%<P,Q> &container, size_t& returnArg)
|
||||
handler = """
|
||||
template <typename DB, typename T0, typename T1>
|
||||
struct TypeHandler<DB, %1%<T0, T1>> {
|
||||
using type = StaticTypes::Pair<DB,
|
||||
using type = types::st::Pair<DB,
|
||||
typename TypeHandler<DB, T0>::type,
|
||||
typename TypeHandler<DB, T1>::type>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0, T1> & container,
|
||||
typename TypeHandler<DB, %1%<T0, T1>>::type returnArg) {
|
||||
return OIInternal::getSizeType<DB>(
|
||||
|
@ -36,11 +36,11 @@ void getSizeType(const %1%<T, Container, Cmp> &containerAdapter, size_t& returnA
|
||||
handler = """
|
||||
template <typename DB, typename T0, typename T1, typename T2>
|
||||
struct TypeHandler<DB, %1%<T0, T1, T2>> {
|
||||
using type = StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
using type = types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
typename TypeHandler<DB, T1>::type>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0, T1, T2>& container,
|
||||
typename TypeHandler<DB, %1%<T0, T1, T2>>::type returnArg) {
|
||||
auto tail = returnArg.write((uintptr_t)&container);
|
||||
|
@ -35,11 +35,11 @@ void getSizeType(const %1%<T, Container> &containerAdapter, size_t& returnArg)
|
||||
handler = """
|
||||
template <typename DB, typename T0, typename T1>
|
||||
struct TypeHandler<DB, %1%<T0, T1>> {
|
||||
using type = StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
using type = types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
typename TypeHandler<DB, T1>::type>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1% <T0, T1> & container,
|
||||
typename TypeHandler<DB, %1% <T0, T1>>::type returnArg) {
|
||||
auto tail = returnArg.write((uintptr_t)&container);
|
||||
|
@ -33,14 +33,14 @@ void getSizeType(const %1%<T> &ref, size_t& returnArg)
|
||||
handler = """
|
||||
template <typename DB, typename T0>
|
||||
struct TypeHandler<DB, %1%<T0>> {
|
||||
using type = StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
StaticTypes::Sum<DB,
|
||||
StaticTypes::Unit<DB>,
|
||||
using type = types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
types::st::Sum<DB,
|
||||
types::st::Unit<DB>,
|
||||
typename TypeHandler<DB, T0>::type
|
||||
>>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0>& container,
|
||||
typename TypeHandler<DB, %1%<T0>>::type returnArg) {
|
||||
auto r0 = returnArg.write((uintptr_t)&(container.get()));
|
||||
|
@ -38,13 +38,13 @@ void getSizeType(const %1%<T, Allocator> &container, size_t& returnArg)
|
||||
handler = """
|
||||
template <typename DB, typename T0>
|
||||
struct TypeHandler<DB, %1% <T0>> {
|
||||
using type = StaticTypes::Pair<
|
||||
DB, StaticTypes::VarInt<DB>,
|
||||
StaticTypes::Pair<
|
||||
DB, StaticTypes::VarInt<DB>,
|
||||
StaticTypes::List<DB, typename TypeHandler<DB, T0>::type>>>;
|
||||
using type = types::st::Pair<
|
||||
DB, types::st::VarInt<DB>,
|
||||
types::st::Pair<
|
||||
DB, types::st::VarInt<DB>,
|
||||
types::st::List<DB, typename TypeHandler<DB, T0>::type>>>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1% <T0> & container,
|
||||
typename TypeHandler<DB, %1% <T0>>::type returnArg) {
|
||||
auto tail = returnArg.write((uintptr_t)&container)
|
||||
|
@ -39,11 +39,11 @@ void getSizeType(const %1%<Key, Compare, Alloc> &container, size_t& returnArg)
|
||||
handler = """
|
||||
template <typename DB, typename T0, typename T1, typename T2>
|
||||
struct TypeHandler<DB, %1% <T0, T1, T2>> {
|
||||
using type = StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
StaticTypes::List<DB, typename TypeHandler<DB, T0>::type>>;
|
||||
using type = types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
types::st::List<DB, typename TypeHandler<DB, T0>::type>>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0, T1, T2>& container,
|
||||
typename TypeHandler<DB, %1%<T0, T1, T2>>::type returnArg) {
|
||||
constexpr size_t nodeSize = sizeof(typename %1%<T0, T1, T2>::node_type);
|
||||
|
@ -39,15 +39,15 @@ template <typename DB, typename T0>
|
||||
struct TypeHandler<DB, %1%<T0>> {
|
||||
using type = typename std::conditional<
|
||||
std::is_void<T0>::value,
|
||||
StaticTypes::Unit<DB>,
|
||||
StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
StaticTypes::Sum<DB,
|
||||
StaticTypes::Unit<DB>,
|
||||
types::st::Unit<DB>,
|
||||
types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
types::st::Sum<DB,
|
||||
types::st::Unit<DB>,
|
||||
typename TypeHandler<DB, T0>::type
|
||||
>>>::type;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0>& container,
|
||||
typename TypeHandler<DB, %1%<T0>>::type returnArg) {
|
||||
if constexpr (!std::is_void<T0>::value) {
|
||||
|
@ -34,11 +34,11 @@ void getSizeType(const %1%<T,Compare, Allocator, GrowthPolicy, Container> &conta
|
||||
handler = """
|
||||
template <typename DB, typename T0, typename T1, typename T2, typename T3, typename T4>
|
||||
struct TypeHandler<DB, %1%<T0, T1, T2, T3, T4>> {
|
||||
using type = StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
using type = types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
typename TypeHandler<DB, T4>::type>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0, T1, T2, T3, T4>& container,
|
||||
typename TypeHandler<DB, %1%<T0, T1, T2, T3, T4>>::type returnArg) {
|
||||
auto tail = returnArg.write((uintptr_t)&container);
|
||||
|
@ -35,11 +35,11 @@ void getSizeType(const %1%<T, Container> &containerAdapter, size_t& returnArg)
|
||||
handler = """
|
||||
template <typename DB, typename T0, typename T1>
|
||||
struct TypeHandler<DB, %1%<T0, T1>> {
|
||||
using type = StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
using type = types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
typename TypeHandler<DB, T1>::type>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1% <T0, T1> & container,
|
||||
typename TypeHandler<DB, %1% <T0, T1>>::type returnArg) {
|
||||
auto tail = returnArg.write((uintptr_t)&container);
|
||||
|
@ -40,14 +40,14 @@ void getSizeType(const %1%<K, T, C, A> &container, size_t& returnArg)
|
||||
handler = """
|
||||
template <typename DB, typename T0, typename T1, typename T2, typename T3>
|
||||
struct TypeHandler<DB, %1%<T0, T1, T2, T3>> {
|
||||
using type = StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
StaticTypes::List<DB, StaticTypes::Pair<DB,
|
||||
using type = types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
types::st::List<DB, types::st::Pair<DB,
|
||||
typename TypeHandler<DB, T0>::type,
|
||||
typename TypeHandler<DB, T1>::type
|
||||
>>>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0, T1, T2, T3>& container,
|
||||
typename TypeHandler<DB, %1%<T0, T1, T2, T3>>::type returnArg) {
|
||||
constexpr size_t nodeSize = sizeof(typename %1%<T0, T1, T2, T3>::node_type);
|
||||
|
@ -42,16 +42,16 @@ void getSizeType(const %1%<K, T, H, KE, A> &container, size_t& returnArg)
|
||||
handler = """
|
||||
template <typename DB, typename T0, typename T1, typename T2, typename T3, typename T4>
|
||||
struct TypeHandler<DB, %1%<T0, T1, T2, T3, T4>> {
|
||||
using type = StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
StaticTypes::List<DB, StaticTypes::Pair<DB,
|
||||
using type = types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
types::st::List<DB, types::st::Pair<DB,
|
||||
typename TypeHandler<DB, T0>::type,
|
||||
typename TypeHandler<DB, T1>::type
|
||||
>>>>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0, T1, T2, T3, T4>& container,
|
||||
typename TypeHandler<DB, %1%<T0, T1, T2, T3, T4>>::type returnArg) {
|
||||
constexpr size_t nodeSize = sizeof(typename %1%<T0, T1, T2, T3, T4>::node_type);
|
||||
|
@ -39,9 +39,9 @@ void getSizeType(const %1%<Types...> &container, size_t& returnArg)
|
||||
handler = """
|
||||
template <typename DB, typename... Types>
|
||||
struct TypeHandler<DB, %1%<Types...>> {
|
||||
using type = StaticTypes::Sum<DB, typename TypeHandler<DB, Types>::type..., StaticTypes::Unit<DB>>;
|
||||
using type = types::st::Sum<DB, typename TypeHandler<DB, Types>::type..., types::st::Unit<DB>>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<Types...>& container,
|
||||
typename TypeHandler<DB, %1%<Types...>>::type returnArg) {
|
||||
return getSizeTypeRecursive(container, returnArg);
|
||||
@ -49,7 +49,7 @@ struct TypeHandler<DB, %1%<Types...>> {
|
||||
|
||||
private:
|
||||
template <size_t I = 0>
|
||||
static StaticTypes::Unit<DB> getSizeTypeRecursive(
|
||||
static types::st::Unit<DB> getSizeTypeRecursive(
|
||||
const %1%<Types...>& container,
|
||||
typename TypeHandler<DB, %1%<Types...>>::type returnArg) {
|
||||
if constexpr (I < sizeof...(Types)) {
|
||||
|
@ -40,15 +40,15 @@ template <typename DB, typename T0, typename T1>
|
||||
struct TypeHandler<DB, %1%<T0,T1>> {
|
||||
using type = typename std::conditional<
|
||||
std::is_void<T0>::value,
|
||||
StaticTypes::Unit<DB>,
|
||||
StaticTypes::Pair<DB,
|
||||
StaticTypes::VarInt<DB>,
|
||||
StaticTypes::Sum<DB,
|
||||
StaticTypes::Unit<DB>,
|
||||
types::st::Unit<DB>,
|
||||
types::st::Pair<DB,
|
||||
types::st::VarInt<DB>,
|
||||
types::st::Sum<DB,
|
||||
types::st::Unit<DB>,
|
||||
typename TypeHandler<DB, T0>::type
|
||||
>>>::type;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0,T1>& container,
|
||||
typename TypeHandler<DB, %1%<T0,T1>>::type returnArg) {
|
||||
if constexpr (!std::is_void<T0>::value) {
|
||||
|
@ -40,13 +40,13 @@ void getSizeType(const %1%<Key, Hasher, KeyEqual, Alloc> &container, size_t& ret
|
||||
handler = """
|
||||
template <typename DB, typename T0, typename T1, typename T2, typename T3>
|
||||
struct TypeHandler<DB, %1%<T0, T1, T2, T3>> {
|
||||
using type = StaticTypes::Pair<
|
||||
DB, StaticTypes::VarInt<DB>,
|
||||
StaticTypes::Pair<
|
||||
DB, StaticTypes::VarInt<DB>,
|
||||
StaticTypes::List<DB, typename TypeHandler<DB, T0>::type>>>;
|
||||
using type = types::st::Pair<
|
||||
DB, types::st::VarInt<DB>,
|
||||
types::st::Pair<
|
||||
DB, types::st::VarInt<DB>,
|
||||
types::st::List<DB, typename TypeHandler<DB, T0>::type>>>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0, T1, T2, T3>& container,
|
||||
typename TypeHandler<DB, %1%<T0, T1, T2, T3>>::type returnArg) {
|
||||
constexpr size_t nodeSize = sizeof(typename %1%<T0, T1, T2, T3>::node_type);
|
||||
|
@ -27,9 +27,9 @@ void getSizeType(const %1%<T> &s_ptr, size_t& returnArg)
|
||||
handler = """
|
||||
template <typename DB, typename T0>
|
||||
struct TypeHandler<DB, %1%<T0>> {
|
||||
using type = StaticTypes::Unit<DB>;
|
||||
using type = types::st::Unit<DB>;
|
||||
|
||||
static StaticTypes::Unit<DB> getSizeType(
|
||||
static types::st::Unit<DB> getSizeType(
|
||||
const %1%<T0>& container,
|
||||
typename TypeHandler<DB, %1%<T0>>::type returnArg) {
|
||||
return returnArg;
|
||||
|
Loading…
Reference in New Issue
Block a user