Commit 6dbff32e 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 1e32eba6
...@@ -2059,6 +2059,14 @@ private: ...@@ -2059,6 +2059,14 @@ private:
uint64_t id; 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, InterfaceText makeInterfaceText(kj::StringPtr scope, kj::StringPtr name, InterfaceSchema schema,
kj::Array<kj::StringTree> nestedTypeDecls, kj::Array<kj::StringTree> nestedTypeDecls,
const TemplateContext& templateContext) { const TemplateContext& templateContext) {
...@@ -2074,6 +2082,16 @@ private: ...@@ -2074,6 +2082,16 @@ private:
return ExtendInfo { cppFullName(superclass, nullptr), superclass.getProto().getId() }; 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); CppTypeName clientName = cppFullName(schema, nullptr);
clientName.addMemberType("Client"); clientName.addMemberType("Client");
...@@ -2227,7 +2245,7 @@ private: ...@@ -2227,7 +2245,7 @@ private:
" switch (interfaceId) {\n" " switch (interfaceId) {\n"
" case 0x", kj::hex(proto.getId()), "ull:\n" " case 0x", kj::hex(proto.getId()), "ull:\n"
" return dispatchCallInternal(methodId, context);\n", " return dispatchCallInternal(methodId, context);\n",
KJ_MAP(s, superclasses) { KJ_MAP(s, transitiveSuperclasses) {
return kj::strTree( return kj::strTree(
" case 0x", kj::hex(s.id), "ull:\n" " case 0x", kj::hex(s.id), "ull:\n"
" return ", s.typeName, "::Server::dispatchCallInternal(methodId, context);\n"); " return ", s.typeName, "::Server::dispatchCallInternal(methodId, context);\n");
......
...@@ -198,7 +198,7 @@ private: ...@@ -198,7 +198,7 @@ private:
int& callCount; int& callCount;
}; };
class TestExtendsImpl final: public test::TestExtends::Server { class TestExtendsImpl final: public test::TestExtends2::Server {
public: public:
TestExtendsImpl(int& callCount); TestExtendsImpl(int& callCount);
......
...@@ -712,6 +712,8 @@ interface TestExtends extends(TestInterface) { ...@@ -712,6 +712,8 @@ interface TestExtends extends(TestInterface) {
grault @2 () -> TestAllTypes; grault @2 () -> TestAllTypes;
} }
interface TestExtends2 extends(TestExtends) {}
interface TestPipeline { interface TestPipeline {
getCap @0 (n: UInt32, inCap :TestInterface) -> (s: Text, outBox :Box); getCap @0 (n: UInt32, inCap :TestInterface) -> (s: Text, outBox :Box);
testPointers @1 (cap :TestInterface, obj :AnyPointer, list :List(TestInterface)) -> (); 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