Skip to content

Commit

Permalink
CLI: Replace all occurencies of types[%d].values in static code, see #…
Browse files Browse the repository at this point in the history
…641; Fixed: Use Type.toObject/Message.toObject within converters, see #641
  • Loading branch information
dcodeIO committed Jan 12, 2017
1 parent a4954ed commit 508984b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cli/targets/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 508984b

Please sign in to comment.