diff --git a/compiler/src/main/cpp/capnpc-java.c++ b/compiler/src/main/cpp/capnpc-java.c++ index cc64838..96bc5f1 100644 --- a/compiler/src/main/cpp/capnpc-java.c++ +++ b/compiler/src/main/cpp/capnpc-java.c++ @@ -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()) { diff --git a/compiler/src/test/scala/org/capnproto/EncodingSuite.scala b/compiler/src/test/scala/org/capnproto/EncodingSuite.scala index 5603abf..8a62f47 100644 --- a/compiler/src/test/scala/org/capnproto/EncodingSuite.scala +++ b/compiler/src/test/scala/org/capnproto/EncodingSuite.scala @@ -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) diff --git a/project/build.scala b/project/build.scala index d46a5e9..8540020 100644 --- a/project/build.scala +++ b/project/build.scala @@ -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."); }