Panic when invalid arguments are passed to the C API.
Closes
@@ -304,18 +304,20 @@ pub unsafe extern "C" fn PFCanvasSetLineWidth(canvas: PFCanvasRef, new_line_widt
#[no_mangle]
pub unsafe extern "C" fn PFCanvasSetLineCap(canvas: PFCanvasRef, new_line_cap: PFLineCap) {
(*canvas).set_line_cap(match new_line_cap {
+ PF_LINE_CAP_BUTT => LineCap::Butt,
PF_LINE_CAP_SQUARE => LineCap::Square,
PF_LINE_CAP_ROUND => LineCap::Round,
- _ => LineCap::Butt,
+ _ => panic!("Invalid Pathfinder line cap style!"),
});
}
#[no_mangle]
pub unsafe extern "C" fn PFCanvasSetLineJoin(canvas: PFCanvasRef, new_line_join: PFLineJoin) {
(*canvas).set_line_join(match new_line_join {
+ PF_LINE_JOIN_MITER => LineJoin::Miter,
PF_LINE_JOIN_BEVEL => LineJoin::Bevel,
PF_LINE_JOIN_ROUND => LineJoin::Round,
- _ => LineJoin::Miter,
+ _ => panic!("Invalid Pathfinder line join style!"),
});
}
@@ -453,7 +455,11 @@ pub unsafe extern "C" fn PFPathArc(path: PFPathRef,
start_angle: f32,
end_angle: f32,
direction: PFArcDirection) {
- let direction = if direction == 0 { ArcDirection::CW } else { ArcDirection::CCW };
+ let direction = match direction {
+ PF_ARC_DIRECTION_CW => ArcDirection::CW,
+ PF_ARC_DIRECTION_CCW => ArcDirection::CCW,
+ _ => panic!("Invalid Pathfinder arc direction!"),
+ };
(*path).arc((*center).to_rust(), radius, start_angle, end_angle, direction)
}
@@ -859,6 +865,7 @@ impl PFRendererOptions {
fn to_rust_renderer_level(level: PFRendererLevel) -> RendererLevel {
match level {
PF_RENDERER_LEVEL_D3D9 => RendererLevel::D3D9,
- _ => RendererLevel::D3D11,
+ PF_RENDERER_LEVEL_D3D11 => RendererLevel::D3D11,
+ _ => panic!("Invalid Pathfinder renderer level!"),
}
}
