Fix some C++ warnings - #10383
Fix some C++ warnings#10383
Conversation
There was a problem hiding this comment.
just change the signature of convert_bool to int convert_bool(PyObject *obj, bool *p)?
There was a problem hiding this comment.
All of the convert functions use void*.
There was a problem hiding this comment.
not convinced that they should but I guess that's another project...
| goto exit; | ||
| } | ||
| should_simplify = PyObject_IsTrue(should_simplify_obj); | ||
| should_simplify = PyObject_IsTrue(should_simplify_obj) != 0; |
There was a problem hiding this comment.
perhaps use convert_bool? dunno
| offset_trans, | ||
| facecolors, | ||
| antialiased, | ||
| antialiased != 0, |
There was a problem hiding this comment.
wouldn't it be simpler (throughout) to make antialiased a bool?
|
|
||
| transformed_path_t tpath(path, trans); | ||
| nan_removed_t nan_removed(tpath, true, has_curves); | ||
| nan_removed_t nan_removed(tpath, true, has_curves != 0); |
| case Edge_N: return BOUNDARY_N(quad_edge.quad); | ||
| case Edge_W: return BOUNDARY_W(quad_edge.quad); | ||
| case Edge_S: return BOUNDARY_S(quad_edge.quad); | ||
| case Edge_E: return BOUNDARY_E(quad_edge.quad) != 0; |
There was a problem hiding this comment.
modify the macro accordingly?
(same comment applies more or less throughout)
| "norm : float, optional\n" | ||
| " The norm for the interpolation function. Default is 0.\n\n" | ||
| "norm : bool, optional\n" | ||
| " Whether to norm the interpolation function. Default is 0.\n\n" |
anntzer
left a comment
There was a problem hiding this comment.
few more comments left to be addressed (make macros return bools, etc) but already an improvement.
cd50cd3 to
fa5e2a3
Compare
|
Test failure doesn't look spurious. |
|
It is; that one fails sporadically due to some filename re-use. I've been meaning to look into it... |
|
Do we want to hold off on this until we get a 2.2 rc tagged? |
|
I don't think it needs to wait--but your asking gives me pause on clicking the button now... |
|
BTW, in Python 3.3, |
|
btw do you really have a warning on implicitly casting a number to a bool? (dunno, just asking) |
|
Can merge now? |
| ext = make_extension('matplotlib.ft2font', sources) | ||
| FreeType().add_flags(ext) | ||
| Numpy().add_flags(ext) | ||
| LibAgg().add_flags(ext) |
There was a problem hiding this comment.
so libagg became a "dep" of ft2font via py_converters? probably not a big deal but yuck... now that we're py3 only we may as well use the p converter flag instead of convert_bool, if that avoids the additional internal dep.
There was a problem hiding this comment.
py_converters has Agg stuff in it so includes its headers, and then we need to add its flags... I think I can split them up so that this isn't necessary.
Using p will still produce an int which caused the warnings on AppVeyor.
There was a problem hiding this comment.
Though maybe I'd wait for #10426 so I don't have to worry about the old backends.
There was a problem hiding this comment.
but we can just do the cast of the result of p ourselves?
I don't want to force you to overengineer this, the addition of agg as a dependency only somewhat annoys me.
There was a problem hiding this comment.
But then we'd need all the != 0 that you didn't like, no? Because MSVC didn't like (bool)var either...
There was a problem hiding this comment.
if an explicit typecast triggers a warning that seems a bit too much but can't do anything about it :/ I guess that sort of forces towards using != 0 (or !!x) then...
There was a problem hiding this comment.
If it helps you feel a little better, I also stopped it adding Agg sources to these extensions, which was unnecessary.
This prevents a bunch of repeated warnings since these headers are included multiple times.
This prevents a warning casting from double to float if the variable is not double.
It only accepts a boolean on the Python side, but this is not enforced on the C++ side. This causes many casting warnings since it's used multiple times calling various filters that only take a `bool`.
No need to cast the int before dividing, because the divisor is a double. It is necessary to cast the entire expression though, since the storage variable is only a float.
This helps fix up some bool warnings.
|
Rebased and tweaked setup a little so Agg sources don't get built into the new ones. |

PR Summary
This fixes various minor type conversion and other casting warnings. It is not completely clean now, but saves about 100 lines of warnings in every AppVeyor build.
PR Checklist