Commit ec86305e authored by Kenton Varda's avatar Kenton Varda

Fix but where interface server's transitive superclass's methods weren't…

Fix but where interface server's transitive superclass's methods weren't dispatched correctly -- ouch.
parent 9dc88268
......@@ -2131,6 +2131,14 @@ private:
uint64_t id;
};
void getTransitiveSuperclasses(InterfaceSchema schema, std::map<uint64_t, InterfaceSchema>& map) {
if (map.insert(std::make_pair(schema.getProto().getId(), schema)).second) {
for (auto sup: schema.getSuperclasses()) {
getTransitiveSuperclasses(sup, map);
}
}
}
InterfaceText makeInterfaceText(kj::StringPtr scope, kj::StringPtr name, InterfaceSchema schema,
kj::Array<kj::StringTree> nestedTypeDecls,
const TemplateContext& templateContext) {
......@@ -2146,6 +2154,16 @@ private:
return ExtendInfo { cppFullName(superclass, nullptr), superclass.getProto().getId() };
};
kj::Array<ExtendInfo> transitiveSuperclasses;
{
std::map<uint64_t, InterfaceSchema> map;
getTransitiveSuperclasses(schema, map);
map.erase(schema.getProto().getId());
transitiveSuperclasses = KJ_MAP(entry, map) {
return ExtendInfo { cppFullName(entry.second, nullptr), entry.second.getProto().getId() };
};
}
CppTypeName clientName = cppFullName(schema, nullptr);
clientName.addMemberType("Client");
......@@ -2305,7 +2323,7 @@ private:
" switch (interfaceId) {\n"
" case 0x", kj::hex(proto.getId()), "ull:\n"
" return dispatchCallInternal(methodId, context);\n",
KJ_MAP(s, superclasses) {
KJ_MAP(s, transitiveSuperclasses) {
return kj::strTree(
" case 0x", kj::hex(s.id), "ull:\n"
" return ", s.typeName, "::Server::dispatchCallInternal(methodId, context);\n");
......
......@@ -210,7 +210,7 @@ private:
int& callCount;
};
class TestExtendsImpl final: public test::TestExtends::Server {
class TestExtendsImpl final: public test::TestExtends2::Server {
public:
TestExtendsImpl(int& callCount);
......
......@@ -718,6 +718,8 @@ interface TestExtends extends(TestInterface) {
grault @2 () -> TestAllTypes;
}
interface TestExtends2 extends(TestExtends) {}
interface TestPipeline {
getCap @0 (n: UInt32, inCap :TestInterface) -> (s: Text, outBox :Box);
testPointers @1 (cap :TestInterface, obj :AnyPointer, list :List(TestInterface)) -> ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment