From a5b6c28a1f3dba1bb96a10696ce98c058d3d8ceb Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Fri, 5 Oct 2018 20:56:50 +0000 Subject: [PATCH] Updated and synchronized documentation comments for QrCode class's fields and constants, in all languages. --- c/qrcodegen.h | 5 ++--- cpp/QrCode.hpp | 16 ++++++++++------ java/io/nayuki/qrcodegen/QrCode.java | 18 +++++++++++------- javascript/qrcodegen.js | 17 +++++++++-------- python/qrcodegen.py | 16 ++++++++++++++-- rust/src/lib.rs | 16 ++++++++++------ typescript/qrcodegen.ts | 15 +++++++++------ 7 files changed, 65 insertions(+), 38 deletions(-) diff --git a/c/qrcodegen.h b/c/qrcodegen.h index cdcc879..bc410f9 100644 --- a/c/qrcodegen.h +++ b/c/qrcodegen.h @@ -113,9 +113,8 @@ struct qrcodegen_Segment { /*---- Macro constants and functions ----*/ -// The minimum and maximum defined QR Code version numbers for Model 2. -#define qrcodegen_VERSION_MIN 1 -#define qrcodegen_VERSION_MAX 40 +#define qrcodegen_VERSION_MIN 1 // The minimum version number supported in the QR Code Model 2 standard +#define qrcodegen_VERSION_MAX 40 // The maximum version number supported in the QR Code Model 2 standard // Calculates the number of bytes needed to store any QR Code up to and including the given version number, // as a compile-time constant. For example, 'uint8_t buffer[qrcodegen_BUFFER_LEN_FOR_VERSION(25)];' diff --git a/cpp/QrCode.hpp b/cpp/QrCode.hpp index 075591f..3a644d5 100644 --- a/cpp/QrCode.hpp +++ b/cpp/QrCode.hpp @@ -96,19 +96,20 @@ class QrCode final { // Immutable scalar parameters: - /* This QR Code's version number, which is always between 1 and 40 (inclusive). */ + /* The version number of this QR Code, which is between 1 and 40 (inclusive). + * This determines the size of this barcode. */ private: int version; - /* The width and height of this QR Code, measured in modules. - * Always equal to version * 4 + 17, in the range 21 to 177. */ + /* The width and height of this QR Code, measured in modules, between + * 21 and 177 (inclusive). This is equal to version * 4 + 17. */ private: int size; /* The error correction level used in this QR Code. */ private: Ecc errorCorrectionLevel; - /* The mask pattern used in this QR Code, in the range 0 to 7 (i.e. unsigned 3-bit integer). - * Note that even if a constructor was called with automatic masking requested - * (mask = -1), the resulting object will still have a mask value between 0 and 7. */ + /* The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive). + * Even if a QR Code is created with automatic masking requested (mask = -1), + * the resulting object still has a mask value between 0 and 7. */ private: int mask; // Private grids of modules/pixels, with dimensions of size*size: @@ -255,7 +256,10 @@ class QrCode final { /*---- Constants and tables ----*/ + // The minimum version number supported in the QR Code Model 2 standard. public: static constexpr int MIN_VERSION = 1; + + // The maximum version number supported in the QR Code Model 2 standard. public: static constexpr int MAX_VERSION = 40; diff --git a/java/io/nayuki/qrcodegen/QrCode.java b/java/io/nayuki/qrcodegen/QrCode.java index 683eedc..ca57ebe 100644 --- a/java/io/nayuki/qrcodegen/QrCode.java +++ b/java/io/nayuki/qrcodegen/QrCode.java @@ -173,19 +173,20 @@ public final class QrCode { // Public immutable scalar parameters: - /** This QR Code's version number, which is always between 1 and 40 (inclusive). */ + /** The version number of this QR Code, which is between 1 and 40 (inclusive). + * This determines the size of this barcode. */ public final int version; - /** The width and height of this QR Code, measured in modules. - * Always equal to version × 4 + 17, in the range 21 to 177 (inclusive). */ + /** The width and height of this QR Code, measured in modules, between + * 21 and 177 (inclusive). This is equal to version × 4 + 17. */ public final int size; - /** The error correction level used in this QR Code. Never {@code null}. */ + /** The error correction level used in this QR Code, which is not {@code null}. */ public final Ecc errorCorrectionLevel; - /** The mask pattern used in this QR Code, in the range 0 to 7 (i.e. unsigned 3-bit integer). - * Note that even if a constructor was called with automatic masking requested - * (mask = -1), the resulting object will still have a mask value between 0 and 7. */ + /** The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive). + *

Even if a QR Code is created with automatic masking requested (mask = + * −1), the resulting object still has a mask value between 0 and 7. */ public final int mask; // Private grids of modules/pixels, with dimensions of size*size: @@ -705,7 +706,10 @@ public final class QrCode { /*---- Constants and tables ----*/ + /** The minimum version number (1) supported in the QR Code Model 2 standard. */ public static final int MIN_VERSION = 1; + + /** The maximum version number (40) supported in the QR Code Model 2 standard. */ public static final int MAX_VERSION = 40; diff --git a/javascript/qrcodegen.js b/javascript/qrcodegen.js index d2d3ede..d395c21 100644 --- a/javascript/qrcodegen.js +++ b/javascript/qrcodegen.js @@ -121,19 +121,20 @@ var qrcodegen = new function() { /*---- Read-only instance properties ----*/ - // This QR Code's version number, which is always between 1 and 40 (inclusive). + // The version number of this QR Code, which is between 1 and 40 (inclusive). + // This determines the size of this barcode. Object.defineProperty(this, "version", {value:version}); - // The width and height of this QR Code, measured in modules. - // Always equal to version * 4 + 17, in the range 21 to 177. + // The width and height of this QR Code, measured in modules, between + // 21 and 177 (inclusive). This is equal to version * 4 + 17. Object.defineProperty(this, "size", {value:size}); // The error correction level used in this QR Code. Object.defineProperty(this, "errorCorrectionLevel", {value:errCorLvl}); - // The mask pattern used in this QR Code, 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. + // The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive). + // Even if a QR Code is created with automatic masking requested (mask = -1), + // the resulting object still has a mask value between 0 and 7. Object.defineProperty(this, "mask", {value:mask}); @@ -638,8 +639,8 @@ var qrcodegen = new function() { /*---- Constants and tables for QrCode ----*/ - var MIN_VERSION = 1; - var MAX_VERSION = 40; + var MIN_VERSION = 1; // The minimum version number supported in the QR Code Model 2 standard + var MAX_VERSION = 40; // The maximum version number supported in the QR Code Model 2 standard Object.defineProperty(this.QrCode, "MIN_VERSION", {value:MIN_VERSION}); Object.defineProperty(this.QrCode, "MAX_VERSION", {value:MAX_VERSION}); diff --git a/python/qrcodegen.py b/python/qrcodegen.py index 9e49c25..377c352 100644 --- a/python/qrcodegen.py +++ b/python/qrcodegen.py @@ -158,8 +158,16 @@ class QrCode(object): raise ValueError("Mask value out of range") if not isinstance(errcorlvl, QrCode.Ecc): raise TypeError("QrCode.Ecc expected") + + # The version number of this QR Code, which is between 1 and 40 (inclusive). + # This determines the size of this barcode. self._version = version + + # The width and height of this QR Code, measured in modules, between + # 21 and 177 (inclusive). This is equal to version * 4 + 17. self._size = version * 4 + 17 + + # The error correction level used in this QR Code. self._errcorlvl = errcorlvl # Initialize both grids to be size*size arrays of Boolean false @@ -187,6 +195,10 @@ class QrCode(object): assert 0 <= mask <= 7 self._draw_format_bits(mask) # Overwrite old format bits self._apply_mask(mask) # Apply the final choice of mask + + # The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive). + # Even if a QR Code is created with automatic masking requested (mask = -1), + # the resulting object still has a mask value between 0 and 7. self._mask = mask del self._isfunction @@ -529,8 +541,8 @@ class QrCode(object): # ---- Constants and tables ---- - MIN_VERSION = 1 - MAX_VERSION = 40 + MIN_VERSION = 1 # The minimum version number supported in the QR Code Model 2 standard + MAX_VERSION = 40 # The maximum version number supported in the QR Code Model 2 standard # For use in getPenaltyScore(), when evaluating which mask is best. _PENALTY_N1 = 3 diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 66e8c1a..4100d37 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -33,19 +33,20 @@ pub struct QrCode { // Scalar parameters: - // This QR Code's version number, which is always between 1 and 40 (inclusive). + // The version number of this QR Code, which is between 1 and 40 (inclusive). + // This determines the size of this barcode. version: Version, - // The width and height of this QR Code, measured in modules. - // Always equal to version * 4 + 17, in the range 21 to 177. + // The width and height of this QR Code, measured in modules, between + // 21 and 177 (inclusive). This is equal to version * 4 + 17. size: i32, // The error correction level used in this QR Code. errorcorrectionlevel: QrCodeEcc, - // The mask pattern used in this QR Code, in the range 0 to 7 (i.e. unsigned 3-bit integer). - // Note that even if a constructor was called with automatic masking requested - // (mask = -1), the resulting object will still have a mask value between 0 and 7. + // The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive). + // Even if a QR Code is created with automatic masking requested (mask = None), + // the resulting object still has a mask value between 0 and 7. mask: Mask, // Grids of modules/pixels, with dimensions of size*size: @@ -681,7 +682,10 @@ impl QrCode { /*---- Cconstants and tables ----*/ +// The minimum version number supported in the QR Code Model 2 standard. pub const QrCode_MIN_VERSION: Version = Version( 1); + +// The maximum version number supported in the QR Code Model 2 standard. pub const QrCode_MAX_VERSION: Version = Version(40); diff --git a/typescript/qrcodegen.ts b/typescript/qrcodegen.ts index 8c4e165..928ca89 100644 --- a/typescript/qrcodegen.ts +++ b/typescript/qrcodegen.ts @@ -133,8 +133,8 @@ namespace qrcodegen { /*-- Fields --*/ - // The width and height of this QR Code, measured in modules. - // Always equal to version * 4 + 17, in the range 21 to 177. + // The width and height of this QR Code, measured in modules, between + // 21 and 177 (inclusive). This is equal to version * 4 + 17. public readonly size: int; // The modules of this QR Code (false = white, true = black). Immutable after constructor finishes. @@ -147,7 +147,8 @@ namespace qrcodegen { /*-- Constructor (low level) and fields --*/ public constructor( - // This QR Code's version number, which is always between 1 and 40 (inclusive). + // The version number of this QR Code, which is between 1 and 40 (inclusive). + // This determines the size of this barcode. public readonly version: int, // The error correction level used in this QR Code. @@ -155,9 +156,9 @@ namespace qrcodegen { dataCodewords: Array, - // The mask pattern used in this QR Code, 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. + // The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive). + // Even if a QR Code is created with automatic masking requested (mask = -1), + // the resulting object still has a mask value between 0 and 7. public readonly mask: int) { // Check scalar arguments @@ -609,7 +610,9 @@ namespace qrcodegen { /*-- Constants and tables --*/ + // The minimum version number supported in the QR Code Model 2 standard. public static readonly MIN_VERSION: int = 1; + // The maximum version number supported in the QR Code Model 2 standard. public static readonly MAX_VERSION: int = 40; // For use in getPenaltyScore(), when evaluating which mask is best.