Fully qualify class names so that cross-package references work.
This commit is contained in:
parent
d3fdf4d17d
commit
037bebfb9c
3 changed files with 17 additions and 3 deletions
|
@ -202,12 +202,17 @@ private:
|
|||
auto node = schema.getProto();
|
||||
if (node.getScopeId() == 0) {
|
||||
usedImports.insert(node.getId());
|
||||
kj::String className;
|
||||
kj::String package;
|
||||
for (auto annotation: node.getAnnotations()) {
|
||||
if (annotation.getId() == OUTER_CLASSNAME_ANNOTATION_ID) {
|
||||
return kj::strTree("", toTitleCase(annotation.getValue().getText()));
|
||||
className = toTitleCase(annotation.getValue().getText());
|
||||
}
|
||||
if (annotation.getId() == PACKAGE_ANNOTATION_ID) {
|
||||
package = kj::str(annotation.getValue().getText());
|
||||
}
|
||||
}
|
||||
return kj::strTree(" ");//kj::strTree(outerClassName);
|
||||
return kj::strTree(kj::mv(package), ".", kj::mv(className));
|
||||
} else {
|
||||
Schema parent = schemaLoader.get(node.getScopeId());
|
||||
for (auto nested: parent.getProto().getNestedNodes()) {
|
||||
|
|
|
@ -600,6 +600,15 @@ class EncodingSuite extends FunSuite {
|
|||
Serialize.computeSerializedSizeInWords(builder) should equal (4)
|
||||
}
|
||||
|
||||
test("Import") {
|
||||
val builder = new MessageBuilder()
|
||||
val root = builder.initRoot(org.capnproto.testimport.TestImport.Foo.factory)
|
||||
val field = root.initImportedStruct()
|
||||
TestUtil.initTestMessage(field)
|
||||
TestUtil.checkTestMessage(field)
|
||||
TestUtil.checkTestMessage(field.asReader())
|
||||
}
|
||||
|
||||
// to debug, do this:
|
||||
//Serialize.write((new java.io.FileOutputStream("/Users/dwrensha/Desktop/test.dat")).getChannel(),
|
||||
// message)
|
||||
|
|
|
@ -65,7 +65,7 @@ object Build extends sbt.Build {
|
|||
val compileTestSchema = taskKey[Unit]("Run capnpc-java on test schema")
|
||||
val compileTestSchemaTask = compileTestSchema := {
|
||||
val result0 = "mkdir -p compiler/src/test/generated".!!
|
||||
val result = "capnp compile -I compiler/src/main/schema/ --src-prefix=compiler/src/test/schema/ -o./capnpc-java:compiler/src/test/generated compiler/src/test/schema/test.capnp".!!
|
||||
val result = "capnp compile -I compiler/src/main/schema/ --src-prefix=compiler/src/test/schema/ -o./capnpc-java:compiler/src/test/generated compiler/src/test/schema/test.capnp compiler/src/test/schema/test-import.capnp".!!
|
||||
println(s"**** CodeGen for test.capnp started\n$result\n**** CodeGen complete.");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue