Moved QrCode class's max/min version constants, tweaked associated comments and blank lines, in all languages except C.

pull/39/merge
Project Nayuki 6 years ago
parent af6a247121
commit 859438d183

@ -88,13 +88,6 @@ class QrCode final {
/*---- Public constants ----*/
public: static constexpr int MIN_VERSION = 1;
public: static constexpr int MAX_VERSION = 40;
/*---- Instance fields ----*/ /*---- Instance fields ----*/
// Immutable scalar parameters // Immutable scalar parameters
@ -252,7 +245,11 @@ class QrCode final {
private: static bool getBit(long x, int i); private: static bool getBit(long x, int i);
/*---- Private tables of constants ----*/ /*---- Constants and tables ----*/
public: static constexpr int MIN_VERSION = 1;
public: static constexpr int MAX_VERSION = 40;
// For use in getPenaltyScore(), when evaluating which mask is best. // For use in getPenaltyScore(), when evaluating which mask is best.
private: static const int PENALTY_N1; private: static const int PENALTY_N1;
@ -260,6 +257,7 @@ class QrCode final {
private: static const int PENALTY_N3; private: static const int PENALTY_N3;
private: static const int PENALTY_N4; private: static const int PENALTY_N4;
private: static const std::int8_t ECC_CODEWORDS_PER_BLOCK[4][41]; private: static const std::int8_t ECC_CODEWORDS_PER_BLOCK[4][41];
private: static const std::int8_t NUM_ERROR_CORRECTION_BLOCKS[4][41]; private: static const std::int8_t NUM_ERROR_CORRECTION_BLOCKS[4][41];

@ -167,13 +167,6 @@ public final class QrCode {
/*---- Public constants ----*/
public static final int MIN_VERSION = 1;
public static final int MAX_VERSION = 40;
/*---- Instance fields ----*/ /*---- Instance fields ----*/
// Public immutable scalar parameters // Public immutable scalar parameters
@ -704,7 +697,11 @@ public final class QrCode {
} }
/*---- Private tables of constants ----*/ /*---- Constants and tables ----*/
public static final int MIN_VERSION = 1;
public static final int MAX_VERSION = 40;
// For use in getPenaltyScore(), when evaluating which mask is best. // For use in getPenaltyScore(), when evaluating which mask is best.
private static final int PENALTY_N1 = 3; private static final int PENALTY_N1 = 3;

@ -599,14 +599,6 @@ var qrcodegen = new function() {
}; };
/*---- Public constants for QrCode ----*/
var MIN_VERSION = 1;
var MAX_VERSION = 40;
Object.defineProperty(this.QrCode, "MIN_VERSION", {value:MIN_VERSION});
Object.defineProperty(this.QrCode, "MAX_VERSION", {value:MAX_VERSION});
/*---- Private static helper functions for QrCode ----*/ /*---- Private static helper functions for QrCode ----*/
var QrCode = {}; // Private object to assign properties to. Not the same object as 'this.QrCode'. var QrCode = {}; // Private object to assign properties to. Not the same object as 'this.QrCode'.
@ -639,7 +631,12 @@ var qrcodegen = new function() {
}; };
/*---- Private tables of constants for QrCode ----*/ /*---- Constants and tables for QrCode ----*/
var MIN_VERSION = 1;
var MAX_VERSION = 40;
Object.defineProperty(this.QrCode, "MIN_VERSION", {value:MIN_VERSION});
Object.defineProperty(this.QrCode, "MAX_VERSION", {value:MAX_VERSION});
// For use in getPenaltyScore(), when evaluating which mask is best. // For use in getPenaltyScore(), when evaluating which mask is best.
QrCode.PENALTY_N1 = 3; QrCode.PENALTY_N1 = 3;

@ -142,12 +142,6 @@ class QrCode(object):
return QrCode(bb.get_bytes(), mask, version, ecl) return QrCode(bb.get_bytes(), mask, version, ecl)
# ---- Public constants ----
MIN_VERSION = 1
MAX_VERSION = 40
# ---- Constructor ---- # ---- Constructor ----
def __init__(self, datacodewords, mask, version, errcorlvl): def __init__(self, datacodewords, mask, version, errcorlvl):
@ -529,7 +523,10 @@ class QrCode(object):
* QrCode._NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver] * QrCode._NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver]
# ---- Private tables of constants ---- # ---- Constants and tables ----
MIN_VERSION = 1
MAX_VERSION = 40
# For use in getPenaltyScore(), when evaluating which mask is best. # For use in getPenaltyScore(), when evaluating which mask is best.
_PENALTY_N1 = 3 _PENALTY_N1 = 3

@ -673,14 +673,12 @@ impl QrCode {
} }
/*---- Public constants ----*/ /*---- Cconstants and tables ----*/
pub const QrCode_MIN_VERSION: Version = Version( 1); pub const QrCode_MIN_VERSION: Version = Version( 1);
pub const QrCode_MAX_VERSION: Version = Version(40); pub const QrCode_MAX_VERSION: Version = Version(40);
/*---- Private tables of constants ----*/
// For use in get_penalty_score(), when evaluating which mask is best. // For use in get_penalty_score(), when evaluating which mask is best.
const PENALTY_N1: i32 = 3; const PENALTY_N1: i32 = 3;
const PENALTY_N2: i32 = 3; const PENALTY_N2: i32 = 3;

@ -604,20 +604,17 @@ namespace qrcodegen {
} }
/*-- Constants --*/ /*-- Constants and tables --*/
public static readonly MIN_VERSION: int = 1; public static readonly MIN_VERSION: int = 1;
public static readonly MAX_VERSION: int = 40; public static readonly MAX_VERSION: int = 40;
// For use in getPenaltyScore(), when evaluating which mask is best. // For use in getPenaltyScore(), when evaluating which mask is best.
private static readonly PENALTY_N1: int = 3; private static readonly PENALTY_N1: int = 3;
private static readonly PENALTY_N2: int = 3; private static readonly PENALTY_N2: int = 3;
private static readonly PENALTY_N3: int = 40; private static readonly PENALTY_N3: int = 40;
private static readonly PENALTY_N4: int = 10; private static readonly PENALTY_N4: int = 10;
/*-- Private tables of constants --*/
private static readonly ECC_CODEWORDS_PER_BLOCK: Array<Array<int>> = [ private static readonly ECC_CODEWORDS_PER_BLOCK: Array<Array<int>> = [
// Version: (note that index 0 is for padding, and is set to an illegal value) // Version: (note that index 0 is for padding, and is set to an illegal value)
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level

Loading…
Cancel
Save