mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-28 05:12:34 +00:00
warning cleanup
This commit is contained in:
@@ -33,7 +33,7 @@ impl SimpleToken {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn appendTo(&self, bit_array: &mut BitArray, text: &[u8]) {
|
pub fn appendTo(&self, bit_array: &mut BitArray, _text: &[u8]) {
|
||||||
bit_array
|
bit_array
|
||||||
.appendBits(self.value as u32, self.bit_count as usize)
|
.appendBits(self.value as u32, self.bit_count as usize)
|
||||||
.expect("append should never fail");
|
.expect("append should never fail");
|
||||||
|
|||||||
@@ -474,7 +474,7 @@ impl BitArray {
|
|||||||
*/
|
*/
|
||||||
pub fn setRange(&mut self, start: usize, end: usize) -> Result<(), Exceptions> {
|
pub fn setRange(&mut self, start: usize, end: usize) -> Result<(), Exceptions> {
|
||||||
let mut end = end;
|
let mut end = end;
|
||||||
if end < start || start < 0 || end > self.size {
|
if end < start || end > self.size {
|
||||||
return Err(Exceptions::IllegalArgumentException(
|
return Err(Exceptions::IllegalArgumentException(
|
||||||
"end < start || start < 0 || end > self.size".to_owned(),
|
"end < start || start < 0 || end > self.size".to_owned(),
|
||||||
));
|
));
|
||||||
@@ -518,7 +518,7 @@ impl BitArray {
|
|||||||
*/
|
*/
|
||||||
pub fn isRange(&self, start: usize, end: usize, value: bool) -> Result<bool, Exceptions> {
|
pub fn isRange(&self, start: usize, end: usize, value: bool) -> Result<bool, Exceptions> {
|
||||||
let mut end = end;
|
let mut end = end;
|
||||||
if end < start || start < 0 || end > self.size {
|
if end < start || end > self.size {
|
||||||
return Err(Exceptions::IllegalArgumentException(
|
return Err(Exceptions::IllegalArgumentException(
|
||||||
"end < start || start < 0 || end > self.size".to_owned(),
|
"end < start || start < 0 || end > self.size".to_owned(),
|
||||||
));
|
));
|
||||||
@@ -1035,11 +1035,11 @@ impl BitMatrix {
|
|||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), Exceptions> {
|
) -> Result<(), Exceptions> {
|
||||||
if top < 0 || left < 0 {
|
// if top < 0 || left < 0 {
|
||||||
return Err(Exceptions::IllegalArgumentException(
|
// return Err(Exceptions::IllegalArgumentException(
|
||||||
"Left and top must be nonnegative".to_owned(),
|
// "Left and top must be nonnegative".to_owned(),
|
||||||
));
|
// ));
|
||||||
}
|
// }
|
||||||
if height < 1 || width < 1 {
|
if height < 1 || width < 1 {
|
||||||
return Err(Exceptions::IllegalArgumentException(
|
return Err(Exceptions::IllegalArgumentException(
|
||||||
"Height and width must be at least 1".to_owned(),
|
"Height and width must be at least 1".to_owned(),
|
||||||
@@ -1133,7 +1133,7 @@ impl BitMatrix {
|
|||||||
pub fn rotate180(&mut self) {
|
pub fn rotate180(&mut self) {
|
||||||
let mut topRow = BitArray::with_size(self.width as usize);
|
let mut topRow = BitArray::with_size(self.width as usize);
|
||||||
let mut bottomRow = BitArray::with_size(self.width as usize);
|
let mut bottomRow = BitArray::with_size(self.width as usize);
|
||||||
let mut maxHeight = (self.height + 1) / 2;
|
let maxHeight = (self.height + 1) / 2;
|
||||||
for i in 0..maxHeight {
|
for i in 0..maxHeight {
|
||||||
//for (int i = 0; i < maxHeight; i++) {
|
//for (int i = 0; i < maxHeight; i++) {
|
||||||
topRow = self.getRow(i, &topRow);
|
topRow = self.getRow(i, &topRow);
|
||||||
@@ -1150,9 +1150,9 @@ impl BitMatrix {
|
|||||||
* Modifies this {@code BitMatrix} to represent the same but rotated 90 degrees counterclockwise
|
* Modifies this {@code BitMatrix} to represent the same but rotated 90 degrees counterclockwise
|
||||||
*/
|
*/
|
||||||
pub fn rotate90(&mut self) {
|
pub fn rotate90(&mut self) {
|
||||||
let mut newWidth = self.height;
|
let newWidth = self.height;
|
||||||
let mut newHeight = self.width;
|
let newHeight = self.width;
|
||||||
let mut newRowSize = (newWidth + 31) / 32;
|
let newRowSize = (newWidth + 31) / 32;
|
||||||
let mut newBits = vec![0; (newRowSize * newHeight).try_into().unwrap()];
|
let mut newBits = vec![0; (newRowSize * newHeight).try_into().unwrap()];
|
||||||
|
|
||||||
for y in 0..self.height {
|
for y in 0..self.height {
|
||||||
|
|||||||
@@ -1213,7 +1213,7 @@ pub mod result_point_utils {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let mut pointA; //: &RXingResultPoint;
|
let mut pointA; //: &RXingResultPoint;
|
||||||
let mut pointB; //: &RXingResultPoint;
|
let pointB; //: &RXingResultPoint;
|
||||||
let mut pointC; //: &RXingResultPoint;
|
let mut pointC; //: &RXingResultPoint;
|
||||||
// Assume one closest to other two is B; A and C will just be guesses at first
|
// Assume one closest to other two is B; A and C will just be guesses at first
|
||||||
if oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance {
|
if oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ impl BitMatrixParser {
|
|||||||
// for (int x = 0; x < width; x++) {
|
// for (int x = 0; x < width; x++) {
|
||||||
let bit = bitnrRow[x];
|
let bit = bitnrRow[x];
|
||||||
if bit >= 0 && self.0.get(x as u32, y as u32) {
|
if bit >= 0 && self.0.get(x as u32, y as u32) {
|
||||||
result[bit as usize / 6] |= (1 << (5 - (bit % 6)));
|
result[bit as usize / 6] |= 1 << (5 - (bit % 6));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,11 +64,11 @@ impl DataBlock {
|
|||||||
let ecBlocks = version.getECBlocksForLevel(ecLevel);
|
let ecBlocks = version.getECBlocksForLevel(ecLevel);
|
||||||
|
|
||||||
// First count the total number of data blocks
|
// First count the total number of data blocks
|
||||||
let mut totalBlocks = 0;
|
let mut _totalBlocks = 0;
|
||||||
let ecBlockArray = ecBlocks.getECBlocks();
|
let ecBlockArray = ecBlocks.getECBlocks();
|
||||||
for ecBlock in ecBlockArray {
|
for ecBlock in ecBlockArray {
|
||||||
// for (Version.ECB ecBlock : ecBlockArray) {
|
// for (Version.ECB ecBlock : ecBlockArray) {
|
||||||
totalBlocks += ecBlock.getCount();
|
_totalBlocks += ecBlock.getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now establish DataBlocks of the appropriate size and number of data codewords
|
// Now establish DataBlocks of the appropriate size and number of data codewords
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ use super::{decoded_bit_stream_parser, BitMatrixParser, DataBlock, QRCodeDecoder
|
|||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
//rsDecoder = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256);
|
//rsDecoder = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256);
|
||||||
static ref rsDecoder : ReedSolomonDecoder = ReedSolomonDecoder::new(get_predefined_genericgf(PredefinedGenericGF::QrCodeField256));
|
static ref RS_DECODER : ReedSolomonDecoder = ReedSolomonDecoder::new(get_predefined_genericgf(PredefinedGenericGF::QrCodeField256));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decode_bool_array(image: &Vec<Vec<bool>>) -> Result<DecoderRXingResult, Exceptions> {
|
pub fn decode_bool_array(image: &Vec<Vec<bool>>) -> Result<DecoderRXingResult, Exceptions> {
|
||||||
@@ -200,7 +200,7 @@ fn correctErrors(codewordBytes: &mut [u8], numDataCodewords: usize) -> Result<()
|
|||||||
|
|
||||||
let mut sending_code_words : Vec<i32> = codewordsInts.iter().map(|x| *x as i32).collect();
|
let mut sending_code_words : Vec<i32> = codewordsInts.iter().map(|x| *x as i32).collect();
|
||||||
|
|
||||||
if let Err(e) = rsDecoder.decode(
|
if let Err(e) = RS_DECODER.decode(
|
||||||
&mut sending_code_words,
|
&mut sending_code_words,
|
||||||
(codewordBytes.len() - numDataCodewords) as i32,
|
(codewordBytes.len() - numDataCodewords) as i32,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ impl FormatInformation {
|
|||||||
if masked_format_info1 != masked_format_info2 {
|
if masked_format_info1 != masked_format_info2 {
|
||||||
// also try the other option
|
// also try the other option
|
||||||
bits_difference = Self::numBitsDiffering(masked_format_info2, targetInfo);
|
bits_difference = Self::numBitsDiffering(masked_format_info2, targetInfo);
|
||||||
if (bits_difference < best_difference) {
|
if bits_difference < best_difference {
|
||||||
best_format_info = decodeInfo[1] as u8;
|
best_format_info = decodeInfo[1] as u8;
|
||||||
best_difference = bits_difference;
|
best_difference = bits_difference;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ pub fn encode_with_hints(
|
|||||||
let encoding = if encoding.is_some() {
|
let encoding = if encoding.is_some() {
|
||||||
encoding.unwrap()
|
encoding.unwrap()
|
||||||
} else {
|
} else {
|
||||||
if let Ok(encs) = DEFAULT_BYTE_MODE_ENCODING.encode(content, encoding::EncoderTrap::Strict){
|
if let Ok(_encs) = DEFAULT_BYTE_MODE_ENCODING.encode(content, encoding::EncoderTrap::Strict){
|
||||||
DEFAULT_BYTE_MODE_ENCODING
|
DEFAULT_BYTE_MODE_ENCODING
|
||||||
}else {
|
}else {
|
||||||
has_encoding_hint = true;
|
has_encoding_hint = true;
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ pub fn embedTypeInfo(
|
|||||||
matrix: &mut ByteMatrix,
|
matrix: &mut ByteMatrix,
|
||||||
) -> Result<(), Exceptions> {
|
) -> Result<(), Exceptions> {
|
||||||
let mut typeInfoBits = BitArray::new();
|
let mut typeInfoBits = BitArray::new();
|
||||||
makeTypeInfoBits(ecLevel, maskPattern as u32, &mut typeInfoBits);
|
makeTypeInfoBits(ecLevel, maskPattern as u32, &mut typeInfoBits)?;
|
||||||
|
|
||||||
for i in 0..typeInfoBits.getSize() {
|
for i in 0..typeInfoBits.getSize() {
|
||||||
// for (int i = 0; i < typeInfoBits.getSize(); ++i) {
|
// for (int i = 0; i < typeInfoBits.getSize(); ++i) {
|
||||||
@@ -363,7 +363,7 @@ pub fn makeTypeInfoBits(
|
|||||||
|
|
||||||
let mut maskBits = BitArray::new();
|
let mut maskBits = BitArray::new();
|
||||||
maskBits.appendBits(TYPE_INFO_MASK_PATTERN, 15)?;
|
maskBits.appendBits(TYPE_INFO_MASK_PATTERN, 15)?;
|
||||||
bits.xor(&maskBits);
|
bits.xor(&maskBits)?;
|
||||||
|
|
||||||
if bits.getSize() != 15 {
|
if bits.getSize() != 15 {
|
||||||
// Just in case.
|
// Just in case.
|
||||||
|
|||||||
@@ -943,7 +943,7 @@ impl RXingResultList {
|
|||||||
*/
|
*/
|
||||||
pub fn getBits(&self, bits: &mut BitArray) -> Result<(), Exceptions> {
|
pub fn getBits(&self, bits: &mut BitArray) -> Result<(), Exceptions> {
|
||||||
for resultNode in &self.list {
|
for resultNode in &self.list {
|
||||||
resultNode.getBits(bits);
|
resultNode.getBits(bits)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1078,19 +1078,19 @@ impl RXingResultNode {
|
|||||||
* appends the bits
|
* appends the bits
|
||||||
*/
|
*/
|
||||||
fn getBits(&self, bits: &mut BitArray) -> Result<(), Exceptions> {
|
fn getBits(&self, bits: &mut BitArray) -> Result<(), Exceptions> {
|
||||||
bits.appendBits(self.mode.getBits() as u32, 4);
|
bits.appendBits(self.mode.getBits() as u32, 4)?;
|
||||||
if self.characterLength > 0 {
|
if self.characterLength > 0 {
|
||||||
let length = self.getCharacterCountIndicator();
|
let length = self.getCharacterCountIndicator();
|
||||||
bits.appendBits(
|
bits.appendBits(
|
||||||
length,
|
length,
|
||||||
self.mode.getCharacterCountBits(self.version) as usize,
|
self.mode.getCharacterCountBits(self.version) as usize,
|
||||||
);
|
)?;
|
||||||
}
|
}
|
||||||
if self.mode == Mode::ECI {
|
if self.mode == Mode::ECI {
|
||||||
bits.appendBits(
|
bits.appendBits(
|
||||||
self.encoders.getECIValue(self.charsetEncoderIndex as usize),
|
self.encoders.getECIValue(self.charsetEncoderIndex as usize),
|
||||||
8,
|
8,
|
||||||
);
|
)?;
|
||||||
} else if self.characterLength > 0 {
|
} else if self.characterLength > 0 {
|
||||||
// append data
|
// append data
|
||||||
encoder::appendBytes(
|
encoder::appendBytes(
|
||||||
@@ -1100,7 +1100,7 @@ impl RXingResultNode {
|
|||||||
self.mode,
|
self.mode,
|
||||||
bits,
|
bits,
|
||||||
self.encoders.getCharset(self.charsetEncoderIndex as usize),
|
self.encoders.getCharset(self.charsetEncoderIndex as usize),
|
||||||
);
|
)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ impl Writer for QRCodeWriter {
|
|||||||
height: i32,
|
height: i32,
|
||||||
hints: &crate::EncodingHintDictionary,
|
hints: &crate::EncodingHintDictionary,
|
||||||
) -> Result<crate::common::BitMatrix, crate::Exceptions> {
|
) -> Result<crate::common::BitMatrix, crate::Exceptions> {
|
||||||
if (contents.is_empty()) {
|
if contents.is_empty() {
|
||||||
return Err(Exceptions::IllegalArgumentException(
|
return Err(Exceptions::IllegalArgumentException(
|
||||||
"Found empty contents".to_owned(),
|
"Found empty contents".to_owned(),
|
||||||
));
|
));
|
||||||
@@ -71,7 +71,7 @@ impl Writer for QRCodeWriter {
|
|||||||
// throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format);
|
// throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width < 0 || height < 0) {
|
if width < 0 || height < 0 {
|
||||||
return Err(Exceptions::IllegalArgumentException(format!(
|
return Err(Exceptions::IllegalArgumentException(format!(
|
||||||
"Requested dimensions are too small: {}x{}",
|
"Requested dimensions are too small: {}x{}",
|
||||||
width, height
|
width, height
|
||||||
@@ -158,7 +158,7 @@ impl QRCodeWriter {
|
|||||||
outputY as u32,
|
outputY as u32,
|
||||||
multiple as u32,
|
multiple as u32,
|
||||||
multiple as u32,
|
multiple as u32,
|
||||||
);
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
inputX += 1;
|
inputX += 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user