factory argument comes first

This commit is contained in:
David Renshaw 2014-05-21 21:20:33 -04:00
parent d3aff83097
commit e233fe1126
2 changed files with 14 additions and 10 deletions

View file

@ -990,10 +990,12 @@ private:
spaces(indent), " public final ", type, ".Reader<", elementReaderType, ">", spaces(indent), " public final ", type, ".Reader<", elementReaderType, ">",
" get", titleCase, "() {\n", " get", titleCase, "() {\n",
spaces(indent), " return new ", type, ".Reader<", 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? // XXX what about lists of non-structs?
typeName(typeBody.getList().getElementType()),".STRUCT_SIZE.preferredListEncoding), ", typeName(typeBody.getList().getElementType()),".STRUCT_SIZE.preferredListEncoding)",
elementReaderType, ".factory);\n", ");\n",
spaces(indent), " }\n", spaces(indent), " }\n",
"\n"), "\n"),
@ -1011,10 +1013,12 @@ private:
spaces(indent), " }\n", spaces(indent), " }\n",
spaces(indent), " public final ", type, ".Builder<", elementBuilderType,">", spaces(indent), " public final ", type, ".Builder<", elementBuilderType,">",
" init", titleCase, "(int size) {\n", " init", titleCase, "(int size) {\n",
spaces(indent), " return new ", type, ".Builder<", elementBuilderType, ">", spaces(indent), " return new ", type, ".Builder<", elementBuilderType, ">(\n",
"(_builder.getPointerField(", offset, ").initStructList(", // XXX what about non-struct lists? spaces(indent), " ", elementBuilderType,".factory,\n",
"size,", typeName(typeBody.getList().getElementType()),".STRUCT_SIZE), ", // XXX what about non-struct lists?
elementBuilderType, ".factory);\n", spaces(indent), " _builder.getPointerField(", offset, ").initStructList(",
"size,", typeName(typeBody.getList().getElementType()),".STRUCT_SIZE)",
");\n",
spaces(indent), " }\n"), spaces(indent), " }\n"),
kj::strTree( kj::strTree(

View file

@ -5,7 +5,7 @@ public final class StructList {
public ListReader reader; public ListReader reader;
public final FromStructReader<T> factory; public final FromStructReader<T> factory;
public Reader(ListReader reader, FromStructReader<T> factory) { public Reader(FromStructReader<T> factory, ListReader reader) {
this.reader = reader; this.reader = reader;
this.factory = factory; this.factory = factory;
} }
@ -23,13 +23,13 @@ public final class StructList {
public ListBuilder builder; public ListBuilder builder;
public final FromStructBuilder<T> factory; public final FromStructBuilder<T> factory;
public Builder(ListBuilder builder, FromStructBuilder<T> factory) { public Builder(FromStructBuilder<T> factory, ListBuilder builder) {
this.builder = builder; this.builder = builder;
this.factory = factory; this.factory = factory;
} }
// init // init
Builder(PointerBuilder builder, int size, FromStructBuilder<T> factory) { Builder(FromStructBuilder<T> factory, PointerBuilder builder, int size) {
this.builder = builder.initStructList(size, factory.structSize()); this.builder = builder.initStructList(size, factory.structSize());
this.factory = factory; this.factory = factory;
} }