Fix error and warnings in 32-bit Windows build

This commit is contained in:
rdb 2015-11-01 16:57:52 +01:00
parent b0d8b9109e
commit da17cce447
15 changed files with 44 additions and 48 deletions

View File

@ -177,7 +177,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst,
bool any_changed = false;
for (int i = 0; i < _elements.size(); ++i) {
for (size_t i = 0; i < _elements.size(); ++i) {
CPPInstance *elem_rep =
_elements[i]->substitute_decl(subst, current_scope, global_scope)
->as_instance();

View File

@ -637,11 +637,11 @@ evaluate() const {
(_u._op._op1->_type == T_string ||
_u._op._op1->_type == T_u8string)) {
int index = r2.as_integer();
if (index == _u._op._op1->_str.size()) {
int index = (int)r2.as_integer();
if ((size_t)index == _u._op._op1->_str.size()) {
return Result(0);
} else if (index >= 0 && index < _u._op._op1->_str.size()) {
return Result(_u._op._op1->_str[index]);
} else if (index >= 0 && (size_t)index < _u._op._op1->_str.size()) {
return Result(_u._op._op1->_str[(size_t)index]);
} else {
cerr << "array index " << index << " out of bounds of string literal "
<< *_u._op._op1 << "\n";

View File

@ -1689,7 +1689,7 @@ handle_include_directive(const string &args, const YYLTYPE &loc) {
// Now search the quote-include-path
if (!angle_quotes && !found_file) {
for (int dir=0; dir<_quote_include_path.get_num_directories(); dir++) {
for (size_t dir=0; dir<_quote_include_path.get_num_directories(); dir++) {
Filename match(_quote_include_path.get_directory(dir), filename);
if (match.exists()) {
filename = match;

View File

@ -132,11 +132,7 @@ add_hash(size_t hash, const Key &key) {
INLINE size_t pointer_hash::
add_hash(size_t hash, const void *key) {
// We don't mind if this loses precision.
#ifdef _MSC_VER
PN_uint32 key32 = PtrToUlong(key);
#else
PN_uint32 key32 = (PN_uint32)reinterpret_cast<unsigned long>(key);
#endif
PN_uint32 key32 = (PN_uint32)reinterpret_cast<uintptr_t>(key);
return AddHash::add_hash(hash, &key32, 1);
}

View File

@ -108,7 +108,7 @@ string FunctionRemap::
call_function(ostream &out, int indent_level, bool convert_result,
const string &container) const {
vector_string pexprs;
for (int i = 0; i < _parameters.size(); ++i) {
for (size_t i = 0; i < _parameters.size(); ++i) {
pexprs.push_back(get_parameter_name(i));
}
return call_function(out, indent_level, convert_result, container, pexprs);
@ -478,8 +478,8 @@ get_call_str(const string &container, const vector_string &pexprs) const {
separator = ", ";
}
int pn = _first_true_parameter;
int num_parameters = pexprs.size();
size_t pn = _first_true_parameter;
size_t num_parameters = pexprs.size();
if (_type == T_item_assignment_operator) {
// The last parameter is the value to set.
@ -513,8 +513,8 @@ get_call_str(const string &container, const vector_string &pexprs) const {
// of the nth parameter is it is empty.
////////////////////////////////////////////////////////////////////
string FunctionRemap::
get_parameter_expr(int n, const vector_string &pexprs) const {
if (n < (int)pexprs.size()) {
get_parameter_expr(size_t n, const vector_string &pexprs) const {
if (n < pexprs.size()) {
return pexprs[n];
}
return get_parameter_name(n);

View File

@ -112,7 +112,7 @@ public:
bool _blocking;
bool _extension;
bool _const_method;
int _first_true_parameter;
size_t _first_true_parameter;
int _num_default_parameters;
Type _type;
int _flags;
@ -137,7 +137,7 @@ public:
bool _is_valid;
private:
string get_parameter_expr(int n, const vector_string &pexprs) const;
string get_parameter_expr(size_t n, const vector_string &pexprs) const;
bool setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_maker);
};

View File

@ -3990,9 +3990,9 @@ collapse_default_remaps(std::map<int, std::set<FunctionRemap *> > &map_sets,
std::set<FunctionRemap *>::iterator sii;
for (sii = rmi->second.begin(); sii != rmi->second.end(); ++sii) {
FunctionRemap *remap = (*sii);
int pn = rmi->first - 1;
if (remap->_has_this && remap->_type != FunctionRemap::T_constructor) {
++pn;
size_t pn = (size_t)rmi->first;
if (!remap->_has_this || remap->_type == FunctionRemap::T_constructor) {
--pn;
}
nassertd(pn < remap->_parameters.size()) goto abort_iteration;
@ -4345,8 +4345,8 @@ write_function_forset(ostream &out,
for (sii = remaps.begin(); sii != remaps.end(); ++sii) {
remap = (*sii);
if (remap->_parameters.size() > (int)remap->_has_this) {
ParameterRemap *param = remap->_parameters[(int)remap->_has_this]._remap;
if (remap->_parameters.size() > (size_t)remap->_has_this) {
ParameterRemap *param = remap->_parameters[(size_t)remap->_has_this]._remap;
string param_name = param->get_orig_type()->get_local_name(&parser);
if (param_name != "CPT_InternalName" &&
@ -4601,15 +4601,15 @@ write_function_instance(ostream &out, FunctionRemap *remap,
if (remap->_has_this) {
num_params += 1;
}
if (num_params > remap->_parameters.size()) {
if (num_params > (int)remap->_parameters.size()) {
// Limit to how many parameters this remap actually has.
num_params = remap->_parameters.size();
num_params = (int)remap->_parameters.size();
max_num_args = num_params;
if (remap->_has_this) {
--max_num_args;
}
}
nassertv(num_params <= remap->_parameters.size());
nassertv(num_params <= (int)remap->_parameters.size());
bool only_pyobjects = true;

View File

@ -255,7 +255,7 @@ reload_implicit_pages() {
// We walk through the list of directories in forward order, so that
// the most important directories are visited first.
for (int di = 0; di < _search_path.get_num_directories(); ++di) {
for (size_t di = 0; di < _search_path.get_num_directories(); ++di) {
const Filename &directory = _search_path.get_directory(di);
if (directory.is_directory()) {
Filename canonical(directory, ".");

View File

@ -981,7 +981,7 @@ transform_vertices(const LMatrix4 &mat) {
PT(GeomVertexData) new_data = modify_vertex_data();
CPT(GeomVertexFormat) format = new_data->get_format();
int ci;
size_t ci;
for (ci = 0; ci < format->get_num_points(); ci++) {
GeomVertexRewriter data(new_data, format->get_point(ci));

View File

@ -358,7 +358,7 @@ unclean_set_format(const GeomVertexFormat *format) {
#ifndef NDEBUG
nassertv(format->get_num_arrays() == cdata->_format->get_num_arrays());
for (int ai = 0; ai < format->get_num_arrays(); ++ai) {
for (size_t ai = 0; ai < format->get_num_arrays(); ++ai) {
nassertv(format->get_array(ai)->get_stride() == cdata->_format->get_array(ai)->get_stride());
}
nassertv(cdata->_arrays.size() == cdata->_format->get_num_arrays());
@ -702,7 +702,7 @@ copy_from(const GeomVertexData *source, bool keep_data_objects,
LVecBase4i indices(0, 0, 0, 0);
nassertv(blend.get_num_transforms() <= 4);
for (int i = 0; i < blend.get_num_transforms(); i++) {
for (size_t i = 0; i < blend.get_num_transforms(); i++) {
weights[i] = blend.get_weight(i);
indices[i] = add_transform(transform_table, blend.get_transform(i),
already_added);
@ -722,7 +722,7 @@ copy_from(const GeomVertexData *source, bool keep_data_objects,
const TransformBlend &blend = blend_table->get_blend(from.get_data1i());
LVecBase4 weights = LVecBase4::zero();
for (int i = 0; i < blend.get_num_transforms(); i++) {
for (size_t i = 0; i < blend.get_num_transforms(); i++) {
int index = add_transform(transform_table, blend.get_transform(i),
already_added);
nassertv(index <= 4);
@ -1184,7 +1184,7 @@ transform_vertices(const LMatrix4 &mat, int begin_row, int end_row) {
const GeomVertexFormat *format = get_format();
int ci;
size_t ci;
for (ci = 0; ci < format->get_num_points(); ci++) {
GeomVertexRewriter data(this, format->get_point(ci));
do_transform_point_column(format, data, mat, begin_row, end_row);
@ -1395,7 +1395,7 @@ describe_vertex(ostream &out, int row) const {
// index and report the vertex weighting.
reader.set_column(ai, column);
int bi = reader.get_data1i();
if (bi >= 0 && bi < tb_table->get_num_blends()) {
if (bi >= 0 && (size_t)bi < tb_table->get_num_blends()) {
const TransformBlend &blend = tb_table->get_blend(bi);
out << " " << blend << "\n";
}
@ -1681,7 +1681,7 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) {
CPT(GeomVertexArrayDataHandle) blend_array_handle = cdata->_arrays[blend_array_index].get_read_pointer()->get_handle(current_thread);
const unsigned short *blendt = (const unsigned short *)blend_array_handle->get_read_pointer(true);
int ci;
size_t ci;
for (ci = 0; ci < new_format->get_num_points(); ci++) {
GeomVertexRewriter data(new_data, new_format->get_point(ci));
@ -1768,7 +1768,7 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) {
GeomVertexReader blendi(this, InternalName::get_transform_blend());
nassertv(blendi.has_column());
int ci;
size_t ci;
for (ci = 0; ci < new_format->get_num_points(); ci++) {
GeomVertexRewriter data(new_data, new_format->get_point(ci));

View File

@ -423,7 +423,7 @@ const GeomVertexColumn *GeomVertexFormat::
get_column(size_t i) const {
Arrays::const_iterator ai;
for (ai = _arrays.begin(); ai != _arrays.end(); ++ai) {
if (i < (*ai)->get_num_columns()) {
if (i < (size_t)(*ai)->get_num_columns()) {
return (*ai)->get_column(i);
}
i -= (*ai)->get_num_columns();
@ -448,7 +448,7 @@ int GeomVertexFormat::
get_array_with(size_t i) const {
int array_index = 0;
for (array_index = 0; array_index < (int)_arrays.size(); array_index++) {
if (i < _arrays[array_index]->get_num_columns()) {
if (i < (size_t)_arrays[array_index]->get_num_columns()) {
return array_index;
}
i -= _arrays[array_index]->get_num_columns();

View File

@ -1124,7 +1124,7 @@ finalize(BamReader *manager) {
// GeomVertexData::has_column().
CPT(GeomVertexData) vdata = geom->get_vertex_data(current_thread);
CPT(GeomVertexFormat) vformat = vdata->get_format();
for (int i = 0; i < vformat->get_num_arrays(); ++i) {
for (size_t i = 0; i < vformat->get_num_arrays(); ++i) {
const GeomVertexArrayFormat *varray = vformat->get_array(i);
manager->finalize_now((GeomVertexArrayFormat *)varray);
}

View File

@ -1357,13 +1357,13 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) {
for (int i = 0; i < vdata->get_num_arrays(); ++i) {
PT(GeomVertexArrayData) new_array = _new_data->modify_array(i);
CPT(GeomVertexArrayData) old_array = vdata->get_array(i);
int stride = _new_format->get_array(i)->get_stride();
int start_byte = vertex_offset * stride;
int copy_bytes = old_array->get_data_size_bytes();
size_t stride = (size_t)_new_format->get_array(i)->get_stride();
size_t start_byte = (size_t)vertex_offset * stride;
size_t copy_bytes = old_array->get_data_size_bytes();
nassertv(start_byte + copy_bytes <= new_array->get_data_size_bytes());
new_array->modify_handle()->copy_subdata_from
(start_byte, copy_bytes,
(start_byte, copy_bytes,
old_array->get_handle(), 0, copy_bytes);
}

View File

@ -208,7 +208,7 @@ get_bit(int index) const {
nassertr(index >= 0, false);
int w = index / num_bits_per_word;
int b = index % num_bits_per_word;
if (w >= get_num_words()) {
if ((size_t)w >= get_num_words()) {
return get_highest_bits();
} else {
return (_array[w].get_bit(b));
@ -226,7 +226,7 @@ set_bit(int index) {
nassertv(index >= 0);
int w = index / num_bits_per_word;
int b = index % num_bits_per_word;
if (w >= get_num_words() && _highest_bits) {
if ((size_t)w >= get_num_words() && _highest_bits) {
// All the highest bits are already on.
return;
}
@ -246,7 +246,7 @@ clear_bit(int index) {
nassertv(index >= 0);
int w = index / num_bits_per_word;
int b = index % num_bits_per_word;
if (w >= get_num_words() && !_highest_bits) {
if ((size_t)w >= get_num_words() && !_highest_bits) {
// All the highest bits are already off.
return;
}

View File

@ -29,9 +29,9 @@ SparseArray(const BitArray &from) {
bool empty_bit = from.get_highest_bits();
_inverse = empty_bit;
int begin = 0;
size_t begin = 0;
bool current_state = from.get_bit(0);
int i = 0;
size_t i = 0;
// By including get_num_bits()--one more than the last bit--in this
// traversal, we guarantee that we will end on the empty_bit state