Renamed QrSegment.getBits() to getData() in {Java, JavaScript, TypeScript, Python} code, to match C++ and Rust.

This commit is contained in:
Project Nayuki 2018-10-06 04:49:04 +00:00
parent b7922a8dce
commit 950955a4c5
4 changed files with 14 additions and 12 deletions

View File

@ -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
}

View File

@ -50,7 +50,7 @@
* - Constructor QrSegment(QrSegment.Mode mode, int numChars, list<int> bitData)
* - Field QrSegment.Mode mode
* - Field int numChars
* - Method getBits() -> list<int>
* - Method getData() -> list<int>
* - 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;
};

View File

@ -51,7 +51,7 @@ This module "qrcodegen", public members:
- Constructor QrSegment(QrSegment.Mode mode, int numch, list<int> bitdata)
- Method get_mode() -> QrSegment.Mode
- Method get_num_chars() -> int
- Method get_bits() -> list<int>
- Method get_data() -> list<int>
- 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

View File

@ -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<bit>) {
if (numChars < 0)
@ -795,7 +795,7 @@ namespace qrcodegen {
/*-- Methods --*/
// Returns a new copy of the data bits of this segment.
public getBits(): Array<bit> {
public getData(): Array<bit> {
return this.bitData.slice(); // Make defensive copy
}