mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-30 10:00:02 +00:00
Undoes one bit, adds null type allowance to addField<> default.
This commit is contained in:
@@ -1975,8 +1975,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
GenDocComment(code_ptr);
|
GenDocComment(code_ptr);
|
||||||
code += "static " + namer_.Method("add", field);
|
code += "static " + namer_.Method("add", field);
|
||||||
code += "(builder:flatbuffers.Builder, " + argname + ":" +
|
code += "(builder:flatbuffers.Builder, " + argname + ":" +
|
||||||
GetArgType(imports, struct_def, field, /* allow null */ true) +
|
GetArgType(imports, struct_def, field, false) + ") {\n";
|
||||||
") {\n";
|
|
||||||
code += " builder.addField" + GenWriteMethod(field.value.type) + "(";
|
code += " builder.addField" + GenWriteMethod(field.value.type) + "(";
|
||||||
code += NumToString(it - struct_def.fields.vec.begin()) + ", ";
|
code += NumToString(it - struct_def.fields.vec.begin()) + ", ";
|
||||||
if (field.value.type.base_type == BASE_TYPE_BOOL) { code += "+"; }
|
if (field.value.type.base_type == BASE_TYPE_BOOL) { code += "+"; }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ByteBuffer } from "./byte-buffer.js"
|
import { ByteBuffer } from "./byte-buffer.js"
|
||||||
import { SIZEOF_SHORT, SIZE_PREFIX_LENGTH, SIZEOF_INT, FILE_IDENTIFIER_LENGTH } from "./constants.js"
|
import { FILE_IDENTIFIER_LENGTH, SIZEOF_INT, SIZEOF_SHORT, SIZE_PREFIX_LENGTH } from "./constants.js"
|
||||||
import { Offset, IGeneratedObject } from "./types.js"
|
import { IGeneratedObject, Offset } from "./types.js"
|
||||||
|
|
||||||
export class Builder {
|
export class Builder {
|
||||||
private bb: ByteBuffer
|
private bb: ByteBuffer
|
||||||
@@ -202,42 +202,42 @@ export class Builder {
|
|||||||
this.writeFloat64(value);
|
this.writeFloat64(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
addFieldInt8(voffset: number, value: number, defaultValue: number): void {
|
addFieldInt8(voffset: number, value: number, defaultValue: number|null): void {
|
||||||
if (this.force_defaults || value != defaultValue) {
|
if (this.force_defaults || value != defaultValue) {
|
||||||
this.addInt8(value);
|
this.addInt8(value);
|
||||||
this.slot(voffset);
|
this.slot(voffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addFieldInt16(voffset: number, value: number, defaultValue: number): void {
|
addFieldInt16(voffset: number, value: number, defaultValue: number|null): void {
|
||||||
if (this.force_defaults || value != defaultValue) {
|
if (this.force_defaults || value != defaultValue) {
|
||||||
this.addInt16(value);
|
this.addInt16(value);
|
||||||
this.slot(voffset);
|
this.slot(voffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addFieldInt32(voffset: number, value: number, defaultValue: number): void {
|
addFieldInt32(voffset: number, value: number, defaultValue: number|null): void {
|
||||||
if (this.force_defaults || value != defaultValue) {
|
if (this.force_defaults || value != defaultValue) {
|
||||||
this.addInt32(value);
|
this.addInt32(value);
|
||||||
this.slot(voffset);
|
this.slot(voffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addFieldInt64(voffset: number, value: bigint, defaultValue: bigint): void {
|
addFieldInt64(voffset: number, value: bigint, defaultValue: bigint|null): void {
|
||||||
if (this.force_defaults || value !== defaultValue) {
|
if (this.force_defaults || value !== defaultValue) {
|
||||||
this.addInt64(value);
|
this.addInt64(value);
|
||||||
this.slot(voffset);
|
this.slot(voffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addFieldFloat32(voffset: number, value: number, defaultValue: number): void {
|
addFieldFloat32(voffset: number, value: number, defaultValue: number|null): void {
|
||||||
if (this.force_defaults || value != defaultValue) {
|
if (this.force_defaults || value != defaultValue) {
|
||||||
this.addFloat32(value);
|
this.addFloat32(value);
|
||||||
this.slot(voffset);
|
this.slot(voffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addFieldFloat64(voffset: number, value: number, defaultValue: number): void {
|
addFieldFloat64(voffset: number, value: number, defaultValue: number|null): void {
|
||||||
if (this.force_defaults || value != defaultValue) {
|
if (this.force_defaults || value != defaultValue) {
|
||||||
this.addFloat64(value);
|
this.addFloat64(value);
|
||||||
this.slot(voffset);
|
this.slot(voffset);
|
||||||
|
|||||||
Reference in New Issue
Block a user