Various compiler warning fixes

This commit is contained in:
rdb 2018-06-12 11:09:26 +02:00
parent fa23c199ec
commit b88bd99704
22 changed files with 55 additions and 55 deletions

View File

@ -103,11 +103,6 @@ RenameSet methodRenameDictionary[] = {
{ nullptr, nullptr, -1 } { nullptr, nullptr, -1 }
}; };
RenameSet classRenameDictionary[] = {
// No longer used, now empty.
{ nullptr, nullptr, -1 }
};
const char *pythonKeywords[] = { const char *pythonKeywords[] = {
"and", "and",
"as", "as",
@ -193,12 +188,6 @@ classNameFromCppName(const std::string &cppName, bool mangle) {
} }
} }
for (int x = 0; classRenameDictionary[x]._from != nullptr; x++) {
if (cppName == classRenameDictionary[x]._from) {
className = classRenameDictionary[x]._to;
}
}
if (className.empty()) { if (className.empty()) {
std::string text = "** ERROR ** Renaming class: " + cppName + " to empty string"; std::string text = "** ERROR ** Renaming class: " + cppName + " to empty string";
printf("%s", text.c_str()); printf("%s", text.c_str());
@ -253,15 +242,6 @@ methodNameFromCppName(const std::string &cppName, const std::string &className,
} }
} }
if (className.size() > 0) {
string lookup_name = className + '.' + cppName;
for (int x = 0; classRenameDictionary[x]._from != nullptr; x++) {
if (lookup_name == methodRenameDictionary[x]._from) {
methodName = methodRenameDictionary[x]._to;
}
}
}
// # Mangle names that happen to be python keywords so they are not anymore // # Mangle names that happen to be python keywords so they are not anymore
methodName = checkKeyword(methodName); methodName = checkKeyword(methodName);
return methodName; return methodName;

View File

@ -34,6 +34,7 @@ PUBLISHED:
explicit CharacterSlider(PartGroup *parent, const std::string &name); explicit CharacterSlider(PartGroup *parent, const std::string &name);
virtual ~CharacterSlider(); virtual ~CharacterSlider();
public:
virtual PartGroup *make_copy() const; virtual PartGroup *make_copy() const;
virtual bool update_internals(PartBundle *root, PartGroup *parent, virtual bool update_internals(PartBundle *root, PartGroup *parent,

View File

@ -33,7 +33,7 @@
* This class exists for name scoping only. Don't use the constructor * This class exists for name scoping only. Don't use the constructor
* directly; use one of the make_* methods. * directly; use one of the make_* methods.
*/ */
class EXPCL_PANDA_DISPLAY NativeWindowHandle : public WindowHandle { class EXPCL_PANDA_DISPLAY NativeWindowHandle final : public WindowHandle {
private: private:
INLINE NativeWindowHandle(); INLINE NativeWindowHandle();
INLINE NativeWindowHandle(const NativeWindowHandle &copy); INLINE NativeWindowHandle(const NativeWindowHandle &copy);

View File

@ -57,7 +57,7 @@ get_shading() const {
if (!first_component->has_normal()) { if (!first_component->has_normal()) {
first_component = this; first_component = this;
} }
for (int i = 1; i < get_num_components(); i++) { for (size_t i = 1; i < get_num_components(); ++i) {
const EggAttributes *component = get_component(i); const EggAttributes *component = get_component(i);
if (!component->has_normal()) { if (!component->has_normal()) {
component = this; component = this;
@ -74,7 +74,7 @@ get_shading() const {
if (!first_component->has_color()) { if (!first_component->has_color()) {
first_component = this; first_component = this;
} }
for (int i = 1; i < get_num_components(); i++) { for (size_t i = 1; i < get_num_components(); ++i) {
const EggAttributes *component = get_component(i); const EggAttributes *component = get_component(i);
if (!component->has_color()) { if (!component->has_color()) {
component = this; component = this;
@ -295,7 +295,7 @@ apply_last_attribute() {
// The first component gets applied to the third vertex, and so on from // The first component gets applied to the third vertex, and so on from
// there. // there.
int num_lead_vertices = get_num_lead_vertices(); int num_lead_vertices = get_num_lead_vertices();
for (int i = 0; i < get_num_components(); i++) { for (size_t i = 0; i < get_num_components(); ++i) {
EggAttributes *component = get_component(i); EggAttributes *component = get_component(i);
do_apply_flat_attribute(i + num_lead_vertices, component); do_apply_flat_attribute(i + num_lead_vertices, component);
} }
@ -313,7 +313,7 @@ void EggCompositePrimitive::
apply_first_attribute() { apply_first_attribute() {
// The first component gets applied to the first vertex, and so on from // The first component gets applied to the first vertex, and so on from
// there. // there.
for (int i = 0; i < get_num_components(); i++) { for (size_t i = 0; i < get_num_components(); ++i) {
EggAttributes *component = get_component(i); EggAttributes *component = get_component(i);
do_apply_flat_attribute(i, component); do_apply_flat_attribute(i, component);
} }

View File

@ -227,7 +227,7 @@ get_shading() const {
if (!first_vertex->has_normal()) { if (!first_vertex->has_normal()) {
first_vertex = this; first_vertex = this;
} }
for (int i = 1; i < get_num_vertices(); i++) { for (size_t i = 1; i < get_num_vertices(); ++i) {
const EggAttributes *vertex = get_vertex(i); const EggAttributes *vertex = get_vertex(i);
if (!vertex->has_normal()) { if (!vertex->has_normal()) {
vertex = this; vertex = this;
@ -244,7 +244,7 @@ get_shading() const {
if (!first_vertex->has_color()) { if (!first_vertex->has_color()) {
first_vertex = this; first_vertex = this;
} }
for (int i = 1; i < get_num_vertices(); i++) { for (size_t i = 1; i < get_num_vertices(); ++i) {
const EggAttributes *vertex = get_vertex(i); const EggAttributes *vertex = get_vertex(i);
if (!vertex->has_color()) { if (!vertex->has_color()) {
vertex = this; vertex = this;
@ -461,9 +461,7 @@ apply_first_attribute() {
void EggPrimitive:: void EggPrimitive::
post_apply_flat_attribute() { post_apply_flat_attribute() {
if (!empty()) { if (!empty()) {
for (int i = 0; i < (int)size(); i++) { for (EggVertex *vertex : _vertices) {
EggVertex *vertex = get_vertex(i);
// Use set_normal() instead of copy_normal(), to avoid getting the // Use set_normal() instead of copy_normal(), to avoid getting the
// morphs--we don't want them here, since we're just putting a bogus // morphs--we don't want them here, since we're just putting a bogus
// value on the normal anyway. // value on the normal anyway.

View File

@ -57,7 +57,7 @@ apply_first_attribute() {
// In the case of a triangle fan, the first vertex of the fan is the common // In the case of a triangle fan, the first vertex of the fan is the common
// vertex, so we consider the second vertex to be the key vertex of the // vertex, so we consider the second vertex to be the key vertex of the
// first triangle, and move from there. // first triangle, and move from there.
for (int i = 0; i < get_num_components(); i++) { for (size_t i = 0; i < get_num_components(); ++i) {
EggAttributes *component = get_component(i); EggAttributes *component = get_component(i);
do_apply_flat_attribute(i + 1, component); do_apply_flat_attribute(i + 1, component);
} }

View File

@ -560,7 +560,7 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path,
// Get an arbitrary vector on the plane by taking the cross product // Get an arbitrary vector on the plane by taking the cross product
// with any vector, as long as it is different. // with any vector, as long as it is different.
LVector3 vec1; LVector3 vec1;
if (abs(normal[2]) > abs(normal[1])) { if (std::fabs(normal[2]) > std::fabs(normal[1])) {
vec1 = normal.cross(LVector3(0, 1, 0)); vec1 = normal.cross(LVector3(0, 1, 0));
} else { } else {
vec1 = normal.cross(LVector3(0, 0, 1)); vec1 = normal.cross(LVector3(0, 0, 1));
@ -626,7 +626,7 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path,
// Also get an arbitrary vector perpendicular to the tube. // Also get an arbitrary vector perpendicular to the tube.
LVector3 axis = point_b - point_a; LVector3 axis = point_b - point_a;
LVector3 sideways; LVector3 sideways;
if (abs(axis[2]) > abs(axis[1])) { if (std::fabs(axis[2]) > std::fabs(axis[1])) {
sideways = axis.cross(LVector3(0, 1, 0)); sideways = axis.cross(LVector3(0, 1, 0));
} else { } else {
sideways = axis.cross(LVector3(0, 0, 1)); sideways = axis.cross(LVector3(0, 0, 1));

View File

@ -34,7 +34,7 @@ get_repeat_count() const {
* Returns the index of the task within the sequence that is currently being * Returns the index of the task within the sequence that is currently being
* executed (or that will be executed at the next epoch). * executed (or that will be executed at the next epoch).
*/ */
INLINE int AsyncTaskSequence:: INLINE size_t AsyncTaskSequence::
get_current_task_index() const { get_current_task_index() const {
return _task_index; return _task_index;
} }

View File

@ -39,7 +39,7 @@ PUBLISHED:
INLINE void set_repeat_count(int repeat_count); INLINE void set_repeat_count(int repeat_count);
INLINE int get_repeat_count() const; INLINE int get_repeat_count() const;
INLINE int get_current_task_index() const; INLINE size_t get_current_task_index() const;
protected: protected:
virtual bool is_runnable(); virtual bool is_runnable();
@ -51,7 +51,7 @@ private:
void set_current_task(AsyncTask *task, bool clean_exit); void set_current_task(AsyncTask *task, bool clean_exit);
int _repeat_count; int _repeat_count;
int _task_index; size_t _task_index;
PT(AsyncTask) _current_task; PT(AsyncTask) _current_task;
public: public:

View File

@ -3007,7 +3007,7 @@ reset() {
#ifndef OPENGLES_1 #ifndef OPENGLES_1
_enabled_vertex_attrib_arrays.clear(); _enabled_vertex_attrib_arrays.clear();
memset(_vertex_attrib_divisors, 0, sizeof(GLint) * 32); memset(_vertex_attrib_divisors, 0, sizeof(GLuint) * 32);
#endif #endif
// Dither is on by default in GL; let's turn it off // Dither is on by default in GL; let's turn it off

View File

@ -661,7 +661,7 @@ protected:
#ifndef OPENGLES_1 #ifndef OPENGLES_1
BitMask32 _enabled_vertex_attrib_arrays; BitMask32 _enabled_vertex_attrib_arrays;
GLint _vertex_attrib_divisors[32]; GLuint _vertex_attrib_divisors[32];
PT(Shader) _current_shader; PT(Shader) _current_shader;
ShaderContext *_current_shader_context; ShaderContext *_current_shader_context;

View File

@ -374,7 +374,7 @@ void MeshDrawer::geometry(NodePath draw_node) {
CPT(GeomVertexData) v_data = geom->get_vertex_data(); CPT(GeomVertexData) v_data = geom->get_vertex_data();
GeomVertexReader *prim_vertex_reader = new GeomVertexReader(v_data, "vertex"); GeomVertexReader *prim_vertex_reader = new GeomVertexReader(v_data, "vertex");
GeomVertexReader *prim_uv_reader = new GeomVertexReader(v_data, "texcoord"); GeomVertexReader *prim_uv_reader = new GeomVertexReader(v_data, "texcoord");
for(int k=0; k <geom->get_num_primitives(); k++) { for (size_t k = 0; k < geom->get_num_primitives(); ++k) {
CPT(GeomPrimitive) prim1 = geom->get_primitive(k); CPT(GeomPrimitive) prim1 = geom->get_primitive(k);
CPT(GeomPrimitive) _prim = prim1->decompose(); CPT(GeomPrimitive) _prim = prim1->decompose();

View File

@ -288,6 +288,17 @@ do_load_one(Texture::CData *cdata_tex,
return false; return false;
} }
/**
* Loading a static image into a MovieTexture is an error.
*/
bool MovieTexture::
do_load_one(Texture::CData *cdata_tex,
const PfmFile &pfm, const std::string &name, int z, int n,
const LoaderOptions &options) {
grutil_cat.error() << "You cannot load a static image into a MovieTexture\n";
return false;
}
/** /**
* Called internally by do_reconsider_z_size() to allocate new memory in * Called internally by do_reconsider_z_size() to allocate new memory in
* _ram_images[0] for the new number of pages. * _ram_images[0] for the new number of pages.

View File

@ -102,6 +102,9 @@ protected:
virtual bool do_load_one(Texture::CData *cdata, virtual bool do_load_one(Texture::CData *cdata,
const PNMImage &pnmimage, const std::string &name, const PNMImage &pnmimage, const std::string &name,
int z, int n, const LoaderOptions &options); int z, int n, const LoaderOptions &options);
virtual bool do_load_one(Texture::CData *cdata,
const PfmFile &pfm, const std::string &name,
int z, int n, const LoaderOptions &options);
bool do_load_one(Texture::CData *cdata, bool do_load_one(Texture::CData *cdata,
PT(MovieVideoCursor) color, PT(MovieVideoCursor) alpha, PT(MovieVideoCursor) color, PT(MovieVideoCursor) alpha,
int z, const LoaderOptions &options); int z, const LoaderOptions &options);

View File

@ -328,7 +328,9 @@ static drflac* drflac_open_memory(const void* data, size_t dataSize);
#endif #endif
#ifdef __linux__ #ifdef __linux__
#ifndef _BSD_SOURCE
#define _BSD_SOURCE #define _BSD_SOURCE
#endif
#include <endian.h> #include <endian.h>
#endif #endif

View File

@ -1242,7 +1242,7 @@ apply_collect_changes() {
*/ */
void GeomTransformer::NewCollectedData:: void GeomTransformer::NewCollectedData::
append_vdata(const GeomVertexData *vdata, int vertex_offset) { append_vdata(const GeomVertexData *vdata, int vertex_offset) {
for (int i = 0; i < vdata->get_num_arrays(); ++i) { for (size_t i = 0; i < vdata->get_num_arrays(); ++i) {
PT(GeomVertexArrayDataHandle) new_handle = _new_data->modify_array_handle(i); PT(GeomVertexArrayDataHandle) new_handle = _new_data->modify_array_handle(i);
CPT(GeomVertexArrayDataHandle) old_handle = vdata->get_array_handle(i); CPT(GeomVertexArrayDataHandle) old_handle = vdata->get_array_handle(i);
size_t stride = (size_t)_new_format->get_array(i)->get_stride(); size_t stride = (size_t)_new_format->get_array(i)->get_stride();

View File

@ -188,8 +188,8 @@ get_path(int index) const {
* get_path(), but it may be a more convenient way to access it. * get_path(), but it may be a more convenient way to access it.
*/ */
NodePath NodePathCollection:: NodePath NodePathCollection::
operator [] (int index) const { operator [] (size_t index) const {
nassertr(index >= 0 && index < (int)_node_paths.size(), NodePath()); nassertr(index < _node_paths.size(), NodePath());
return _node_paths[index]; return _node_paths[index];
} }
@ -198,7 +198,7 @@ operator [] (int index) const {
* Returns the number of paths in the collection. This is the same thing as * Returns the number of paths in the collection. This is the same thing as
* get_num_paths(). * get_num_paths().
*/ */
int NodePathCollection:: size_t NodePathCollection::
size() const { size() const {
return _node_paths.size(); return _node_paths.size();
} }

View File

@ -45,8 +45,8 @@ PUBLISHED:
int get_num_paths() const; int get_num_paths() const;
NodePath get_path(int index) const; NodePath get_path(int index) const;
MAKE_SEQ(get_paths, get_num_paths, get_path); MAKE_SEQ(get_paths, get_num_paths, get_path);
NodePath operator [] (int index) const; NodePath operator [] (size_t index) const;
int size() const; size_t size() const;
INLINE void operator += (const NodePathCollection &other); INLINE void operator += (const NodePathCollection &other);
INLINE NodePathCollection operator + (const NodePathCollection &other) const; INLINE NodePathCollection operator + (const NodePathCollection &other) const;

View File

@ -404,6 +404,9 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) {
info._flags |= ShaderKey::TF_uses_last_saved_result; info._flags |= ShaderKey::TF_uses_last_saved_result;
} }
break; break;
default:
break;
} }
// In fact, perhaps this stage should be disabled altogether? // In fact, perhaps this stage should be disabled altogether?
@ -438,6 +441,8 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) {
skip = true; skip = true;
} }
break; break;
default:
break;
} }
// We can't just drop a disabled slot from the list, since then the // We can't just drop a disabled slot from the list, since then the
// indices for the texture stages will no longer match up. So we keep it, // indices for the texture stages will no longer match up. So we keep it,

View File

@ -2381,7 +2381,7 @@ assign_append_to(GeomCollectorMap &geom_collector_map,
PT(Geom) geom = _glyph->get_geom(GeomEnums::UH_static); PT(Geom) geom = _glyph->get_geom(GeomEnums::UH_static);
int p, sp, s, e, i; int sp, s, e, i;
const GeomVertexData *vdata = geom->get_vertex_data(); const GeomVertexData *vdata = geom->get_vertex_data();
CPT(RenderState) rs = _glyph->get_state()->compose(state); CPT(RenderState) rs = _glyph->get_state()->compose(state);
@ -2398,7 +2398,7 @@ assign_append_to(GeomCollectorMap &geom_collector_map,
// that we don't needlessly duplicate vertices into our output vertex data. // that we don't needlessly duplicate vertices into our output vertex data.
VertexIndexMap vimap; VertexIndexMap vimap;
for (p = 0; p < geom->get_num_primitives(); p++) { for (size_t p = 0; p < geom->get_num_primitives(); ++p) {
CPT(GeomPrimitive) primitive = geom->get_primitive(p)->decompose(); CPT(GeomPrimitive) primitive = geom->get_primitive(p)->decompose();
// Get a new GeomPrimitive of the corresponding type. // Get a new GeomPrimitive of the corresponding type.

View File

@ -14,7 +14,7 @@
int error, derror; int error, derror;
int x1, dxdy_min, dxdy_max; int x1, dxdy_min, dxdy_max;
/* warning: x2 is multiplied by 2^16 */ /* warning: x2 is multiplied by 2^16 */
int x2, dx2dy2; UNUSED int x2, dx2dy2;
#ifdef INTERP_Z #ifdef INTERP_Z
int z1 = 0, dzdx = 0, dzdy = 0, dzdl_min = 0, dzdl_max = 0; int z1 = 0, dzdx = 0, dzdy = 0, dzdl_min = 0, dzdl_max = 0;

View File

@ -32,7 +32,7 @@ FNAME(flat_untextured) (ZBuffer *zb,
ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
{ {
UNUSED int color; UNUSED int color;
int or0, og0, ob0, oa0; UNUSED int or0, og0, ob0, oa0;
#define INTERP_Z #define INTERP_Z
@ -160,7 +160,7 @@ FNAME(flat_textured) (ZBuffer *zb,
ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
{ {
ZTextureDef *texture_def; ZTextureDef *texture_def;
int or0, og0, ob0, oa0; UNUSED int or0, og0, ob0, oa0;
#define INTERP_Z #define INTERP_Z
#define INTERP_ST #define INTERP_ST
@ -399,7 +399,7 @@ FNAME(flat_perspective) (ZBuffer *zb,
{ {
ZTextureDef *texture_def; ZTextureDef *texture_def;
PN_stdfloat fdzdx,fndzdx,ndszdx,ndtzdx; PN_stdfloat fdzdx,fndzdx,ndszdx,ndtzdx;
int or0, og0, ob0, oa0; UNUSED int or0, og0, ob0, oa0;
#define INTERP_Z #define INTERP_Z
#define INTERP_STZ #define INTERP_STZ
@ -456,7 +456,7 @@ FNAME(flat_perspective) (ZBuffer *zb,
PIXEL *pp; \ PIXEL *pp; \
int s,t,z,zz; \ int s,t,z,zz; \
int n,dsdx,dtdx; \ int n,dsdx,dtdx; \
int or1,og1,ob1,oa1; \ UNUSED int or1,og1,ob1,oa1; \
PN_stdfloat sz,tz,fz,zinv; \ PN_stdfloat sz,tz,fz,zinv; \
n=(x2>>16)-x1; \ n=(x2>>16)-x1; \
fz=(PN_stdfloat)z1; \ fz=(PN_stdfloat)z1; \
@ -596,7 +596,7 @@ FNAME(smooth_perspective) (ZBuffer *zb,
PIXEL *pp; \ PIXEL *pp; \
int s,t,z,zz; \ int s,t,z,zz; \
int n,dsdx,dtdx; \ int n,dsdx,dtdx; \
int or1,og1,ob1,oa1; \ UNUSED int or1,og1,ob1,oa1; \
PN_stdfloat sz,tz,fz,zinv; \ PN_stdfloat sz,tz,fz,zinv; \
n=(x2>>16)-x1; \ n=(x2>>16)-x1; \
fz=(PN_stdfloat)z1; \ fz=(PN_stdfloat)z1; \
@ -727,7 +727,7 @@ FNAME(smooth_multitex2) (ZBuffer *zb,
PIXEL *pp; \ PIXEL *pp; \
int s,t,sa,ta,z,zz; \ int s,t,sa,ta,z,zz; \
int n,dsdx,dtdx,dsadx,dtadx; \ int n,dsdx,dtdx,dsadx,dtadx; \
int or1,og1,ob1,oa1; \ UNUSED int or1,og1,ob1,oa1; \
PN_stdfloat sz,tz,sza,tza,fz,zinv; \ PN_stdfloat sz,tz,sza,tza,fz,zinv; \
n=(x2>>16)-x1; \ n=(x2>>16)-x1; \
fz=(PN_stdfloat)z1; \ fz=(PN_stdfloat)z1; \
@ -888,7 +888,7 @@ FNAME(smooth_multitex3) (ZBuffer *zb,
PIXEL *pp; \ PIXEL *pp; \
int s,t,sa,ta,sb,tb,z,zz; \ int s,t,sa,ta,sb,tb,z,zz; \
int n,dsdx,dtdx,dsadx,dtadx,dsbdx,dtbdx; \ int n,dsdx,dtdx,dsadx,dtadx,dsbdx,dtbdx; \
int or1,og1,ob1,oa1; \ UNUSED int or1,og1,ob1,oa1; \
PN_stdfloat sz,tz,sza,tza,szb,tzb,fz,zinv; \ PN_stdfloat sz,tz,sza,tza,szb,tzb,fz,zinv; \
n=(x2>>16)-x1; \ n=(x2>>16)-x1; \
fz=(PN_stdfloat)z1; \ fz=(PN_stdfloat)z1; \