diff --git a/compiler/src/main/cpp/capnpc-java.c++ b/compiler/src/main/cpp/capnpc-java.c++ index f17f1f2..437a323 100644 --- a/compiler/src/main/cpp/capnpc-java.c++ +++ b/compiler/src/main/cpp/capnpc-java.c++ @@ -990,10 +990,12 @@ private: spaces(indent), " public final ", type, ".Reader<", elementReaderType, ">", " get", titleCase, "() {\n", spaces(indent), " return new ", type, ".Reader<", - elementReaderType, ">(_reader.getPointerField(", offset, ").getList(", + elementReaderType, ">(\n", + spaces(indent), " ", elementReaderType, ".factory,\n", + spaces(indent), " _reader.getPointerField(", offset, ").getList(", // XXX what about lists of non-structs? - typeName(typeBody.getList().getElementType()),".STRUCT_SIZE.preferredListEncoding), ", - elementReaderType, ".factory);\n", + typeName(typeBody.getList().getElementType()),".STRUCT_SIZE.preferredListEncoding)", + ");\n", spaces(indent), " }\n", "\n"), @@ -1011,10 +1013,12 @@ private: spaces(indent), " }\n", spaces(indent), " public final ", type, ".Builder<", elementBuilderType,">", " init", titleCase, "(int size) {\n", - spaces(indent), " return new ", type, ".Builder<", elementBuilderType, ">", - "(_builder.getPointerField(", offset, ").initStructList(", // XXX what about non-struct lists? - "size,", typeName(typeBody.getList().getElementType()),".STRUCT_SIZE), ", - elementBuilderType, ".factory);\n", + spaces(indent), " return new ", type, ".Builder<", elementBuilderType, ">(\n", + spaces(indent), " ", elementBuilderType,".factory,\n", + // XXX what about non-struct lists? + spaces(indent), " _builder.getPointerField(", offset, ").initStructList(", + "size,", typeName(typeBody.getList().getElementType()),".STRUCT_SIZE)", + ");\n", spaces(indent), " }\n"), kj::strTree( diff --git a/runtime/src/main/java/org/capnproto/StructList.java b/runtime/src/main/java/org/capnproto/StructList.java index 9014788..78a53ff 100644 --- a/runtime/src/main/java/org/capnproto/StructList.java +++ b/runtime/src/main/java/org/capnproto/StructList.java @@ -5,7 +5,7 @@ public final class StructList { public ListReader reader; public final FromStructReader factory; - public Reader(ListReader reader, FromStructReader factory) { + public Reader(FromStructReader factory, ListReader reader) { this.reader = reader; this.factory = factory; } @@ -23,13 +23,13 @@ public final class StructList { public ListBuilder builder; public final FromStructBuilder factory; - public Builder(ListBuilder builder, FromStructBuilder factory) { + public Builder(FromStructBuilder factory, ListBuilder builder) { this.builder = builder; this.factory = factory; } // init - Builder(PointerBuilder builder, int size, FromStructBuilder factory) { + Builder(FromStructBuilder factory, PointerBuilder builder, int size) { this.builder = builder.initStructList(size, factory.structSize()); this.factory = factory; }