Changed ~4 members to package-private in all language versions, updating code in Java version but only updating comments in JavaScript, Python, C++ versions.

This commit is contained in:
Nayuki Minase 2016-04-20 20:40:49 +00:00
parent be316029aa
commit f63f890235
6 changed files with 17 additions and 18 deletions

View File

@ -54,7 +54,7 @@ public:
// Fields. // Fields.
public: public:
const int ordinal; // In the range 0 to 3 (unsigned 2-bit integer). const int ordinal; // In the range 0 to 3 (unsigned 2-bit integer).
const int formatBits; // In the range 0 to 3 (unsigned 2-bit integer). const int formatBits; // (Package-private) In the range 0 to 3 (unsigned 2-bit integer).
// Constructor. // Constructor.
private: private:

View File

@ -59,7 +59,7 @@ public:
/*-- Fields --*/ /*-- Fields --*/
/* An unsigned 4-bit integer value (range 0 to 15) representing the mode indicator bits for this mode object. */ /* (Package-private) An unsigned 4-bit integer value (range 0 to 15) representing the mode indicator bits for this mode object. */
public: public:
const int modeBits; const int modeBits;
@ -76,7 +76,7 @@ public:
/*-- Method --*/ /*-- Method --*/
/* /*
* Returns the bit width of the segment character count field for this mode object at the given version number. * (Package-private) Returns the bit width of the segment character count field for this mode object at the given version number.
*/ */
public: public:
int numCharCountBits(int ver) const; int numCharCountBits(int ver) const;

View File

@ -755,7 +755,7 @@ public final class QrCode {
LOW(1), MEDIUM(0), QUARTILE(3), HIGH(2); LOW(1), MEDIUM(0), QUARTILE(3), HIGH(2);
// In the range 0 to 3 (unsigned 2-bit integer). // In the range 0 to 3 (unsigned 2-bit integer).
public final int formatBits; final int formatBits;
// Constructor. // Constructor.
private Ecc(int fb) { private Ecc(int fb) {

View File

@ -243,7 +243,7 @@ public final class QrSegment {
/*-- Fields --*/ /*-- Fields --*/
/** An unsigned 4-bit integer value (range 0 to 15) representing the mode indicator bits for this mode object. */ /** An unsigned 4-bit integer value (range 0 to 15) representing the mode indicator bits for this mode object. */
public final int modeBits; final int modeBits;
private final int[] numBitsCharCount; private final int[] numBitsCharCount;
@ -264,7 +264,7 @@ public final class QrSegment {
* @return the number of bits for the character count, which is between 8 to 16, inclusive * @return the number of bits for the character count, which is between 8 to 16, inclusive
* @throws IllegalArgumentException if the version number is out of range * @throws IllegalArgumentException if the version number is out of range
*/ */
public int numCharCountBits(int ver) { int numCharCountBits(int ver) {
if ( 1 <= ver && ver <= 9) return numBitsCharCount[0]; if ( 1 <= ver && ver <= 9) return numBitsCharCount[0];
else if (10 <= ver && ver <= 26) return numBitsCharCount[1]; else if (10 <= ver && ver <= 26) return numBitsCharCount[1];
else if (27 <= ver && ver <= 40) return numBitsCharCount[2]; else if (27 <= ver && ver <= 40) return numBitsCharCount[2];

View File

@ -37,11 +37,10 @@
* - Fields int version, size, mask * - Fields int version, size, mask
* - Field QrCode.Ecc errorCorrectionLevel * - Field QrCode.Ecc errorCorrectionLevel
* - Method getModule(int x, int y) -> int * - Method getModule(int x, int y) -> int
* - Method isFunctionModule(int x, int y) -> bool
* - Method toSvgString(int border) -> str * - Method toSvgString(int border) -> str
* - Enum Ecc: * - Enum Ecc:
* - Constants LOW, MEDIUM, QUARTILE, HIGH * - Constants LOW, MEDIUM, QUARTILE, HIGH
* - Fields int ordinal, formatBits * - Field int ordinal
* - Class QrSegment: * - Class QrSegment:
* - Function makeBytes(list<int> data) -> QrSegment * - Function makeBytes(list<int> data) -> QrSegment
* - Function makeNumeric(str data) -> QrSegment * - Function makeNumeric(str data) -> QrSegment
@ -53,8 +52,6 @@
* - Method getBits() -> list<int> * - Method getBits() -> list<int>
* - Enum Mode: * - Enum Mode:
* - Constants NUMERIC, ALPHANUMERIC, BYTE, KANJI * - Constants NUMERIC, ALPHANUMERIC, BYTE, KANJI
* - Field int modeBits
* - Method numCharCountBits(int ver) -> int
*/ */
var qrcodegen = new function() { var qrcodegen = new function() {
@ -172,8 +169,9 @@ var qrcodegen = new function() {
return 0; // Infinite white border return 0; // Infinite white border
}; };
// Tests whether the module at the given coordinates is a function module (true) or not (false). The top left // (Package-private) Tests whether the module at the given coordinates is a function module (true) or not (false).
// corner has the coordinates (x=0, y=0). If the given coordinates are out of bounds, then false is returned. // The top left corner has the coordinates (x=0, y=0). If the given coordinates are out of bounds, then false is returned.
// The JavaScript version of this library has this method because it is impossible to access private variables of another object.
this.isFunctionModule = function(x, y) { this.isFunctionModule = function(x, y) {
if (0 <= x && x < size && 0 <= y && y < size) if (0 <= x && x < size && 0 <= y && y < size)
return isFunction[y][x]; return isFunction[y][x];
@ -681,6 +679,7 @@ var qrcodegen = new function() {
// (Public) In the range 0 to 3 (unsigned 2-bit integer) // (Public) In the range 0 to 3 (unsigned 2-bit integer)
Object.defineProperty(this, "ordinal", {value:ord}); Object.defineProperty(this, "ordinal", {value:ord});
// (Package-private) In the range 0 to 3 (unsigned 2-bit integer)
Object.defineProperty(this, "formatBits", {value:fb}); Object.defineProperty(this, "formatBits", {value:fb});
} }
@ -844,10 +843,10 @@ var qrcodegen = new function() {
// Private constructor. // Private constructor.
function Mode(mode, ccbits) { function Mode(mode, ccbits) {
// An unsigned 4-bit integer value (range 0 to 15) representing the mode indicator bits for this mode object. // (Package-private) An unsigned 4-bit integer value (range 0 to 15) representing the mode indicator bits for this mode object.
Object.defineProperty(this, "modeBits", {value:mode}); Object.defineProperty(this, "modeBits", {value:mode});
// Returns the bit width of the segment character count field for this mode object at the given version number. // (Package-private) Returns the bit width of the segment character count field for this mode object at the given version number.
this.numCharCountBits = function(ver) { this.numCharCountBits = function(ver) {
if ( 1 <= ver && ver <= 9) return ccbits[0]; if ( 1 <= ver && ver <= 9) return ccbits[0];
else if (10 <= ver && ver <= 26) return ccbits[1]; else if (10 <= ver && ver <= 26) return ccbits[1];

View File

@ -42,7 +42,7 @@ This module "qrcodegen", public members:
- Method to_svg_str(int border) -> str - Method to_svg_str(int border) -> str
- Enum Ecc: - Enum Ecc:
- Constants LOW, MEDIUM, QUARTILE, HIGH - Constants LOW, MEDIUM, QUARTILE, HIGH
- Fields int ordinal, formatbits - Field int ordinal
- Class QrSegment: - Class QrSegment:
- Function make_bytes(bytes data) -> QrSegment - Function make_bytes(bytes data) -> QrSegment
- Function make_numeric(str digits) -> QrSegment - Function make_numeric(str digits) -> QrSegment
@ -54,8 +54,6 @@ This module "qrcodegen", public members:
- Method get_bits() -> list<int> - Method get_bits() -> list<int>
- Enum Mode: - Enum Mode:
- Constants NUMERIC, ALPHANUMERIC, BYTE, KANJI - Constants NUMERIC, ALPHANUMERIC, BYTE, KANJI
- Method get_mode_bits() -> int
- Method num_char_count_bits(int ver) -> int
""" """
@ -584,7 +582,7 @@ class QrCode(object):
# Private constructor # Private constructor
def __init__(self, i, fb): def __init__(self, i, fb):
self.ordinal = i # In the range 0 to 3 (unsigned 2-bit integer) self.ordinal = i # In the range 0 to 3 (unsigned 2-bit integer)
self.formatbits = fb # In the range 0 to 3 (unsigned 2-bit integer) self.formatbits = fb # (Package-private) In the range 0 to 3 (unsigned 2-bit integer)
# Public constants. Create them outside the class. # Public constants. Create them outside the class.
Ecc.LOW = Ecc(0, 1) Ecc.LOW = Ecc(0, 1)
@ -724,10 +722,12 @@ class QrSegment(object):
self._modebits = modebits self._modebits = modebits
self._charcounts = charcounts self._charcounts = charcounts
# Package-private method
def get_mode_bits(self): def get_mode_bits(self):
"""Returns an unsigned 4-bit integer value (range 0 to 15) representing the mode indicator bits for this mode object.""" """Returns an unsigned 4-bit integer value (range 0 to 15) representing the mode indicator bits for this mode object."""
return self._modebits return self._modebits
# Package-private method
def num_char_count_bits(self, ver): def num_char_count_bits(self, ver):
"""Returns the bit width of the segment character count field for this mode object at the given version number.""" """Returns the bit width of the segment character count field for this mode object at the given version number."""
if 1 <= ver <= 9: return self._charcounts[0] if 1 <= ver <= 9: return self._charcounts[0]