From fd64af3e506e40389d5251c681f825779b780d35 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Fri, 5 Oct 2018 00:56:29 +0000 Subject: [PATCH] Rearranged QrCode constructor parameters in JavaScript/TypeScript/Python code to match order in Java/C++/Rust. --- javascript/qrcodegen.js | 6 +++--- python/qrcodegen.py | 6 +++--- typescript/qrcodegen.ts | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/javascript/qrcodegen.js b/javascript/qrcodegen.js index 15c312e..499c038 100644 --- a/javascript/qrcodegen.js +++ b/javascript/qrcodegen.js @@ -32,7 +32,7 @@ * - Function encodeSegments(list segs, QrCode.Ecc ecl, * int minVersion=1, int maxVersion=40, mask=-1, boostEcl=true) -> QrCode * - Constants int MIN_VERSION, MAX_VERSION - * - Constructor QrCode(list dataCodewords, int mask, int version, QrCode.Ecc ecl) + * - Constructor QrCode(int version, QrCode.Ecc ecl, list dataCodewords, int mask) * - Fields int version, size, mask * - Field QrCode.Ecc errorCorrectionLevel * - Method getModule(int x, int y) -> bool @@ -68,7 +68,7 @@ var qrcodegen = new function() { * and mask number. mask = -1 is for automatic choice, or 0 to 7 for fixed choice. This is a cumbersome low-level constructor * that should not be invoked directly by the user. To go one level up, see the QrCode.encodeSegments() function. */ - this.QrCode = function(dataCodewords, mask, version, errCorLvl) { + this.QrCode = function(version, errCorLvl, dataCodewords, mask) { /*---- Constructor (low level) ----*/ @@ -597,7 +597,7 @@ var qrcodegen = new function() { bb.appendBits(padByte, 8); // Create the QR Code symbol - return new this(bb.getBytes(), mask, version, ecl); + return new this(version, ecl, bb.getBytes(), mask); }; diff --git a/python/qrcodegen.py b/python/qrcodegen.py index 190dee2..dbbd5d3 100644 --- a/python/qrcodegen.py +++ b/python/qrcodegen.py @@ -32,7 +32,7 @@ This module "qrcodegen", public members: - Function encode_segments(list segs, QrCode.Ecc ecl, int minversion=1, int maxversion=40, mask=-1, boostecl=true) -> QrCode - Constants int MIN_VERSION, MAX_VERSION - - Constructor QrCode(bytes datacodewords, int mask, int version, QrCode.Ecc ecl) + - Constructor QrCode(int version, QrCode.Ecc ecl, bytes datacodewords, int mask) - Method get_version() -> int - Method get_size() -> int - Method get_error_correction_level() -> QrCode.Ecc @@ -141,12 +141,12 @@ class QrCode(object): bb.append_bits(padbyte, 8) # Create the QR Code symbol - return QrCode(bb.get_bytes(), mask, version, ecl) + return QrCode(version, ecl, bb.get_bytes(), mask) # ---- Constructor (low level) ---- - def __init__(self, datacodewords, mask, version, errcorlvl): + def __init__(self, version, errcorlvl, datacodewords, mask): """Creates a new QR Code symbol with the given version number, error correction level, binary data array, and mask number. mask = -1 is for automatic choice, or 0 to 7 for fixed choice. This is a cumbersome low-level constructor that should not be invoked directly by the user. To go one level up, see the QrCode.encode_segments() function.""" diff --git a/typescript/qrcodegen.ts b/typescript/qrcodegen.ts index 8e36f40..d8d12e9 100644 --- a/typescript/qrcodegen.ts +++ b/typescript/qrcodegen.ts @@ -127,7 +127,7 @@ namespace qrcodegen { bb.appendBits(padByte, 8); // Create the QR Code symbol - return new QrCode(bb.getBytes(), mask, version, ecl); + return new QrCode(version, ecl, bb.getBytes(), mask); } @@ -147,18 +147,18 @@ namespace qrcodegen { /*-- Constructor (low level) and fields --*/ public constructor( + // This QR Code symbol's version number, which is always between 1 and 40 (inclusive). + public readonly version: int, + + // The error correction level used in this QR Code symbol. + public readonly errorCorrectionLevel: QrCode.Ecc, + dataCodewords: Array, // The mask pattern used in this QR Code symbol, in the range 0 to 7 (i.e. unsigned 3-bit integer). // Note that even if the constructor was called with automatic masking requested // (mask = -1), the resulting object will still have a mask value between 0 and 7. - public readonly mask: int, - - // This QR Code symbol's version number, which is always between 1 and 40 (inclusive). - public readonly version: int, - - // The error correction level used in this QR Code symbol. - public readonly errorCorrectionLevel: QrCode.Ecc) { + public readonly mask: int) { // Check arguments and handle simple scalar fields if (mask < -1 || mask > 7)