capi: casting on 'const Paint*' instead of constness removing

This commit is contained in:
Mira Grudzinska 2021-10-26 02:02:46 +02:00 committed by Hermet Park
parent 6b7aff560f
commit 8c52f2a870

View file

@ -27,8 +27,6 @@
using namespace std;
using namespace tvg;
#define CCP(A) const_cast<Tvg_Paint*>(A) //Const-Cast-Paint
#ifdef __cplusplus
extern "C" {
#endif
@ -322,7 +320,7 @@ TVG_EXPORT Tvg_Result tvg_shape_set_stroke_width(Tvg_Paint* paint, float width)
TVG_EXPORT Tvg_Result tvg_shape_get_stroke_width(const Tvg_Paint* paint, float* width)
{
if (!paint || !width) return TVG_RESULT_INVALID_ARGUMENT;
*width = reinterpret_cast<Shape*>(CCP(paint))->strokeWidth();
*width = reinterpret_cast<const Shape*>(paint)->strokeWidth();
return TVG_RESULT_SUCCESS;
}
@ -337,7 +335,7 @@ TVG_EXPORT Tvg_Result tvg_shape_set_stroke_color(Tvg_Paint* paint, uint8_t r, ui
TVG_EXPORT Tvg_Result tvg_shape_get_stroke_color(const Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a)
{
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
return (Tvg_Result) reinterpret_cast<Shape*>(CCP(paint))->strokeColor(r, g, b, a);
return (Tvg_Result) reinterpret_cast<const Shape*>(paint)->strokeColor(r, g, b, a);
}
@ -358,7 +356,7 @@ TVG_EXPORT Tvg_Result tvg_shape_set_stroke_radial_gradient(Tvg_Paint* paint, Tvg
TVG_EXPORT Tvg_Result tvg_shape_get_stroke_gradient(const Tvg_Paint* paint, Tvg_Gradient** gradient)
{
if (!paint || !gradient) return TVG_RESULT_INVALID_ARGUMENT;
*gradient = (Tvg_Gradient*)(reinterpret_cast<Shape*>(CCP(paint))->strokeFill());
*gradient = (Tvg_Gradient*)(reinterpret_cast<const Shape*>(paint)->strokeFill());
return TVG_RESULT_SUCCESS;
}
@ -373,7 +371,7 @@ TVG_EXPORT Tvg_Result tvg_shape_set_stroke_dash(Tvg_Paint* paint, const float* d
TVG_EXPORT Tvg_Result tvg_shape_get_stroke_dash(const Tvg_Paint* paint, const float** dashPattern, uint32_t* cnt)
{
if (!paint || !cnt || !dashPattern) return TVG_RESULT_INVALID_ARGUMENT;
*cnt = reinterpret_cast<Shape*>(CCP(paint))->strokeDash(dashPattern);
*cnt = reinterpret_cast<const Shape*>(paint)->strokeDash(dashPattern);
return TVG_RESULT_SUCCESS;
}
@ -388,7 +386,7 @@ TVG_EXPORT Tvg_Result tvg_shape_set_stroke_cap(Tvg_Paint* paint, Tvg_Stroke_Cap
TVG_EXPORT Tvg_Result tvg_shape_get_stroke_cap(const Tvg_Paint* paint, Tvg_Stroke_Cap* cap)
{
if (!paint || !cap) return TVG_RESULT_INVALID_ARGUMENT;
*cap = (Tvg_Stroke_Cap) reinterpret_cast<Shape*>(CCP(paint))->strokeCap();
*cap = (Tvg_Stroke_Cap) reinterpret_cast<const Shape*>(paint)->strokeCap();
return TVG_RESULT_SUCCESS;
}
@ -403,7 +401,7 @@ TVG_EXPORT Tvg_Result tvg_shape_set_stroke_join(Tvg_Paint* paint, Tvg_Stroke_Joi
TVG_EXPORT Tvg_Result tvg_shape_get_stroke_join(const Tvg_Paint* paint, Tvg_Stroke_Join* join)
{
if (!paint || !join) return TVG_RESULT_INVALID_ARGUMENT;
*join = (Tvg_Stroke_Join) reinterpret_cast<Shape*>(CCP(paint))->strokeJoin();
*join = (Tvg_Stroke_Join) reinterpret_cast<const Shape*>(paint)->strokeJoin();
return TVG_RESULT_SUCCESS;
}
@ -418,7 +416,7 @@ TVG_EXPORT Tvg_Result tvg_shape_set_fill_color(Tvg_Paint* paint, uint8_t r, uint
TVG_EXPORT Tvg_Result tvg_shape_get_fill_color(const Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a)
{
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
return (Tvg_Result) reinterpret_cast<Shape*>(CCP(paint))->fillColor(r, g, b, a);
return (Tvg_Result) reinterpret_cast<const Shape*>(paint)->fillColor(r, g, b, a);
}
@ -432,7 +430,7 @@ TVG_EXPORT Tvg_Result tvg_shape_set_fill_rule(Tvg_Paint* paint, Tvg_Fill_Rule ru
TVG_EXPORT Tvg_Result tvg_shape_get_fill_rule(const Tvg_Paint* paint, Tvg_Fill_Rule* rule)
{
if (!paint || !rule) return TVG_RESULT_INVALID_ARGUMENT;
*rule = (Tvg_Fill_Rule) reinterpret_cast<Shape*>(CCP(paint))->fillRule();
*rule = (Tvg_Fill_Rule) reinterpret_cast<const Shape*>(paint)->fillRule();
return TVG_RESULT_SUCCESS;
}
@ -454,7 +452,7 @@ TVG_EXPORT Tvg_Result tvg_shape_set_radial_gradient(Tvg_Paint* paint, Tvg_Gradie
TVG_EXPORT Tvg_Result tvg_shape_get_gradient(const Tvg_Paint* paint, Tvg_Gradient** gradient)
{
if (!paint || !gradient) return TVG_RESULT_INVALID_ARGUMENT;
*gradient = (Tvg_Gradient*)(reinterpret_cast<Shape*>(CCP(paint))->fill());
*gradient = (Tvg_Gradient*)(reinterpret_cast<const Shape*>(paint)->fill());
return TVG_RESULT_SUCCESS;
}
@ -492,21 +490,21 @@ TVG_EXPORT Tvg_Result tvg_picture_load_data(Tvg_Paint* paint, const char *data,
TVG_EXPORT Tvg_Result tvg_picture_set_size(Tvg_Paint* paint, float w, float h)
{
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
return (Tvg_Result) reinterpret_cast<Picture*>(CCP(paint))->size(w, h);
return (Tvg_Result) reinterpret_cast<Picture*>(paint)->size(w, h);
}
TVG_EXPORT Tvg_Result tvg_picture_get_size(const Tvg_Paint* paint, float* w, float* h)
{
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
return (Tvg_Result) reinterpret_cast<Picture*>(CCP(paint))->size(w, h);
return (Tvg_Result) reinterpret_cast<const Picture*>(paint)->size(w, h);
}
TVG_EXPORT Tvg_Result tvg_picture_get_viewbox(const Tvg_Paint* paint, float* x, float* y, float* w, float* h)
{
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
return (Tvg_Result) reinterpret_cast<Picture*>(CCP(paint))->viewbox(x, y, w, h);
return (Tvg_Result) reinterpret_cast<const Picture*>(paint)->viewbox(x, y, w, h);
}