Rearranged QrCode constructor parameters in JavaScript/TypeScript/Python code to match order in Java/C++/Rust.

This commit is contained in:
Project Nayuki 2018-10-05 00:56:29 +00:00
parent ae7b5296f2
commit fd64af3e50
3 changed files with 14 additions and 14 deletions

View File

@ -32,7 +32,7 @@
* - Function encodeSegments(list<QrSegment> segs, QrCode.Ecc ecl, * - Function encodeSegments(list<QrSegment> segs, QrCode.Ecc ecl,
* int minVersion=1, int maxVersion=40, mask=-1, boostEcl=true) -> QrCode * int minVersion=1, int maxVersion=40, mask=-1, boostEcl=true) -> QrCode
* - Constants int MIN_VERSION, MAX_VERSION * - Constants int MIN_VERSION, MAX_VERSION
* - Constructor QrCode(list<int> dataCodewords, int mask, int version, QrCode.Ecc ecl) * - Constructor QrCode(int version, QrCode.Ecc ecl, list<int> dataCodewords, int mask)
* - Fields int version, size, mask * - Fields int version, size, mask
* - Field QrCode.Ecc errorCorrectionLevel * - Field QrCode.Ecc errorCorrectionLevel
* - Method getModule(int x, int y) -> bool * - 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 * 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. * 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) ----*/ /*---- Constructor (low level) ----*/
@ -597,7 +597,7 @@ var qrcodegen = new function() {
bb.appendBits(padByte, 8); bb.appendBits(padByte, 8);
// Create the QR Code symbol // Create the QR Code symbol
return new this(bb.getBytes(), mask, version, ecl); return new this(version, ecl, bb.getBytes(), mask);
}; };

View File

@ -32,7 +32,7 @@ This module "qrcodegen", public members:
- Function encode_segments(list<QrSegment> segs, QrCode.Ecc ecl, - Function encode_segments(list<QrSegment> segs, QrCode.Ecc ecl,
int minversion=1, int maxversion=40, mask=-1, boostecl=true) -> QrCode int minversion=1, int maxversion=40, mask=-1, boostecl=true) -> QrCode
- Constants int MIN_VERSION, MAX_VERSION - 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_version() -> int
- Method get_size() -> int - Method get_size() -> int
- Method get_error_correction_level() -> QrCode.Ecc - Method get_error_correction_level() -> QrCode.Ecc
@ -141,12 +141,12 @@ class QrCode(object):
bb.append_bits(padbyte, 8) bb.append_bits(padbyte, 8)
# Create the QR Code symbol # Create the QR Code symbol
return QrCode(bb.get_bytes(), mask, version, ecl) return QrCode(version, ecl, bb.get_bytes(), mask)
# ---- Constructor (low level) ---- # ---- 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, """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 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.""" that should not be invoked directly by the user. To go one level up, see the QrCode.encode_segments() function."""

View File

@ -127,7 +127,7 @@ namespace qrcodegen {
bb.appendBits(padByte, 8); bb.appendBits(padByte, 8);
// Create the QR Code symbol // 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 --*/ /*-- Constructor (low level) and fields --*/
public constructor( 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<byte>, dataCodewords: Array<byte>,
// The mask pattern used in this QR Code symbol, in the range 0 to 7 (i.e. unsigned 3-bit integer). // 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 // 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. // (mask = -1), the resulting object will still have a mask value between 0 and 7.
public readonly mask: int, 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) {
// Check arguments and handle simple scalar fields // Check arguments and handle simple scalar fields
if (mask < -1 || mask > 7) if (mask < -1 || mask > 7)