Skip to content

Commit

Permalink
Merge pull request #125 from burtonageo/master
Browse files Browse the repository at this point in the history
Replaced all fail! macros with panic! macros
  • Loading branch information
emberian committed Oct 30, 2014
2 parents 1e1d71c + c97a561 commit 7474f4f
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/dynimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl DynamicImage {
pub fn filter3x3(&self, kernel: &[f32]) -> DynamicImage {
if kernel.len() != 9 {
//return self.clone()
fail!("filter must be 3 x 3")
panic!("filter must be 3 x 3")
}

dynamic_map!(*self, ref p => imageops::filter3x3(p, kernel))
Expand Down
2 changes: 1 addition & 1 deletion src/jpeg/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl<W: Writer> JPEGEncoder<W> {
let (size, code) = table[val as uint];

if size > 16 {
fail!("bad huffman value");
panic!("bad huffman value");
}

self.write_bits(code, size)
Expand Down
12 changes: 6 additions & 6 deletions src/png/deflate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl TableElement {
pub fn put(&mut self, index: u16, elem: TableElement) {
match *self {
Table(_, ref mut a) => a.as_mut_slice()[index as uint] = elem,
_ => fail!("requires Table()"),
_ => panic!("requires Table()"),
}
}
}
Expand Down Expand Up @@ -123,7 +123,7 @@ impl<R: Reader> Inflater<R> {
let _ = try!(self.read_dynamic_tables());
self.btype = Compressed;
}
_ => fail!("reserved block type")
_ => panic!("reserved block type")
}

Ok(())
Expand Down Expand Up @@ -169,7 +169,7 @@ impl<R: Reader> Inflater<R> {

18 => i += 11 + try!(self.h.receive(7)),

_ => fail!("out of range code length code symbol")
_ => panic!("out of range code length code symbol")
}
}

Expand Down Expand Up @@ -249,7 +249,7 @@ impl<R: Reader> Inflater<R> {
}
}

_ => fail!("out of range symbol")
_ => panic!("out of range symbol")
}
}

Expand Down Expand Up @@ -413,11 +413,11 @@ impl<R: Reader> HuffReader<R> {

match a[index as uint] {
Symbol(val, size) => (val, size + TABLESIZE),
_ => fail!("bad huffman code")
_ => panic!("bad huffman code")
}
}

Nothing => fail!("bad huffman code")
Nothing => panic!("bad huffman code")
};

if size <= self.num_bits {
Expand Down
4 changes: 2 additions & 2 deletions src/png/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn build_ihdr(width: u32, height: u32, c: color::ColorType) -> (Vec<u8>, uint) {
color::GreyA(16) => (4, 16),
color::RGBA(8) => (6, 8),
color::RGBA(16) => (6, 16),
_ => fail!("unsupported color type and bitdepth")
_ => panic!("unsupported color type and bitdepth")
};

let _ = m.write_u8(bit_depth);
Expand All @@ -114,7 +114,7 @@ fn build_ihdr(width: u32, height: u32, c: color::ColorType) -> (Vec<u8>, uint) {
3 => 3,
4 => 2,
6 => 4,
_ => fail!("unknown colour type")
_ => panic!("unknown colour type")
};

let bpp = ((channels * bit_depth + 7) / 8) as uint;
Expand Down
2 changes: 1 addition & 1 deletion src/png/zlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<R: Reader> ZlibDecoder<R> {
let fdict = (flg & 0b100000) != 0;
if fdict {
let _dictid = try!(self.inner().read_be_u32());
fail!("invalid png: zlib detected fdict true")
panic!("invalid png: zlib detected fdict true")
}

assert!((cmf as u16 * 256 + flg as u16) % 31 == 0);
Expand Down
2 changes: 1 addition & 1 deletion src/ppm/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<W: Writer> PPMEncoder<W> {
}
}

a => fail!(format!("not implemented: {}", a))
a => panic!(format!("not implemented: {}", a))
}

Ok(())
Expand Down
14 changes: 7 additions & 7 deletions src/webp/vp8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ impl<R: Reader> VP8Decoder<R> {

if !self.frame.keyframe {
//9.7 refresh golden frame and altref frame
fail!("unimplemented")
panic!("unimplemented")
} else {
//Refresh entropy probs ?????
let _ = self.b.read_literal(1);
Expand All @@ -1100,7 +1100,7 @@ impl<R: Reader> VP8Decoder<R> {
//9.10 remaining frame data
self.prob_intra = 0;

fail!("unimplemented")
panic!("unimplemented")
} else {
//Reset motion vectors
}
Expand Down Expand Up @@ -1130,7 +1130,7 @@ impl<R: Reader> VP8Decoder<R> {
};

if inter_predicted {
fail!("inter prediction not implemented");
panic!("inter prediction not implemented");
}

if self.frame.keyframe {
Expand Down Expand Up @@ -1158,7 +1158,7 @@ impl<R: Reader> VP8Decoder<R> {
V_PRED => B_VE_PRED,
H_PRED => B_HE_PRED,
TM_PRED => B_TM_PRED,
_ => fail!("unreachable")
_ => panic!("unreachable")
};

mb.bpred[12 + i] = mode;
Expand Down Expand Up @@ -1190,7 +1190,7 @@ impl<R: Reader> VP8Decoder<R> {
TM_PRED => predict_tmpred(ws, 16, 1, 1, stride),
DC_PRED => predict_dcpred(ws, 16, stride, mby != 0, mbx != 0),
B_PRED => predict_4x4(ws, stride, mb.bpred, resdata),
_ => fail!("unknown luma intra prediction mode")
_ => panic!("unknown luma intra prediction mode")
}

if mb.luma_mode != B_PRED {
Expand Down Expand Up @@ -1280,7 +1280,7 @@ impl<R: Reader> VP8Decoder<R> {
DCT_CAT_BASE[(category - DCT_CAT1) as uint] as i16 + extra
}

c => fail!(format!("unknown token: {}", c))
c => panic!(format!("unknown token: {}", c))
} as i32;

skip = false;
Expand Down Expand Up @@ -1534,7 +1534,7 @@ fn predict_4x4(ws: &mut [u8], stride: uint, modes: &[i8], resdata: &[i32]) {
B_VL_PRED => predict_bvlpred(ws, x0, y0, stride),
B_HD_PRED => predict_bhdpred(ws, x0, y0, stride),
B_HU_PRED => predict_bhupred(ws, x0, y0, stride),
_ => fail!("unknown intra bmode"),
_ => panic!("unknown intra bmode"),
}

add_residue(ws, rb, y0, x0, stride);
Expand Down

0 comments on commit 7474f4f

Please sign in to comment.