stubs for builder methods
This commit is contained in:
parent
0d7d7f4f96
commit
aa9a013475
2 changed files with 40 additions and 24 deletions
|
@ -552,10 +552,12 @@ private:
|
||||||
" _builder.setDataField<", scope, "Which>(\n"
|
" _builder.setDataField<", scope, "Which>(\n"
|
||||||
" ", discrimOffset, " * ::capnp::ELEMENTS, ",
|
" ", discrimOffset, " * ::capnp::ELEMENTS, ",
|
||||||
scope, upperCase, ");\n"),
|
scope, upperCase, ");\n"),
|
||||||
kj::strTree(spaces(indent), " public boolean is", titleCase, "() {\n",
|
kj::strTree(spaces(indent), " public final boolean is", titleCase, "() {\n",
|
||||||
|
spaces(indent), " return which() == ", scope, "Which.", upperCase,";\n",
|
||||||
|
spaces(indent), " }\n"),
|
||||||
|
kj::strTree(spaces(indent), " public final boolean is", titleCase, "() {\n",
|
||||||
spaces(indent), " return which() == ", scope, "Which.", upperCase, ";\n",
|
spaces(indent), " return which() == ", scope, "Which.", upperCase, ";\n",
|
||||||
spaces(indent), " }\n"),
|
spaces(indent), " }\n"),
|
||||||
kj::strTree(spaces(indent), " public boolean is", titleCase, "();\n"),
|
|
||||||
kj::strTree(
|
kj::strTree(
|
||||||
"inline boolean ", scope, "Reader::is", titleCase, "() const {\n"
|
"inline boolean ", scope, "Reader::is", titleCase, "() const {\n"
|
||||||
" return which() == ", scope, upperCase, ";\n"
|
" return which() == ", scope, upperCase, ";\n"
|
||||||
|
@ -611,8 +613,12 @@ private:
|
||||||
|
|
||||||
kj::strTree(
|
kj::strTree(
|
||||||
kj::mv(unionDiscrim.builderIsDecl),
|
kj::mv(unionDiscrim.builderIsDecl),
|
||||||
" public final ", titleCase, ".Builder get", titleCase, "();\n"
|
spaces(indent), " public final ", titleCase, ".Builder get", titleCase, "() {\n",
|
||||||
" public final ", titleCase, ".Builder init", titleCase, "();\n"
|
spaces(indent), " throw new Error();\n",
|
||||||
|
spaces(indent), " }\n",
|
||||||
|
spaces(indent), " public final ", titleCase, ".Builder init", titleCase, "() {\n",
|
||||||
|
spaces(indent), " throw new Error();\n",
|
||||||
|
spaces(indent), " }\n",
|
||||||
"\n"),
|
"\n"),
|
||||||
|
|
||||||
kj::strTree(),
|
kj::strTree(),
|
||||||
|
@ -769,7 +775,7 @@ private:
|
||||||
return FieldText {
|
return FieldText {
|
||||||
kj::strTree(
|
kj::strTree(
|
||||||
kj::mv(unionDiscrim.readerIsDecl),
|
kj::mv(unionDiscrim.readerIsDecl),
|
||||||
spaces(indent), " public ", type, " get", titleCase, "() {\n",
|
spaces(indent), " public final ", type, " get", titleCase, "() {\n",
|
||||||
spaces(indent),
|
spaces(indent),
|
||||||
(typeBody.which() == schema::Type::ENUM ?
|
(typeBody.which() == schema::Type::ENUM ?
|
||||||
kj::strTree(" return ", type, ".values()[_reader.getShortField(", offset, ")];\n") :
|
kj::strTree(" return ", type, ".values()[_reader.getShortField(", offset, ")];\n") :
|
||||||
|
@ -781,8 +787,16 @@ private:
|
||||||
|
|
||||||
kj::strTree(
|
kj::strTree(
|
||||||
kj::mv(unionDiscrim.builderIsDecl),
|
kj::mv(unionDiscrim.builderIsDecl),
|
||||||
" inline ", type, " get", titleCase, "();\n"
|
spaces(indent), " public final ", type, " get", titleCase, "() {\n",
|
||||||
" inline void set", titleCase, "(", type, " value", setterDefault, ");\n"
|
spaces(indent),
|
||||||
|
(typeBody.which() == schema::Type::ENUM ?
|
||||||
|
kj::strTree(" return ", type, ".values()[_builder.getShortField(", offset, ")];\n") :
|
||||||
|
(typeBody.which() == schema::Type::VOID ?
|
||||||
|
kj::strTree(" // nothing to return\n") :
|
||||||
|
kj::strTree(" return _builder.get",toTitleCase(type),"Field(", offset, ");\n"))),
|
||||||
|
spaces(indent), " }\n",
|
||||||
|
|
||||||
|
//spaces(indent), " public final void set", titleCase, "(", type, " value", setterDefault, ");\n",
|
||||||
"\n"),
|
"\n"),
|
||||||
|
|
||||||
kj::strTree(),
|
kj::strTree(),
|
||||||
|
@ -943,21 +957,18 @@ private:
|
||||||
|
|
||||||
kj::strTree(
|
kj::strTree(
|
||||||
kj::mv(unionDiscrim.builderIsDecl),
|
kj::mv(unionDiscrim.builderIsDecl),
|
||||||
" inline boolean has", titleCase, "();\n"
|
spaces(indent), " public final boolean has", titleCase, "() {\n",
|
||||||
" inline ", type, "::Builder get", titleCase, "();\n"
|
spaces(indent), " return !_builder.getPointerField(", offset, ").isNull();\n",
|
||||||
" inline void set", titleCase, "(", type, "::Reader value);\n",
|
spaces(indent), " }\n",
|
||||||
kind == FieldKind::LIST && !isStructOrCapList
|
spaces(indent), " public final ", type, ".Builder get", titleCase, "() {\n",
|
||||||
? kj::strTree(
|
spaces(indent), " throw new Error();\n",
|
||||||
" inline void set", titleCase, "(::kj::ArrayPtr<const ", elementReaderType, "> value);\n")
|
spaces(indent), " }\n",
|
||||||
: kj::strTree(),
|
spaces(indent), " public final void set", titleCase, "(", type, ".Reader value) {\n",
|
||||||
kind == FieldKind::STRUCT
|
spaces(indent), " throw new Error();\n",
|
||||||
? kj::strTree(
|
spaces(indent), " }\n",
|
||||||
" inline ", type, "::Builder init", titleCase, "();\n")
|
spaces(indent), " public final ", type, ".Builder init", titleCase, "() {\n",
|
||||||
: kj::strTree(
|
spaces(indent), " throw new Error();\n",
|
||||||
" inline ", type, "::Builder init", titleCase, "(unsigned int size);\n"),
|
spaces(indent), " }\n"),
|
||||||
" inline void adopt", titleCase, "(::capnp::Orphan<", type, ">&& value);\n"
|
|
||||||
" inline ::capnp::Orphan<", type, "> disown", titleCase, "();\n"
|
|
||||||
"\n"),
|
|
||||||
|
|
||||||
kj::strTree(
|
kj::strTree(
|
||||||
kind == FieldKind::STRUCT && !hasDiscriminantValue(proto)
|
kind == FieldKind::STRUCT && !hasDiscriminantValue(proto)
|
||||||
|
@ -1093,6 +1104,7 @@ private:
|
||||||
structNode.getDiscriminantOffset(), ")];\n",
|
structNode.getDiscriminantOffset(), ")];\n",
|
||||||
spaces(indent), " }\n")
|
spaces(indent), " }\n")
|
||||||
: kj::strTree()),
|
: kj::strTree()),
|
||||||
|
kj::mv(methodDecls),
|
||||||
spaces(indent), "}\n",
|
spaces(indent), "}\n",
|
||||||
"\n");
|
"\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,10 @@ public final class PointerBuilder {
|
||||||
this.pointer = pointer;
|
this.pointer = pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final boolean isNull() {
|
||||||
|
return this.segment.buffer.getLong(this.pointer) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
public final ListBuilder initStructList(int elementCount, StructSize elementSize) {
|
public final ListBuilder initStructList(int elementCount, StructSize elementSize) {
|
||||||
return WireHelpers.initStructListPointer(this.pointer, this.segment, elementCount, elementSize);
|
return WireHelpers.initStructListPointer(this.pointer, this.segment, elementCount, elementSize);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue