From bc6f776429826bec200b4d7c36394107096d202e Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Mon, 17 Sep 2018 03:59:20 +0000 Subject: [PATCH] Updated JavaScript code for type purity to ensure the modules array is actually Boolean (instead of numeric) after masking, tweaked TypeScript code to correspond to new JS code. --- javascript/qrcodegen.js | 3 ++- typescript/qrcodegen.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/javascript/qrcodegen.js b/javascript/qrcodegen.js index 0fd17ad..13d7abf 100644 --- a/javascript/qrcodegen.js +++ b/javascript/qrcodegen.js @@ -398,7 +398,8 @@ var qrcodegen = new function() { case 7: invert = ((x + y) % 2 + x * y % 3) % 2 == 0; break; default: throw "Assertion error"; } - modules[y][x] ^= invert & !isFunction[y][x]; + if (!isFunction[y][x] && invert) + modules[y][x] = !modules[y][x]; } } } diff --git a/typescript/qrcodegen.ts b/typescript/qrcodegen.ts index b975987..3ab5c8b 100644 --- a/typescript/qrcodegen.ts +++ b/typescript/qrcodegen.ts @@ -470,7 +470,7 @@ namespace qrcodegen { case 7: invert = ((x + y) % 2 + x * y % 3) % 2 == 0; break; default: throw "Assertion error"; } - if (invert && !this.isFunction[y][x]) + if (!this.isFunction[y][x] && invert) this.modules[y][x] = !this.modules[y][x]; } }