From 950955a4c5d97662317f6cfe625b0c7364beafff Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Sat, 6 Oct 2018 04:49:04 +0000 Subject: [PATCH] Renamed QrSegment.getBits() to getData() in {Java, JavaScript, TypeScript, Python} code, to match C++ and Rust. --- java/io/nayuki/qrcodegen/QrSegment.java | 4 ++-- javascript/qrcodegen.js | 10 ++++++---- python/qrcodegen.py | 6 +++--- typescript/qrcodegen.ts | 6 +++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/java/io/nayuki/qrcodegen/QrSegment.java b/java/io/nayuki/qrcodegen/QrSegment.java index 9f9c74c..0f13947 100644 --- a/java/io/nayuki/qrcodegen/QrSegment.java +++ b/java/io/nayuki/qrcodegen/QrSegment.java @@ -173,7 +173,7 @@ public final class QrSegment { * Always zero or positive. Not the same as the data's bit length. */ public final int numChars; - /** The data bits of this segment. Not {@code null}. Accessed through {@link #getBits()}. */ + /** The data bits of this segment. Not {@code null}. Accessed through {@link #getData()}. */ final BitBuffer data; @@ -205,7 +205,7 @@ public final class QrSegment { * Returns the data bits of this segment. * @return a new copy of the data bits (not {@code null}) */ - public BitBuffer getBits() { + public BitBuffer getData() { return data.clone(); // Make defensive copy } diff --git a/javascript/qrcodegen.js b/javascript/qrcodegen.js index b4a6d89..1834294 100644 --- a/javascript/qrcodegen.js +++ b/javascript/qrcodegen.js @@ -50,7 +50,7 @@ * - Constructor QrSegment(QrSegment.Mode mode, int numChars, list bitData) * - Field QrSegment.Mode mode * - Field int numChars - * - Method getBits() -> list + * - Method getData() -> list * - Constants RegExp NUMERIC_REGEX, ALPHANUMERIC_REGEX * - Enum Mode: * - Constants NUMERIC, ALPHANUMERIC, BYTE, KANJI, ECI @@ -597,7 +597,7 @@ var qrcodegen = new function() { segs.forEach(function(seg) { bb.appendBits(seg.mode.modeBits, 4); bb.appendBits(seg.numChars, seg.mode.numCharCountBits(version)); - seg.getBits().forEach(function(bit) { + seg.getData().forEach(function(bit) { bb.push(bit); }); }); @@ -738,6 +738,8 @@ var qrcodegen = new function() { /*---- Constructor (low level) ----*/ if (numChars < 0 || !(mode instanceof Mode)) throw "Invalid argument"; + + // The data bits of this segment. Accessed through getData(). bitData = bitData.slice(); // Make defensive copy // The mode indicator of this segment. @@ -749,7 +751,7 @@ var qrcodegen = new function() { Object.defineProperty(this, "numChars", {value:numChars}); // Returns a new copy of the data bits of this segment. - this.getBits = function() { + this.getData = function() { return bitData.slice(); // Make defensive copy }; }; @@ -856,7 +858,7 @@ var qrcodegen = new function() { var ccbits = seg.mode.numCharCountBits(version); if (seg.numChars >= (1 << ccbits)) return Infinity; // The segment's length doesn't fit the field's bit width - result += 4 + ccbits + seg.getBits().length; + result += 4 + ccbits + seg.getData().length; } return result; }; diff --git a/python/qrcodegen.py b/python/qrcodegen.py index 0be9a2d..ca9bdf4 100644 --- a/python/qrcodegen.py +++ b/python/qrcodegen.py @@ -51,7 +51,7 @@ This module "qrcodegen", public members: - Constructor QrSegment(QrSegment.Mode mode, int numch, list bitdata) - Method get_mode() -> QrSegment.Mode - Method get_num_chars() -> int - - Method get_bits() -> list + - Method get_data() -> list - Constants regex NUMERIC_REGEX, ALPHANUMERIC_REGEX - Enum Mode: - Constants NUMERIC, ALPHANUMERIC, BYTE, KANJI, ECI @@ -733,7 +733,7 @@ class QrSegment(object): # Accessed through get_num_chars(). self._numchars = numch - # The data bits of this segment. Accessed through get_bits(). + # The data bits of this segment. Accessed through get_data(). self._bitdata = list(bitdata) # Make defensive copy @@ -747,7 +747,7 @@ class QrSegment(object): """Returns the character count field of this segment.""" return self._numchars - def get_bits(self): + def get_data(self): """Returns a new copy of the data bits of this segment.""" return list(self._bitdata) # Make defensive copy diff --git a/typescript/qrcodegen.ts b/typescript/qrcodegen.ts index a1a6987..1fbfa45 100644 --- a/typescript/qrcodegen.ts +++ b/typescript/qrcodegen.ts @@ -118,7 +118,7 @@ namespace qrcodegen { for (let seg of segs) { bb.appendBits(seg.mode.modeBits, 4); bb.appendBits(seg.numChars, seg.mode.numCharCountBits(version)); - for (let b of seg.getBits()) + for (let b of seg.getData()) bb.push(b); } if (bb.length != dataUsedBits) @@ -783,7 +783,7 @@ namespace qrcodegen { // Always zero or positive. Not the same as the data's bit length. public readonly numChars: int, - // The data bits of this segment. Accessed through getBits(). + // The data bits of this segment. Accessed through getData(). private readonly bitData: Array) { if (numChars < 0) @@ -795,7 +795,7 @@ namespace qrcodegen { /*-- Methods --*/ // Returns a new copy of the data bits of this segment. - public getBits(): Array { + public getData(): Array { return this.bitData.slice(); // Make defensive copy }