@ngx-grpc/protoc-gen-ng
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -18,8 +18,8 @@ "use strict"; | ||
BooleanMessageField.prototype.printDeserializeBinaryFromReader = function (printer) { | ||
var readerCall = 'reader.readBool()'; | ||
var readerCall = '_reader.readBool()'; | ||
if (this.isArray) { | ||
printer.add("case " + this.messageField.number + ": (instance." + this.attributeName + " = instance." + this.attributeName + " || []).push(" + readerCall + ");"); | ||
printer.add("case " + this.messageField.number + ": (_instance." + this.attributeName + " = _instance." + this.attributeName + " || []).push(" + readerCall + ");"); | ||
} | ||
else { | ||
printer.add("case " + this.messageField.number + ": instance." + this.attributeName + " = " + readerCall + ";"); | ||
printer.add("case " + this.messageField.number + ": _instance." + this.attributeName + " = " + readerCall + ";"); | ||
} | ||
@@ -30,9 +30,9 @@ printer.add('break;'); | ||
if (this.isArray) { | ||
printer.add("if (instance." + this.attributeName + " && instance." + this.attributeName + ".length) {\n writer.writeRepeatedBool(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + " && _instance." + this.attributeName + ".length) {\n _writer.writeRepeatedBool(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
} | ||
else if (this.oneOf) { | ||
printer.add("if (instance." + this.attributeName + " || instance." + this.attributeName + " === false) {\n writer.writeBool(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + " || _instance." + this.attributeName + " === false) {\n _writer.writeBool(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
} | ||
else { | ||
printer.add("if (instance." + this.attributeName + ") {\n writer.writeBool(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + ") {\n _writer.writeBool(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
} | ||
@@ -45,6 +45,6 @@ }; | ||
if (this.isArray) { | ||
printer.add("this." + this.attributeName + " = (value." + this.attributeName + " || []).slice();"); | ||
printer.add("this." + this.attributeName + " = (_value." + this.attributeName + " || []).slice();"); | ||
} | ||
else { | ||
printer.add("this." + this.attributeName + " = value." + this.attributeName); | ||
printer.add("this." + this.attributeName + " = _value." + this.attributeName); | ||
} | ||
@@ -57,6 +57,6 @@ }; | ||
else if (this.isArray) { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || []"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || []"); | ||
} | ||
else { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || false"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || false"); | ||
} | ||
@@ -63,0 +63,0 @@ }; |
@@ -18,8 +18,8 @@ "use strict"; | ||
BytesMessageField.prototype.printDeserializeBinaryFromReader = function (printer) { | ||
var readerCall = 'reader.readBytes()'; | ||
var readerCall = '_reader.readBytes()'; | ||
if (this.isArray) { | ||
printer.add("case " + this.messageField.number + ": (instance." + this.attributeName + " = instance." + this.attributeName + " || []).push(" + readerCall + ");"); | ||
printer.add("case " + this.messageField.number + ": (_instance." + this.attributeName + " = _instance." + this.attributeName + " || []).push(" + readerCall + ");"); | ||
} | ||
else { | ||
printer.add("case " + this.messageField.number + ": instance." + this.attributeName + " = " + readerCall + ";"); | ||
printer.add("case " + this.messageField.number + ": _instance." + this.attributeName + " = " + readerCall + ";"); | ||
} | ||
@@ -29,3 +29,3 @@ printer.add('break;'); | ||
BytesMessageField.prototype.printSerializeBinaryToWriter = function (printer) { | ||
printer.add("if (instance." + this.attributeName + " && instance." + this.attributeName + ".length) {\n writer.write" + (this.isArray ? 'Repeated' : '') + "Bytes(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + " && _instance." + this.attributeName + ".length) {\n _writer.write" + (this.isArray ? 'Repeated' : '') + "Bytes(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
}; | ||
@@ -37,6 +37,6 @@ BytesMessageField.prototype.printPrivateAttribute = function (printer) { | ||
if (this.isArray) { | ||
printer.add("this." + this.attributeName + " = (value." + this.attributeName + " || []).map(b => b ? b.subarray(0) : new Uint8Array());"); | ||
printer.add("this." + this.attributeName + " = (_value." + this.attributeName + " || []).map(b => b ? b.subarray(0) : new Uint8Array());"); | ||
} | ||
else { | ||
printer.add("this." + this.attributeName + " = value." + this.attributeName); | ||
printer.add("this." + this.attributeName + " = _value." + this.attributeName); | ||
} | ||
@@ -49,6 +49,6 @@ }; | ||
else if (this.isArray) { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || []"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || []"); | ||
} | ||
else { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || new Uint8Array()"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || new Uint8Array()"); | ||
} | ||
@@ -55,0 +55,0 @@ }; |
@@ -18,8 +18,8 @@ "use strict"; | ||
EnumMessageField.prototype.printDeserializeBinaryFromReader = function (printer) { | ||
var readerCall = 'reader.readEnum()'; | ||
var readerCall = '_reader.readEnum()'; | ||
if (this.isArray) { | ||
printer.add("case " + this.messageField.number + ": (instance." + this.attributeName + " = instance." + this.attributeName + " || []).push(" + readerCall + ");"); | ||
printer.add("case " + this.messageField.number + ": (_instance." + this.attributeName + " = _instance." + this.attributeName + " || []).push(" + readerCall + ");"); | ||
} | ||
else { | ||
printer.add("case " + this.messageField.number + ": instance." + this.attributeName + " = " + readerCall + ";"); | ||
printer.add("case " + this.messageField.number + ": _instance." + this.attributeName + " = " + readerCall + ";"); | ||
} | ||
@@ -30,9 +30,9 @@ printer.add('break;'); | ||
if (this.isArray) { | ||
printer.add("if (instance." + this.attributeName + " && instance." + this.attributeName + ".length) {\n writer.writeRepeatedEnum(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + " && _instance." + this.attributeName + ".length) {\n _writer.writeRepeatedEnum(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
} | ||
else if (this.oneOf) { | ||
printer.add("if (instance." + this.attributeName + " || instance." + this.attributeName + " === 0) {\n writer.writeEnum(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + " || _instance." + this.attributeName + " === 0) {\n _writer.writeEnum(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
} | ||
else { | ||
printer.add("if (instance." + this.attributeName + ") {\n writer.writeEnum(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + ") {\n _writer.writeEnum(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
} | ||
@@ -45,6 +45,6 @@ }; | ||
if (this.isArray) { | ||
printer.add("this." + this.attributeName + " = (value." + this.attributeName + " || []).slice();"); | ||
printer.add("this." + this.attributeName + " = (_value." + this.attributeName + " || []).slice();"); | ||
} | ||
else { | ||
printer.add("this." + this.attributeName + " = value." + this.attributeName); | ||
printer.add("this." + this.attributeName + " = _value." + this.attributeName); | ||
} | ||
@@ -57,6 +57,6 @@ }; | ||
else if (this.isArray) { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || []"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || []"); | ||
} | ||
else { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || 0"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || 0"); | ||
} | ||
@@ -63,0 +63,0 @@ }; |
@@ -23,6 +23,6 @@ "use strict"; | ||
var msgVarName = "msg_" + this.messageField.number; | ||
printer.add("case " + this.messageField.number + ":\n const " + msgVarName + " = {} as any;\n reader.readMessage(" + msgVarName + ", " + this.mapMessageClassName + ".deserializeBinaryFromReader);\n instance." + this.attributeName + " = instance." + this.attributeName + " || {};\n instance." + this.attributeName + "[" + msgVarName + ".key] = " + msgVarName + ".value;\n break;"); | ||
printer.add("case " + this.messageField.number + ":\n const " + msgVarName + " = {} as any;\n _reader.readMessage(" + msgVarName + ", " + this.mapMessageClassName + ".deserializeBinaryFromReader);\n _instance." + this.attributeName + " = _instance." + this.attributeName + " || {};\n _instance." + this.attributeName + "[" + msgVarName + ".key] = " + msgVarName + ".value;\n break;"); | ||
}; | ||
MapMessageField.prototype.printSerializeBinaryToWriter = function (printer) { | ||
var varName = "instance." + this.attributeName; | ||
var varName = "_instance." + this.attributeName; | ||
var keysVarName = "keys_" + this.messageField.number; | ||
@@ -32,3 +32,3 @@ var repeatedVarName = "repeated_" + this.messageField.number; | ||
var castedKey = this.keyField.type === isStringKey ? 'key' : 'Number(key)'; | ||
printer.add("if (!!" + varName + ") {\n const " + keysVarName + " = Object.keys(" + varName + " as any);\n\n if (" + keysVarName + ".length) {\n const " + repeatedVarName + " = " + keysVarName + "\n .map(key => ({ key: " + castedKey + ", value: (" + varName + " as any)[key] }))\n .reduce((r, v) => [...r, v], [] as any[]);\n\n writer.writeRepeatedMessage(" + this.messageField.number + ", " + repeatedVarName + ", " + this.mapMessageClassName + ".serializeBinaryToWriter);\n }\n }"); | ||
printer.add("if (!!" + varName + ") {\n const " + keysVarName + " = Object.keys(" + varName + " as any);\n\n if (" + keysVarName + ".length) {\n const " + repeatedVarName + " = " + keysVarName + "\n .map(key => ({ key: " + castedKey + ", value: (" + varName + " as any)[key] }))\n .reduce((r, v) => [...r, v], [] as any[]);\n\n _writer.writeRepeatedMessage(" + this.messageField.number + ", " + repeatedVarName + ", " + this.mapMessageClassName + ".serializeBinaryToWriter);\n }\n }"); | ||
}; | ||
@@ -39,10 +39,10 @@ MapMessageField.prototype.printPrivateAttribute = function (printer) { | ||
MapMessageField.prototype.printInitializer = function (printer) { | ||
var cloneFn = "value!." + this.attributeName + "![k]"; | ||
var cloneFn = "_value!." + this.attributeName + "![k]"; | ||
if (helpers_1.isFieldMessage(this.valueField)) { | ||
cloneFn = "value!." + this.attributeName + "![k] ? value!." + this.attributeName + "![k].toObject() : undefined,"; | ||
cloneFn = "_value!." + this.attributeName + "![k] ? _value!." + this.attributeName + "![k].toObject() : undefined,"; | ||
} | ||
else if (this.valueField.type === types_1.ProtoMessageFieldType.bytes) { | ||
cloneFn = "value!." + this.attributeName + "![k] ? value!." + this.attributeName + "![k].subarray(0) : undefined"; | ||
cloneFn = "_value!." + this.attributeName + "![k] ? _value!." + this.attributeName + "![k].subarray(0) : undefined"; | ||
} | ||
printer.add("this." + this.attributeName + " = value!." + this.attributeName + " ? Object.keys(value!." + this.attributeName + ").reduce((r, k) => ({ ...r, [k]: " + cloneFn + " }), {}) : {},"); | ||
printer.add("this." + this.attributeName + " = _value!." + this.attributeName + " ? Object.keys(_value!." + this.attributeName + ").reduce((r, k) => ({ ...r, [k]: " + cloneFn + " }), {}) : {},"); | ||
}; | ||
@@ -54,3 +54,3 @@ MapMessageField.prototype.printDefaultValueSetter = function (printer) { | ||
else { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || {}"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || {}"); | ||
} | ||
@@ -57,0 +57,0 @@ }; |
@@ -22,6 +22,6 @@ "use strict"; | ||
if (this.isArray) { | ||
printer.add("case " + this.messageField.number + ":\n const " + varName + " = new " + this.messageClassName + "();\n reader.readMessage(" + varName + ", " + this.messageClassName + ".deserializeBinaryFromReader);\n (instance." + this.attributeName + " = instance." + this.attributeName + " || []).push(" + varName + ");"); | ||
printer.add("case " + this.messageField.number + ":\n const " + varName + " = new " + this.messageClassName + "();\n _reader.readMessage(" + varName + ", " + this.messageClassName + ".deserializeBinaryFromReader);\n (_instance." + this.attributeName + " = _instance." + this.attributeName + " || []).push(" + varName + ");"); | ||
} | ||
else { | ||
printer.add("case " + this.messageField.number + ":\n instance." + this.attributeName + " = new " + this.messageClassName + "();\n reader.readMessage(instance." + this.attributeName + ", " + this.messageClassName + ".deserializeBinaryFromReader);"); | ||
printer.add("case " + this.messageField.number + ":\n _instance." + this.attributeName + " = new " + this.messageClassName + "();\n _reader.readMessage(_instance." + this.attributeName + ", " + this.messageClassName + ".deserializeBinaryFromReader);"); | ||
} | ||
@@ -32,6 +32,6 @@ printer.add('break;'); | ||
if (this.isArray) { | ||
printer.add("if (instance." + this.attributeName + " && instance." + this.attributeName + ".length) {\n writer.writeRepeatedMessage(" + this.messageField.number + ", instance." + this.attributeName + " as any, " + this.messageClassName + ".serializeBinaryToWriter);\n }"); | ||
printer.add("if (_instance." + this.attributeName + " && _instance." + this.attributeName + ".length) {\n _writer.writeRepeatedMessage(" + this.messageField.number + ", _instance." + this.attributeName + " as any, " + this.messageClassName + ".serializeBinaryToWriter);\n }"); | ||
} | ||
else { | ||
printer.add("if (instance." + this.attributeName + ") {\n writer.writeMessage(" + this.messageField.number + ", instance." + this.attributeName + " as any, " + this.messageClassName + ".serializeBinaryToWriter);\n }"); | ||
printer.add("if (_instance." + this.attributeName + ") {\n _writer.writeMessage(" + this.messageField.number + ", _instance." + this.attributeName + " as any, " + this.messageClassName + ".serializeBinaryToWriter);\n }"); | ||
} | ||
@@ -44,6 +44,6 @@ }; | ||
if (this.isArray) { | ||
printer.add("this." + this.attributeName + " = (value." + this.attributeName + " || []).map(m => new " + this.messageClassName + "(m));"); | ||
printer.add("this." + this.attributeName + " = (_value." + this.attributeName + " || []).map(m => new " + this.messageClassName + "(m));"); | ||
} | ||
else { | ||
printer.add("this." + this.attributeName + " = value." + this.attributeName + " ? new " + this.messageClassName + "(value." + this.attributeName + ") : undefined;"); | ||
printer.add("this." + this.attributeName + " = _value." + this.attributeName + " ? new " + this.messageClassName + "(_value." + this.attributeName + ") : undefined;"); | ||
} | ||
@@ -56,6 +56,6 @@ }; | ||
else if (this.isArray) { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || []"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || []"); | ||
} | ||
else { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || undefined"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || undefined"); | ||
} | ||
@@ -62,0 +62,0 @@ }; |
@@ -54,8 +54,8 @@ "use strict"; | ||
NumberMessageField.prototype.printDeserializeBinaryFromReader = function (printer) { | ||
var readerCall = 'reader.read' + this.protoDataType + '()'; | ||
var readerCall = '_reader.read' + this.protoDataType + '()'; | ||
if (this.isArray) { | ||
printer.add("case " + this.messageField.number + ": (instance." + this.attributeName + " = instance." + this.attributeName + " || []).push(" + readerCall + ");"); | ||
printer.add("case " + this.messageField.number + ": (_instance." + this.attributeName + " = _instance." + this.attributeName + " || []).push(" + readerCall + ");"); | ||
} | ||
else { | ||
printer.add("case " + this.messageField.number + ": instance." + this.attributeName + " = " + readerCall + ";"); | ||
printer.add("case " + this.messageField.number + ": _instance." + this.attributeName + " = " + readerCall + ";"); | ||
} | ||
@@ -66,9 +66,9 @@ printer.add('break;'); | ||
if (this.isArray) { | ||
printer.add("if (instance." + this.attributeName + " && instance." + this.attributeName + ".length) {\n writer.writeRepeated" + this.protoDataType + "(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + " && _instance." + this.attributeName + ".length) {\n _writer.writeRepeated" + this.protoDataType + "(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
} | ||
else if (this.oneOf) { | ||
printer.add("if (instance." + this.attributeName + " || instance." + this.attributeName + " === 0) {\n writer.write" + this.protoDataType + "(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + " || _instance." + this.attributeName + " === 0) {\n _writer.write" + this.protoDataType + "(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
} | ||
else { | ||
printer.add("if (instance." + this.attributeName + ") {\n writer.write" + this.protoDataType + "(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + ") {\n _writer.write" + this.protoDataType + "(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
} | ||
@@ -81,6 +81,6 @@ }; | ||
if (this.isArray) { | ||
printer.add("this." + this.attributeName + " = (value." + this.attributeName + " || []).slice();"); | ||
printer.add("this." + this.attributeName + " = (_value." + this.attributeName + " || []).slice();"); | ||
} | ||
else { | ||
printer.add("this." + this.attributeName + " = value." + this.attributeName); | ||
printer.add("this." + this.attributeName + " = _value." + this.attributeName); | ||
} | ||
@@ -93,6 +93,6 @@ }; | ||
else if (this.isArray) { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || []"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || []"); | ||
} | ||
else { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || 0"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || 0"); | ||
} | ||
@@ -99,0 +99,0 @@ }; |
@@ -46,8 +46,8 @@ "use strict"; | ||
Number64MessageField.prototype.printDeserializeBinaryFromReader = function (printer) { | ||
var readerCall = 'reader.read' + this.protoDataType + '()'; | ||
var readerCall = '_reader.read' + this.protoDataType + '()'; | ||
if (this.isArray) { | ||
printer.add("case " + this.messageField.number + ": (instance." + this.attributeName + " = instance." + this.attributeName + " || []).push(" + readerCall + ");"); | ||
printer.add("case " + this.messageField.number + ": (_instance." + this.attributeName + " = _instance." + this.attributeName + " || []).push(" + readerCall + ");"); | ||
} | ||
else { | ||
printer.add("case " + this.messageField.number + ": instance." + this.attributeName + " = " + readerCall + ";"); | ||
printer.add("case " + this.messageField.number + ": _instance." + this.attributeName + " = " + readerCall + ";"); | ||
} | ||
@@ -58,6 +58,6 @@ printer.add('break;'); | ||
if (this.isArray) { | ||
printer.add("if (instance." + this.attributeName + " && instance." + this.attributeName + ".length) {\n writer.writeRepeated" + this.protoDataType + "(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + " && _instance." + this.attributeName + ".length) {\n _writer.writeRepeated" + this.protoDataType + "(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
} | ||
else { | ||
printer.add("if (instance." + this.attributeName + ") {\n writer.write" + this.protoDataType + "(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + ") {\n _writer.write" + this.protoDataType + "(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
} | ||
@@ -70,6 +70,6 @@ }; | ||
if (this.isArray) { | ||
printer.add("this." + this.attributeName + " = (value." + this.attributeName + " || []).slice();"); | ||
printer.add("this." + this.attributeName + " = (_value." + this.attributeName + " || []).slice();"); | ||
} | ||
else { | ||
printer.add("this." + this.attributeName + " = value." + this.attributeName); | ||
printer.add("this." + this.attributeName + " = _value." + this.attributeName); | ||
} | ||
@@ -82,6 +82,6 @@ }; | ||
else if (this.isArray) { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || []"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || []"); | ||
} | ||
else { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || '0'"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || '0'"); | ||
} | ||
@@ -88,0 +88,0 @@ }; |
@@ -18,8 +18,8 @@ "use strict"; | ||
StringMessageField.prototype.printDeserializeBinaryFromReader = function (printer) { | ||
var readerCall = 'reader.readString()'; | ||
var readerCall = '_reader.readString()'; | ||
if (this.isArray) { | ||
printer.add("case " + this.messageField.number + ": (instance." + this.attributeName + " = instance." + this.attributeName + " || []).push(" + readerCall + ");"); | ||
printer.add("case " + this.messageField.number + ": (_instance." + this.attributeName + " = _instance." + this.attributeName + " || []).push(" + readerCall + ");"); | ||
} | ||
else { | ||
printer.add("case " + this.messageField.number + ": instance." + this.attributeName + " = " + readerCall + ";"); | ||
printer.add("case " + this.messageField.number + ": _instance." + this.attributeName + " = " + readerCall + ";"); | ||
} | ||
@@ -30,9 +30,9 @@ printer.add('break;'); | ||
if (this.isArray) { | ||
printer.add("if (instance." + this.attributeName + " && instance." + this.attributeName + ".length) {\n writer.writeRepeatedString(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + " && _instance." + this.attributeName + ".length) {\n _writer.writeRepeatedString(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
} | ||
else if (this.oneOf) { | ||
printer.add("if (instance." + this.attributeName + " || instance." + this.attributeName + " === '') {\n writer.writeString(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + " || _instance." + this.attributeName + " === '') {\n _writer.writeString(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
} | ||
else { | ||
printer.add("if (instance." + this.attributeName + ") {\n writer.writeString(" + this.messageField.number + ", instance." + this.attributeName + ");\n }"); | ||
printer.add("if (_instance." + this.attributeName + ") {\n _writer.writeString(" + this.messageField.number + ", _instance." + this.attributeName + ");\n }"); | ||
} | ||
@@ -45,6 +45,6 @@ }; | ||
if (this.isArray) { | ||
printer.add("this." + this.attributeName + " = (value." + this.attributeName + " || []).slice();"); | ||
printer.add("this." + this.attributeName + " = (_value." + this.attributeName + " || []).slice();"); | ||
} | ||
else { | ||
printer.add("this." + this.attributeName + " = value." + this.attributeName); | ||
printer.add("this." + this.attributeName + " = _value." + this.attributeName); | ||
} | ||
@@ -57,6 +57,6 @@ }; | ||
else if (this.isArray) { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || []"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || []"); | ||
} | ||
else { | ||
printer.add("instance." + this.attributeName + " = instance." + this.attributeName + " || ''"); | ||
printer.add("_instance." + this.attributeName + " = _instance." + this.attributeName + " || ''"); | ||
} | ||
@@ -63,0 +63,0 @@ }; |
@@ -98,3 +98,3 @@ "use strict"; | ||
Message.prototype.printStaticRefineValues = function (printer) { | ||
printer.addLine("\n /**\n * Check all the properties and set default protobuf values if necessary\n * @param instance message instance\n */\n static refineValues(instance: " + this.message.name + ") {\n "); | ||
printer.addLine("\n /**\n * Check all the properties and set default protobuf values if necessary\n * @param _instance message instance\n */\n static refineValues(_instance: " + this.message.name + ") {\n "); | ||
this.messageFields.forEach(function (f) { | ||
@@ -107,3 +107,3 @@ f.printDefaultValueSetter(printer); | ||
Message.prototype.printStaticDeserializeBinaryFromReader = function (printer) { | ||
printer.addLine("\n /**\n * Deserializes / reads binary message into message instance using provided binary reader\n * @param instance message instance\n * @param reader binary reader instance\n */\n static deserializeBinaryFromReader(instance: " + this.message.name + ", reader: BinaryReader) {\n while (reader.nextField()) {\n if (reader.isEndGroup()) break;\n\n switch (reader.getFieldNumber()) {"); | ||
printer.addLine("\n /**\n * Deserializes / reads binary message into message instance using provided binary reader\n * @param _instance message instance\n * @param _reader binary reader instance\n */\n static deserializeBinaryFromReader(_instance: " + this.message.name + ", _reader: BinaryReader) {\n while (_reader.nextField()) {\n if (_reader.isEndGroup()) break;\n\n switch (_reader.getFieldNumber()) {"); | ||
this.messageFields.forEach(function (f) { | ||
@@ -113,6 +113,6 @@ f.printDeserializeBinaryFromReader(printer); | ||
}); | ||
printer.addLine("default: reader.skipField();\n }\n }\n\n " + this.message.name + ".refineValues(instance);\n }"); | ||
printer.addLine("default: _reader.skipField();\n }\n }\n\n " + this.message.name + ".refineValues(_instance);\n }"); | ||
}; | ||
Message.prototype.printStaticSerializeBinaryToWriter = function (printer) { | ||
printer.addLine("\n /**\n * Serializes a message to binary format using provided binary reader\n * @param instance message instance\n * @param writer binary writer instance\n */\n static serializeBinaryToWriter(instance: " + this.message.name + ", writer: BinaryWriter) {\n "); | ||
printer.addLine("\n /**\n * Serializes a message to binary format using provided binary reader\n * @param _instance message instance\n * @param _writer binary writer instance\n */\n static serializeBinaryToWriter(_instance: " + this.message.name + ", _writer: BinaryWriter) {\n "); | ||
this.messageFields.forEach(function (f) { | ||
@@ -133,4 +133,4 @@ f.printSerializeBinaryToWriter(printer); | ||
Message.prototype.printConstructor = function (printer) { | ||
printer.addLine("\n /**\n * Message constructor. Initializes the properties and applies default Protobuf values if necessary\n * @param value initial values object or instance of " + this.message.name + " to deeply clone from\n */\n constructor(value?: RecursivePartial<" + this.message.name + ">) {\n "); | ||
printer.addLine('value = value || {};'); | ||
printer.addLine("\n /**\n * Message constructor. Initializes the properties and applies default Protobuf values if necessary\n * @param _value initial values object or instance of " + this.message.name + " to deeply clone from\n */\n constructor(_value?: RecursivePartial<" + this.message.name + ">) {\n "); | ||
printer.addLine('_value = _value || {};'); | ||
this.messageFields.forEach(function (f) { | ||
@@ -137,0 +137,0 @@ f.printInitializer(printer); |
@@ -19,3 +19,3 @@ { | ||
}, | ||
"version": "1.0.0" | ||
"version": "1.0.1" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
165102
0