init StructList.Builder
This commit is contained in:
parent
8b2655623f
commit
ddbab77252
2 changed files with 18 additions and 15 deletions
|
@ -968,23 +968,17 @@ private:
|
||||||
return FieldText {
|
return FieldText {
|
||||||
kj::strTree(
|
kj::strTree(
|
||||||
kj::mv(unionDiscrim.readerIsDecl),
|
kj::mv(unionDiscrim.readerIsDecl),
|
||||||
spaces(indent), " public boolean has", titleCase, "() {\n",
|
spaces(indent), " public final boolean has", titleCase, "() {\n",
|
||||||
spaces(indent), " return !_reader.getPointerField(", offset, ").isNull();\n",
|
spaces(indent), " return !_reader.getPointerField(", offset, ").isNull();\n",
|
||||||
spaces(indent), " }\n",
|
spaces(indent), " }\n",
|
||||||
|
|
||||||
spaces(indent), " public final ", type, ".Reader<", elementReaderType, ">",
|
spaces(indent), " public final ", type, ".Reader<", elementReaderType, ">",
|
||||||
" get", titleCase, "() {\n",
|
" get", titleCase, "() {\n",
|
||||||
(kind == FieldKind::LIST ?
|
spaces(indent), " return new ", type, ".Reader<",
|
||||||
kj::strTree(spaces(indent),
|
elementReaderType, ">(_reader.getPointerField(", offset, ").getList(",
|
||||||
" return new ", type, ".Reader<",
|
// XXX what about lists of non-structs?
|
||||||
elementReaderType,
|
typeName(typeBody.getList().getElementType()),".STRUCT_SIZE.preferredListEncoding), ",
|
||||||
">(_reader.getPointerField(",
|
elementReaderType, ".factory);\n",
|
||||||
offset, ").getList(",
|
|
||||||
|
|
||||||
// XXX what about lists of non-structs?
|
|
||||||
typeName(typeBody.getList().getElementType()),".STRUCT_SIZE.preferredListEncoding), ",
|
|
||||||
elementReaderType, ".factory);\n") :
|
|
||||||
kj::strTree(spaces(indent), "Struct\n")), // XXX
|
|
||||||
spaces(indent), " }\n",
|
spaces(indent), " }\n",
|
||||||
"\n"),
|
"\n"),
|
||||||
|
|
||||||
|
@ -1002,7 +996,10 @@ 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), " throw new Error();\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), " }\n"),
|
spaces(indent), " }\n"),
|
||||||
|
|
||||||
kj::strTree(
|
kj::strTree(
|
||||||
|
|
|
@ -28,7 +28,13 @@ public final class StructList {
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T get(int index) {
|
// init
|
||||||
|
Builder(PointerBuilder builder, int size, FromStructBuilder<T> factory) {
|
||||||
|
this.builder = builder.initStructList(size, factory.structSize());
|
||||||
|
this.factory = factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final T get(int index) {
|
||||||
return this.factory.fromStructBuilder(this.builder.getStructElement(index));
|
return this.factory.fromStructBuilder(this.builder.getStructElement(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue