mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-09-19 19:19:05 +01:00
EnforceCompatibility: Follow OICodeGen's typesToStub list
This commit is contained in:
parent
8b7bfbe4c0
commit
e19641efad
@ -62,32 +62,6 @@ std::unique_ptr<OICodeGen> OICodeGen::buildFromConfig(const Config& c,
|
|||||||
|
|
||||||
OICodeGen::OICodeGen(const Config& c, SymbolService& s)
|
OICodeGen::OICodeGen(const Config& c, SymbolService& s)
|
||||||
: config{c}, symbols{s} {
|
: config{c}, symbols{s} {
|
||||||
// TODO: Should folly::Range just be added as a container?
|
|
||||||
auto typesToStub = std::array{
|
|
||||||
"SharedMutex",
|
|
||||||
"EnumMap",
|
|
||||||
"function",
|
|
||||||
"Function",
|
|
||||||
"ConcurrentHashMap",
|
|
||||||
"DelayedDestruction",
|
|
||||||
"McServerSession",
|
|
||||||
"Range",
|
|
||||||
"ReadResumableHandle",
|
|
||||||
"CountedIntrusiveList",
|
|
||||||
"EventBaseAtomicNotificationQueue",
|
|
||||||
/* Temporary IOBuf ring used for scattered read/write.
|
|
||||||
* It's only used for communication and should be empty the rest of the
|
|
||||||
* time. So we shouldn't loose too much visibility by stubbing it out.
|
|
||||||
*/
|
|
||||||
"IOBufIovecBuilder",
|
|
||||||
/* struct event from libevent
|
|
||||||
* Its linked lists are not always initialised, leading to SegV in our JIT
|
|
||||||
* code. We can't stub the linked list themselves, as they're anonymous
|
|
||||||
* structs.
|
|
||||||
*/
|
|
||||||
"event",
|
|
||||||
};
|
|
||||||
|
|
||||||
membersToStub = config.membersToStub;
|
membersToStub = config.membersToStub;
|
||||||
for (const auto& type : typesToStub) {
|
for (const auto& type : typesToStub) {
|
||||||
membersToStub.emplace_back(type, "*");
|
membersToStub.emplace_back(type, "*");
|
||||||
|
@ -69,6 +69,32 @@ class OICodeGen {
|
|||||||
std::vector<std::string> toOptions() const;
|
std::vector<std::string> toOptions() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: Should folly::Range just be added as a container?
|
||||||
|
static constexpr auto typesToStub = std::array{
|
||||||
|
"SharedMutex",
|
||||||
|
"EnumMap",
|
||||||
|
"function",
|
||||||
|
"Function",
|
||||||
|
"ConcurrentHashMap",
|
||||||
|
"DelayedDestruction",
|
||||||
|
"McServerSession",
|
||||||
|
"Range",
|
||||||
|
"ReadResumableHandle",
|
||||||
|
"CountedIntrusiveList",
|
||||||
|
"EventBaseAtomicNotificationQueue",
|
||||||
|
/* Temporary IOBuf ring used for scattered read/write.
|
||||||
|
* It's only used for communication and should be empty the rest of the
|
||||||
|
* time. So we shouldn't loose too much visibility by stubbing it out.
|
||||||
|
*/
|
||||||
|
"IOBufIovecBuilder",
|
||||||
|
/* struct event from libevent
|
||||||
|
* Its linked lists are not always initialised, leading to SegV in our JIT
|
||||||
|
* code. We can't stub the linked list themselves, as they're anonymous
|
||||||
|
* structs.
|
||||||
|
*/
|
||||||
|
"event",
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Private constructor. Please use the fallible `OICodeGen::buildFromConfig`
|
// Private constructor. Please use the fallible `OICodeGen::buildFromConfig`
|
||||||
// for the expected behaviour.
|
// for the expected behaviour.
|
||||||
|
@ -15,12 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
#include "EnforceCompatibility.h"
|
#include "EnforceCompatibility.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "AddPadding.h"
|
#include "AddPadding.h"
|
||||||
#include "Flattener.h"
|
#include "Flattener.h"
|
||||||
#include "TypeGraph.h"
|
#include "TypeGraph.h"
|
||||||
#include "TypeIdentifier.h"
|
#include "TypeIdentifier.h"
|
||||||
|
#include "oi/OICodeGen.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace type_graph {
|
||||||
|
|
||||||
@ -42,7 +44,21 @@ void EnforceCompatibility::accept(Type& type) {
|
|||||||
type.accept(*this);
|
type.accept(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
bool isTypeToStub(const Class& c) {
|
||||||
|
auto it = std::ranges::find_if(OICodeGen::typesToStub,
|
||||||
|
[&c](const auto& typeToStub) {
|
||||||
|
return c.name().starts_with(typeToStub);
|
||||||
|
});
|
||||||
|
return it != OICodeGen::typesToStub.end();
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void EnforceCompatibility::visit(Class& c) {
|
void EnforceCompatibility::visit(Class& c) {
|
||||||
|
if (isTypeToStub(c)) {
|
||||||
|
c.members.clear();
|
||||||
|
}
|
||||||
|
|
||||||
for (auto& param : c.templateParams) {
|
for (auto& param : c.templateParams) {
|
||||||
accept(param.type());
|
accept(param.type());
|
||||||
}
|
}
|
||||||
|
@ -17,3 +17,16 @@ TEST(EnforceCompatibilityTest, ParentContainers) {
|
|||||||
[0] Class: MyClass (size: 24)
|
[0] Class: MyClass (size: 24)
|
||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(EnforceCompatibilityTest, TypesToStub) {
|
||||||
|
test(EnforceCompatibility::createPass(), R"(
|
||||||
|
[0] Class: EnumMap (size: 8)
|
||||||
|
Member: a (offset: 0)
|
||||||
|
Primitive: int32_t
|
||||||
|
Member: b (offset: 4)
|
||||||
|
Primitive: int32_t
|
||||||
|
)",
|
||||||
|
R"(
|
||||||
|
[0] Class: EnumMap (size: 8)
|
||||||
|
)");
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user