Generate generic pipelines
This commit is contained in:
parent
e19faf0b81
commit
9268494421
1 changed files with 22 additions and 6 deletions
|
@ -1432,6 +1432,7 @@ private:
|
||||||
">");
|
">");
|
||||||
}
|
}
|
||||||
kj::String readerTypeParams = readerTypeParamsTree.flatten();
|
kj::String readerTypeParams = readerTypeParamsTree.flatten();
|
||||||
|
auto readerTypeParamsInferred = (hasTypeParams ? "<>" : "");
|
||||||
kj::String builderTypeParams = builderTypeParamsTree.flatten();
|
kj::String builderTypeParams = builderTypeParamsTree.flatten();
|
||||||
kj::String factoryTypeParams = factoryTypeParamsTree.flatten();
|
kj::String factoryTypeParams = factoryTypeParamsTree.flatten();
|
||||||
|
|
||||||
|
@ -1443,6 +1444,14 @@ private:
|
||||||
return kj::strTree(spaces(indent), " final org.capnproto.PointerFactory<", p, "_Builder, ", p, "_Reader> ", p, "_Factory;\n");
|
return kj::strTree(spaces(indent), " final org.capnproto.PointerFactory<", p, "_Builder, ", p, "_Reader> ", p, "_Factory;\n");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
kj::String factoryRef = hasTypeParams
|
||||||
|
? kj::str(kj::strTree("newFactory(",
|
||||||
|
kj::StringTree(KJ_MAP(p, typeParamVec) {
|
||||||
|
return kj::strTree(p, "_Factory");
|
||||||
|
}, ", ")
|
||||||
|
, ")"))
|
||||||
|
: kj::str("factory");
|
||||||
|
|
||||||
return StructText {
|
return StructText {
|
||||||
kj::strTree(
|
kj::strTree(
|
||||||
spaces(indent), "public static class ", name, " {\n",
|
spaces(indent), "public static class ", name, " {\n",
|
||||||
|
@ -1453,7 +1462,7 @@ private:
|
||||||
|
|
||||||
spaces(indent), " public static final class Factory", factoryTypeParams, "\n",
|
spaces(indent), " public static final class Factory", factoryTypeParams, "\n",
|
||||||
spaces(indent), " extends org.capnproto.StructFactory<Builder", builderTypeParams, ", Reader", readerTypeParams, ">\n",
|
spaces(indent), " extends org.capnproto.StructFactory<Builder", builderTypeParams, ", Reader", readerTypeParams, ">\n",
|
||||||
spaces(indent), " implements org.capnproto.PipelineFactory<Pipeline> {\n",
|
spaces(indent), " implements org.capnproto.PipelineFactory<Pipeline", readerTypeParams, "> {\n",
|
||||||
factoryMembers.flatten(),
|
factoryMembers.flatten(),
|
||||||
spaces(indent), " public Factory(",
|
spaces(indent), " public Factory(",
|
||||||
factoryArgs.flatten(),
|
factoryArgs.flatten(),
|
||||||
|
@ -1488,8 +1497,12 @@ private:
|
||||||
(hasTypeParams ? kj::strTree("this") : kj::strTree()),
|
(hasTypeParams ? kj::strTree("this") : kj::strTree()),
|
||||||
");\n",
|
");\n",
|
||||||
spaces(indent), " }\n",
|
spaces(indent), " }\n",
|
||||||
spaces(indent), " public Pipeline newPipeline(org.capnproto.RemotePromise<org.capnproto.AnyPointer.Reader> promise) {\n",
|
spaces(indent), " public Pipeline", readerTypeParams, " newPipeline(org.capnproto.RemotePromise<org.capnproto.AnyPointer.Reader> promise) {\n",
|
||||||
spaces(indent), " return new Pipeline(promise);\n",
|
spaces(indent), " return new Pipeline", readerTypeParamsInferred, "(",
|
||||||
|
kj::StringTree(KJ_MAP(p, typeParamVec) {
|
||||||
|
return kj::strTree(p, "_Factory");
|
||||||
|
}, ", "),
|
||||||
|
(hasTypeParams ? ", ": ""), "promise);\n",
|
||||||
spaces(indent), " }\n",
|
spaces(indent), " }\n",
|
||||||
|
|
||||||
spaces(indent), " }\n",
|
spaces(indent), " }\n",
|
||||||
|
@ -1578,9 +1591,12 @@ private:
|
||||||
spaces(indent), " }\n"),
|
spaces(indent), " }\n"),
|
||||||
KJ_MAP(n, nestedTypeDecls) { return kj::mv(n); },
|
KJ_MAP(n, nestedTypeDecls) { return kj::mv(n); },
|
||||||
|
|
||||||
spaces(indent), " public static class Pipeline extends org.capnproto.Pipeline<Reader> {\n",
|
spaces(indent), " public static class Pipeline", readerTypeParams, " extends org.capnproto.Pipeline<Reader", readerTypeParams, "> {\n",
|
||||||
spaces(indent), " public Pipeline(org.capnproto.RemotePromise<org.capnproto.AnyPointer.Reader> remotePromise) {\n",
|
spaces(indent), " public Pipeline(",
|
||||||
spaces(indent), " super(org.capnproto.RemotePromise.fromTypeless(factory, remotePromise));\n",
|
KJ_MAP(p, typeParamVec) {
|
||||||
|
return kj::strTree("org.capnproto.PointerFactory<?,", p, "_Reader> ", p, "_Factory,");
|
||||||
|
}, " org.capnproto.RemotePromise<org.capnproto.AnyPointer.Reader> remotePromise) {\n",
|
||||||
|
spaces(indent), " super(org.capnproto.RemotePromise.fromTypeless(", factoryRef, ", remotePromise));\n",
|
||||||
spaces(indent), " }\n",
|
spaces(indent), " }\n",
|
||||||
KJ_MAP(f, fieldTexts) { return kj::mv(f.pipelineMethodDecls); },
|
KJ_MAP(f, fieldTexts) { return kj::mv(f.pipelineMethodDecls); },
|
||||||
spaces(indent), " }\n",
|
spaces(indent), " }\n",
|
||||||
|
|
Loading…
Reference in a new issue