Tweaked two comments in QrCode constructor, in all languages except C.

pull/39/merge
Project Nayuki 6 years ago
parent f63f7f79a6
commit d060e97e03

@ -119,14 +119,14 @@ QrCode::QrCode(int ver, Ecc ecl, const vector<uint8_t> &dataCodewords, int mask)
version(ver), version(ver),
size(MIN_VERSION <= ver && ver <= MAX_VERSION ? ver * 4 + 17 : -1), // Avoid signed overflow undefined behavior size(MIN_VERSION <= ver && ver <= MAX_VERSION ? ver * 4 + 17 : -1), // Avoid signed overflow undefined behavior
errorCorrectionLevel(ecl), errorCorrectionLevel(ecl),
modules (size, vector<bool>(size)), // Entirely white grid modules (size, vector<bool>(size)), // Initially all white
isFunction(size, vector<bool>(size)) { isFunction(size, vector<bool>(size)) {
// Check arguments // Check arguments
if (ver < MIN_VERSION || ver > MAX_VERSION || mask < -1 || mask > 7) if (ver < MIN_VERSION || ver > MAX_VERSION || mask < -1 || mask > 7)
throw std::domain_error("Value out of range"); throw std::domain_error("Value out of range");
// Draw function patterns, draw all codewords, do masking // Compute ECC, draw modules, do masking
drawFunctionPatterns(); drawFunctionPatterns();
const vector<uint8_t> allCodewords = addEccAndInterleave(dataCodewords); const vector<uint8_t> allCodewords = addEccAndInterleave(dataCodewords);
drawCodewords(allCodewords); drawCodewords(allCodewords);

@ -222,10 +222,10 @@ public final class QrCode {
// Initialize fields // Initialize fields
version = ver; version = ver;
size = ver * 4 + 17; size = ver * 4 + 17;
modules = new boolean[size][size]; // Entirely white grid modules = new boolean[size][size]; // Initially all white
isFunction = new boolean[size][size]; isFunction = new boolean[size][size];
// Draw function patterns, draw all codewords, do masking // Compute ECC, draw modules, do masking
drawFunctionPatterns(); drawFunctionPatterns();
byte[] allCodewords = addEccAndInterleave(dataCodewords); byte[] allCodewords = addEccAndInterleave(dataCodewords);
drawCodewords(allCodewords); drawCodewords(allCodewords);

@ -83,14 +83,14 @@ var qrcodegen = new function() {
var row = []; var row = [];
for (var i = 0; i < size; i++) for (var i = 0; i < size; i++)
row.push(false); row.push(false);
var modules = []; var modules = []; // Initially all white
var isFunction = []; var isFunction = [];
for (var i = 0; i < size; i++) { for (var i = 0; i < size; i++) {
modules .push(row.slice()); modules .push(row.slice());
isFunction.push(row.slice()); isFunction.push(row.slice());
} }
// Handle grid fields, draw function patterns, draw all codewords // Compute ECC, draw modules
drawFunctionPatterns(); drawFunctionPatterns();
var allCodewords = addEccAndInterleave(dataCodewords); var allCodewords = addEccAndInterleave(dataCodewords);
drawCodewords(allCodewords); drawCodewords(allCodewords);

@ -167,11 +167,11 @@ class QrCode(object):
# Initialize grids of modules # Initialize grids of modules
# The modules of this QR Code symbol (False = white, True = black). Immutable after constructor finishes # 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)] self._modules = [[False] * self._size for _ in range(self._size)] # Initially all white
# Indicates function modules that are not subjected to masking. Discarded when constructor finishes # Indicates function modules that are not subjected to masking. Discarded when constructor finishes
self._isfunction = [[False] * self._size for _ in range(self._size)] self._isfunction = [[False] * self._size for _ in range(self._size)]
# Draw function patterns, draw all codewords # Compute ECC, draw modules
self._draw_function_patterns() self._draw_function_patterns()
allcodewords = self._add_ecc_and_interleave(datacodewords) allcodewords = self._add_ecc_and_interleave(datacodewords)
self._draw_codewords(allcodewords) self._draw_codewords(allcodewords)

@ -186,11 +186,11 @@ impl QrCode {
size: size as i32, size: size as i32,
mask: Mask::new(0), // Dummy value mask: Mask::new(0), // Dummy value
errorcorrectionlevel: ecl, errorcorrectionlevel: ecl,
modules : vec![false; size * size], // Entirely white grid modules : vec![false; size * size], // Initially all white
isfunction: vec![false; size * size], isfunction: vec![false; size * size],
}; };
// Draw function patterns, draw all codewords, do masking // Compute ECC, draw modules, do masking
result.draw_function_patterns(); result.draw_function_patterns();
let allcodewords: Vec<u8> = result.add_ecc_and_interleave(datacodewords); let allcodewords: Vec<u8> = result.add_ecc_and_interleave(datacodewords);
result.draw_codewords(&allcodewords); result.draw_codewords(&allcodewords);

@ -172,11 +172,11 @@ namespace qrcodegen {
for (let i = 0; i < this.size; i++) for (let i = 0; i < this.size; i++)
row.push(false); row.push(false);
for (let i = 0; i < this.size; i++) { for (let i = 0; i < this.size; i++) {
this.modules .push(row.slice()); this.modules .push(row.slice()); // Initially all white
this.isFunction.push(row.slice()); this.isFunction.push(row.slice());
} }
// Handle grid fields, draw function patterns, draw all codewords // Compute ECC, draw modules
this.drawFunctionPatterns(); this.drawFunctionPatterns();
let allCodewords: Array<byte> = this.addEccAndInterleave(dataCodewords); let allCodewords: Array<byte> = this.addEccAndInterleave(dataCodewords);
this.drawCodewords(allCodewords); this.drawCodewords(allCodewords);

Loading…
Cancel
Save