mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
OICodeGen: Respect ContainerInfo::requiredFeatures
CodeGen v1 and CodeGen v2 must be in sync in order for CodeGen v2 and TreeBuilder v1 to be compatible. This change updates CodeGen v1 to use the same set of containers as CodeGen v2. This specifically fixes "-ftype-graph -Ftree-builder-v2 -Fcapture-thrift-isset" for Thrift types. The integration test "thrift_isset_no_capture" covers this, but this bug was missed as the Thrift tests do not run in CI.
This commit is contained in:
parent
b117150f83
commit
8e8db376d8
@ -126,6 +126,20 @@ const char* containerTypeEnumToStr(ContainerTypeEnum ty) {
|
||||
});
|
||||
}
|
||||
|
||||
oi::detail::FeatureSet requiredFeatures;
|
||||
if (toml::array* arr = (*info)["required_features"].as_array()) {
|
||||
arr->for_each([&](auto&& el) {
|
||||
if constexpr (toml::is_string<decltype(el)>) {
|
||||
oi::detail::Feature f = oi::detail::featureFromStr(*el);
|
||||
if (f == oi::detail::Feature::UnknownFeature) {
|
||||
LOG(WARNING) << "unknown feature in container config: " << el;
|
||||
return;
|
||||
}
|
||||
requiredFeatures[f] = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
std::optional<size_t> allocatorIndex =
|
||||
(*info)["allocatorIndex"].value<size_t>();
|
||||
std::optional<size_t> underlyingContainerIndex =
|
||||
@ -166,6 +180,7 @@ const char* containerTypeEnumToStr(ContainerTypeEnum ty) {
|
||||
allocatorIndex,
|
||||
underlyingContainerIndex,
|
||||
{},
|
||||
requiredFeatures,
|
||||
{
|
||||
std::move(decl),
|
||||
std::move(func),
|
||||
|
@ -58,6 +58,7 @@ struct ContainerInfo {
|
||||
std::optional<size_t> allocatorIndex_,
|
||||
std::optional<size_t> underlyingContainerIndex_,
|
||||
std::vector<size_t> stubTemplateParams_,
|
||||
oi::detail::FeatureSet requiredFeatures,
|
||||
ContainerInfo::Codegen codegen_)
|
||||
: typeName(std::move(typeName_)),
|
||||
matcher(std::move(matcher_)),
|
||||
@ -69,6 +70,7 @@ struct ContainerInfo {
|
||||
allocatorIndex(allocatorIndex_),
|
||||
underlyingContainerIndex(underlyingContainerIndex_),
|
||||
stubTemplateParams(std::move(stubTemplateParams_)),
|
||||
requiredFeatures(requiredFeatures),
|
||||
codegen(std::move(codegen_)) {
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,10 @@ bool OICodeGen::registerContainer(const fs::path& path) {
|
||||
if (!info) {
|
||||
return false;
|
||||
}
|
||||
if (info->requiredFeatures != (config.features & info->requiredFeatures)) {
|
||||
VLOG(1) << "Skipping container (feature conflict): " << info->typeName;
|
||||
return true;
|
||||
}
|
||||
|
||||
VLOG(1) << "registered container, type: " << info->typeName;
|
||||
containerInfoList.emplace_back(std::move(info));
|
||||
|
Loading…
Reference in New Issue
Block a user