Permalink
Browse files

CLI: Replace all occurencies of types[%d].values in static code, see #…

…641; Fixed: Use Type.toObject/Message.toObject within converters, see #641
  • Loading branch information...
dcodeIO committed Jan 12, 2017
1 parent a4954ed commit 508984b7ff9529906be282375d36fdbada66b8e6
Showing with 3 additions and 3 deletions.
  1. +2 −2 cli/targets/static.js
  2. +1 −1 src/converter.js
@@ -174,8 +174,8 @@ function beautify(code) {

function buildFunction(type, functionName, gen, scope) {
var code = gen.str(functionName)
.replace("(this.ctor)", " $root" + type.fullName) // types: construct directly instead of using reflected ctor
.replace(/(types\[\d+])(\.values)/,"$1"); // enums: use types[N] instead of reflected types[N].values
.replace(/\(this.ctor\)/g, " $root" + type.fullName) // types: construct directly instead of using reflected ctor
.replace(/(types\[\d+])(\.values)/g,"$1"); // enums: use types[N] instead of reflected types[N].values

if (config.beautify)
code = beautify(code);
@@ -148,7 +148,7 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
if (field.resolvedType instanceof Enum) gen
("d%s=o.enums===String?types[%d].values[m%s]:m%s", prop, fieldIndex, prop, prop);
else gen
("d%s=types[%d].ctor.prototype.toObject.call(m%s,o)", prop, fieldIndex, prop);
("d%s=types[%d].toObject(m%s,o)", prop, fieldIndex, prop);
} else {
var isUnsigned = false;
switch (field.type) {

0 comments on commit 508984b

Please sign in to comment.