From eab76f20d63c7b069ff096b73fa2cb46d7a6c03e Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Fri, 5 Oct 2018 00:40:49 +0000 Subject: [PATCH] Updated class QrCode's field comments, in most languages. --- cpp/QrCode.hpp | 12 ++++++++---- java/io/nayuki/qrcodegen/QrCode.java | 12 ++++++++---- python/qrcodegen.py | 8 ++++++-- rust/src/lib.rs | 8 ++++++-- typescript/qrcodegen.ts | 4 ++-- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/cpp/QrCode.hpp b/cpp/QrCode.hpp index a9caf80..3de3bc2 100644 --- a/cpp/QrCode.hpp +++ b/cpp/QrCode.hpp @@ -92,7 +92,7 @@ class QrCode final { /*---- Instance fields ----*/ - // Immutable scalar parameters + // Immutable scalar parameters: /* This QR Code symbol's version number, which is always between 1 and 40 (inclusive). */ private: int version; @@ -109,9 +109,13 @@ class QrCode final { * (mask = -1), the resulting object will still have a mask value between 0 and 7. */ private: int mask; - // Private grids of modules/pixels (conceptually immutable) - private: std::vector > modules; // The modules of this QR Code symbol (false = white, true = black) - private: std::vector > isFunction; // Indicates function modules that are not subjected to masking + // Private grids of modules/pixels, with dimensions of size*size: + + // The modules of this QR Code symbol (false = white, true = black). Immutable after constructor finishes. + private: std::vector > modules; + + // Indicates function modules that are not subjected to masking. Discarded when constructor finishes. + private: std::vector > isFunction; diff --git a/java/io/nayuki/qrcodegen/QrCode.java b/java/io/nayuki/qrcodegen/QrCode.java index e63b6ee..24603bf 100644 --- a/java/io/nayuki/qrcodegen/QrCode.java +++ b/java/io/nayuki/qrcodegen/QrCode.java @@ -171,7 +171,7 @@ public final class QrCode { /*---- Instance fields ----*/ - // Public immutable scalar parameters + // Public immutable scalar parameters: /** This QR Code symbol's version number, which is always between 1 and 40 (inclusive). */ public final int version; @@ -188,9 +188,13 @@ public final class QrCode { * (mask = -1), the resulting object will still have a mask value between 0 and 7. */ public final int mask; - // Private grids of modules/pixels (conceptually immutable) - private boolean[][] modules; // The modules of this QR Code symbol (false = white, true = black) - private boolean[][] isFunction; // Indicates function modules that are not subjected to masking + // Private grids of modules/pixels, with dimensions of size*size: + + // The modules of this QR Code symbol (false = white, true = black). Immutable after constructor finishes. + private boolean[][] modules; + + // Indicates function modules that are not subjected to masking. Discarded when constructor finishes. + private boolean[][] isFunction; diff --git a/python/qrcodegen.py b/python/qrcodegen.py index b4238b4..190dee2 100644 --- a/python/qrcodegen.py +++ b/python/qrcodegen.py @@ -164,9 +164,13 @@ class QrCode(object): if len(datacodewords) != QrCode._get_num_data_codewords(version, errcorlvl): raise ValueError("Invalid array length") + # Initialize grids of modules - self._modules = [[False] * self._size for _ in range(self._size)] # The modules of the QR symbol; start with entirely white grid - self._isfunction = [[False] * self._size for _ in range(self._size)] # Indicates function modules that are not subjected to masking + # The modules of this QR Code symbol (False = white, True = black). Immutable after constructor finishes + self._modules = [[False] * self._size for _ in range(self._size)] + # Indicates function modules that are not subjected to masking. Discarded when constructor finishes + self._isfunction = [[False] * self._size for _ in range(self._size)] + # Draw function patterns, draw all codewords self._draw_function_patterns() allcodewords = self._add_ecc_and_interleave(datacodewords) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 1821946..ac10d47 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -31,6 +31,8 @@ #[derive(Clone)] pub struct QrCode { + // Scalar parameters: + // This QR Code symbol's version number, which is always between 1 and 40 (inclusive). version: Version, @@ -46,10 +48,12 @@ pub struct QrCode { // (mask = -1), the resulting object will still have a mask value between 0 and 7. mask: Mask, - // The modules of this QR Code symbol (false = white, true = black) + // Grids of modules/pixels, with dimensions of size*size: + + // The modules of this QR Code symbol (false = white, true = black). Immutable after constructor finishes. modules: Vec, - // Indicates function modules that are not subjected to masking + // Indicates function modules that are not subjected to masking. Discarded when constructor finishes. isfunction: Vec, } diff --git a/typescript/qrcodegen.ts b/typescript/qrcodegen.ts index 2353ce1..36015b9 100644 --- a/typescript/qrcodegen.ts +++ b/typescript/qrcodegen.ts @@ -137,10 +137,10 @@ namespace qrcodegen { // Always equal to version * 4 + 17, in the range 21 to 177. public readonly size: int; - // The modules of this QR Code symbol (false = white, true = black). + // The modules of this QR Code symbol (false = white, true = black). Immutable after constructor finishes. private readonly modules: Array> = []; - // Indicates function modules that are not subjected to masking. + // Indicates function modules that are not subjected to masking. Discarded when constructor finishes. private readonly isFunction: Array> = [];