diff --git a/dtool/Config.Irix.pp b/dtool/Config.Irix.pp index 86d556e4b8..062edf5333 100644 --- a/dtool/Config.Irix.pp +++ b/dtool/Config.Irix.pp @@ -74,6 +74,10 @@ // Do we have a true stringstream class defined in ? #define HAVE_SSTREAM +// Does fstream::open() require a third parameter, specifying the +// umask? +#define HAVE_OPEN_MASK 1 + // Do we have ? #define HAVE_NEW diff --git a/dtool/Config.Linux.pp b/dtool/Config.Linux.pp index 80823fc1aa..e8edd7db54 100644 --- a/dtool/Config.Linux.pp +++ b/dtool/Config.Linux.pp @@ -7,7 +7,7 @@ // // What additional flags should we pass to interrogate? -#define SYSTEM_IGATE_FLAGS -D__i386__ +#define SYSTEM_IGATE_FLAGS -D__i386__ -D__const=const // Is the platform big-endian (like an SGI workstation) or // little-endian (like a PC)? Define this to the empty string to @@ -69,10 +69,14 @@ // Should we include or ? Define HAVE_IOSTREAM // to nonempty if we should use , or empty if we should use // . -#define HAVE_IOSTREAM +#define HAVE_IOSTREAM 1 // Do we have a true stringstream class defined in ? -#define HAVE_SSTREAM +#define HAVE_SSTREAM 1 + +// Does fstream::open() require a third parameter, specifying the +// umask? Versions of gcc prior to 3.2 had this. +#define HAVE_OPEN_MASK // Do we have ? #define HAVE_NEW 1 diff --git a/dtool/Config.Win32.pp b/dtool/Config.Win32.pp index 536ba5a598..105ed950e2 100644 --- a/dtool/Config.Win32.pp +++ b/dtool/Config.Win32.pp @@ -74,6 +74,10 @@ // Do we have a true stringstream class defined in ? #define HAVE_SSTREAM 1 +// Does fstream::open() require a third parameter, specifying the +// umask? +#define HAVE_OPEN_MASK + // Do we have ? #define HAVE_NEW 1 diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index 9f997cebfc..4bc70c18d8 100644 --- a/dtool/LocalSetup.pp +++ b/dtool/LocalSetup.pp @@ -137,6 +137,9 @@ $[cdefine HAVE_NAMESPACE] /* Define if the C++ iostream library supports ios::binary. */ $[cdefine HAVE_IOS_BINARY] +/* Define if fstream::open() accepts a third parameter for umask. */ +$[cdefine HAVE_OPEN_MASK] + /* Define if the C++ compiler supports the typename keyword. */ $[cdefine HAVE_TYPENAME] diff --git a/dtool/pptempl/Depends.pp b/dtool/pptempl/Depends.pp index dced233b35..6034614476 100644 --- a/dtool/pptempl/Depends.pp +++ b/dtool/pptempl/Depends.pp @@ -37,9 +37,15 @@ // $[compile_sources] from the different directories. #define composite_list // Tag all the static libraries by defining the "lib_is_static" variable. - #forscopes static_lib_target ss_lib_target - #define lib_is_static 1 - #end static_lib_target ss_lib_target + #if $[WINDOWS_PLATFORM] + #forscopes static_lib_target ss_lib_target + #define lib_is_static 1 + #end static_lib_target ss_lib_target + #else + #forscopes static_lib_target + #define lib_is_static 1 + #end static_lib_target + #endif #forscopes metalib_target lib_target noinst_lib_target test_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target // We can optimize quite a bit by evaluating now several of the key diff --git a/dtool/src/dconfig/notify.cxx b/dtool/src/dconfig/notify.cxx index e3596fd24e..5b7ed455d8 100644 --- a/dtool/src/dconfig/notify.cxx +++ b/dtool/src/dconfig/notify.cxx @@ -109,18 +109,18 @@ get_ostream_ptr() const { // case this does nothing. But the flag is available in // case any extended types want to make use of it. //////////////////////////////////////////////////////////////////// -long Notify:: +ios::fmtflags Notify:: get_literal_flag() { static bool got_flag = false; - static long flag; + static ios::fmtflags flag; if (!got_flag) { -#ifndef WIN32_VC +#ifndef HAVE_IOSTREAM flag = ios::bitalloc(); #else // We lost bitalloc in the new iostream? This feature will just be - // disabled in Windows for now. No big deal. - flag = 0; + // disabled for now. No big deal. + flag = (ios::fmtflags)0; #endif got_flag = true; } diff --git a/dtool/src/dconfig/notify.h b/dtool/src/dconfig/notify.h index 5192fc90fd..91f675d6a4 100644 --- a/dtool/src/dconfig/notify.h +++ b/dtool/src/dconfig/notify.h @@ -19,7 +19,7 @@ #ifndef NOTIFY_H #define NOTIFY_H -#include +#include "dtoolbase.h" #include "notifyCategory.h" #include "notifySeverity.h" @@ -75,7 +75,7 @@ PUBLISHED: static Notify *ptr(); public: - static long get_literal_flag(); + static ios::fmtflags get_literal_flag(); bool assert_failure(const char *expression, int line, const char *source_file); diff --git a/dtool/src/dtoolbase/pdeque.h b/dtool/src/dtoolbase/pdeque.h index 6949898a43..a2a576b769 100644 --- a/dtool/src/dtoolbase/pdeque.h +++ b/dtool/src/dtoolbase/pdeque.h @@ -40,6 +40,7 @@ template class pdeque : public deque > { public: + typedef TYPENAME deque >::size_type size_type; pdeque() : deque >() { } pdeque(const pdeque ©) : deque >(copy) { } pdeque(size_type n) : deque >(n) { } diff --git a/dtool/src/dtoolbase/plist.h b/dtool/src/dtoolbase/plist.h index 3ac13c3e07..ee7739f114 100644 --- a/dtool/src/dtoolbase/plist.h +++ b/dtool/src/dtoolbase/plist.h @@ -40,16 +40,16 @@ template class plist : public list > { public: + typedef TYPENAME list >::size_type size_type; plist() : list >() { } plist(const plist ©) : list >(copy) { } plist(size_type n) : list >(n) { } plist(size_type n, const Type &value) : list >(n, value) { } - // VC++ doesn't seem to inherit these properly. - typedef list >::iterator iterator; - typedef list >::const_iterator const_iterator; - typedef list >::reverse_iterator reverse_iterator; - typedef list >::const_reverse_iterator const_reverse_iterator; + typedef TYPENAME list >::iterator iterator; + typedef TYPENAME list >::const_iterator const_iterator; + typedef TYPENAME list >::reverse_iterator reverse_iterator; + typedef TYPENAME list >::const_reverse_iterator const_reverse_iterator; }; #endif // NO_STYLE_ALLOCATOR diff --git a/dtool/src/dtoolbase/pvector.h b/dtool/src/dtoolbase/pvector.h index 317c33c42e..9b6c79b78f 100644 --- a/dtool/src/dtoolbase/pvector.h +++ b/dtool/src/dtoolbase/pvector.h @@ -41,6 +41,8 @@ template class pvector : public vector > { public: + typedef TYPENAME vector >::size_type size_type; + pvector() : vector >() { } pvector(const pvector ©) : vector >(copy) { } pvector(size_type n) : vector >(n) { } diff --git a/dtool/src/dtoolutil/filename.cxx b/dtool/src/dtoolutil/filename.cxx index 94865d91b4..2b8fdb943d 100644 --- a/dtool/src/dtoolutil/filename.cxx +++ b/dtool/src/dtoolutil/filename.cxx @@ -1171,7 +1171,7 @@ bool Filename:: open_read(ifstream &stream) const { assert(is_text() || is_binary()); - int open_mode = ios::in; + ios::openmode open_mode = ios::in; #ifdef HAVE_IOS_BINARY // For some reason, some systems (like Irix) don't define @@ -1206,7 +1206,7 @@ bool Filename:: open_write(ofstream &stream, bool truncate) const { assert(is_text() || is_binary()); - int open_mode = ios::out; + ios::openmode open_mode = ios::out; if (truncate) { open_mode |= ios::trunc; @@ -1232,10 +1232,10 @@ open_write(ofstream &stream, bool truncate) const { stream.clear(); string os_specific = to_os_specific(); -#ifdef WIN32_VC - stream.open(os_specific.c_str(), open_mode); -#else +#ifdef HAVE_OPEN_MASK stream.open(os_specific.c_str(), open_mode, 0666); +#else + stream.open(os_specific.c_str(), open_mode); #endif return (!stream.fail()); @@ -1256,7 +1256,7 @@ bool Filename:: open_append(ofstream &stream) const { assert(is_text() || is_binary()); - int open_mode = ios::app; + ios::openmode open_mode = ios::app; #ifdef HAVE_IOS_BINARY // For some reason, some systems (like Irix) don't define @@ -1268,10 +1268,10 @@ open_append(ofstream &stream) const { stream.clear(); string os_specific = to_os_specific(); -#ifdef WIN32_VC - stream.open(os_specific.c_str(), open_mode); -#else +#ifdef HAVE_OPEN_MASK stream.open(os_specific.c_str(), open_mode, 0666); +#else + stream.open(os_specific.c_str(), open_mode); #endif return (!stream.fail()); @@ -1292,7 +1292,7 @@ bool Filename:: open_read_write(fstream &stream) const { assert(is_text() || is_binary()); - int open_mode = ios::in | ios::out; + ios::openmode open_mode = ios::in | ios::out; #ifdef HAVE_IOS_BINARY // For some reason, some systems (like Irix) don't define @@ -1304,10 +1304,10 @@ open_read_write(fstream &stream) const { stream.clear(); string os_specific = to_os_specific(); -#ifdef WIN32_VC - stream.open(os_specific.c_str(), open_mode); -#else +#ifdef HAVE_OPEN_MASK stream.open(os_specific.c_str(), open_mode, 0666); +#else + stream.open(os_specific.c_str(), open_mode); #endif return (!stream.fail()); diff --git a/dtool/src/dtoolutil/pfstreamBuf.cxx b/dtool/src/dtoolutil/pfstreamBuf.cxx index a16d8cb07b..42f5434307 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.cxx +++ b/dtool/src/dtoolutil/pfstreamBuf.cxx @@ -29,10 +29,9 @@ PipeStreamBuf::PipeStreamBuf(PipeStreamBuf::Direction dir) : { init_pipe(); -#ifndef WIN32_VC - // taken from Dr. Ose. - // These lines, which are essential on Irix and Linux, seem to be - // unnecessary and not understood on Windows. +#ifndef HAVE_IOSTREAM + // These lines, which are essential on older implementations of the + // iostream library, are not understood by more recent versions. allocate(); assert((dir == Input) || (dir == Output)); if (dir == Input) { @@ -40,7 +39,7 @@ PipeStreamBuf::PipeStreamBuf(PipeStreamBuf::Direction dir) : } else { setp(base(), ebuf()); } -#endif /* WIN32_VC */ +#endif /* HAVE_IOSTREAM */ } PipeStreamBuf:: @@ -102,7 +101,7 @@ int PipeStreamBuf::underflow(void) { assert(_dir == Input); if ((eback() == (char*)0L) || (gptr() == (char*)0L) || (egptr() == (char*)0L)) { - // must be in win32 + // must be new-style iostream library char* buf = new char[4096]; char* ebuf = &(buf[4096]); setg(buf, ebuf, ebuf); @@ -114,22 +113,22 @@ int PipeStreamBuf::underflow(void) { if (eof_pipe()) { return EOF; } -#ifdef WIN32_VC +#ifdef HAVE_IOSTREAM size_t len = 4096; -#else /* WIN32_VC */ +#else /* HAVE_IOSTREAM */ size_t len = ebuf() - base(); -#endif /* WIN32_VC */ +#endif /* HAVE_IOSTREAM */ char* buf = new char[len]; size_t n = read_pipe(buf, len); int ret = buf[0]; if (n == 0) ret = EOF; else { -#ifdef WIN32_VC +#ifdef HAVE_IOSTREAM memcpy(eback()+(len-n), buf, n); -#else /* WIN32_VC */ +#else /* HAVE_IOSTREAM */ memcpy(base()+(len-n), buf, n); -#endif /* WIN32_VC */ +#endif /* HAVE_IOSTREAM */ gbump(-((int)n)); } delete buf; diff --git a/dtool/src/interrogatedb/interrogate_datafile.I b/dtool/src/interrogatedb/interrogate_datafile.I index 7e959903e5..0a584b4cbd 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.I +++ b/dtool/src/interrogatedb/interrogate_datafile.I @@ -27,7 +27,7 @@ template void idf_output_vector(ostream &out, const vector &vec) { out << vec.size() << " "; - vector::const_iterator vi; + TYPENAME vector::const_iterator vi; for (vi = vec.begin(); vi != vec.end(); ++vi) { out << (*vi) << " "; } diff --git a/dtool/src/parser-inc/iostream b/dtool/src/parser-inc/iostream index 2ed4702706..211e4b38c4 100644 --- a/dtool/src/parser-inc/iostream +++ b/dtool/src/parser-inc/iostream @@ -29,6 +29,9 @@ // We need to expose one method in each class to force it to publish. // We should fix that sometime. +class ios { + typedef long fmtflags; +}; class ostream { __published: void put(char c); diff --git a/panda/src/builder/builderFuncs.I b/panda/src/builder/builderFuncs.I index 010026f575..8b53cd522d 100644 --- a/panda/src/builder/builderFuncs.I +++ b/panda/src/builder/builderFuncs.I @@ -838,7 +838,7 @@ __mesh_and_build(InputIterator first, InputIterator last, int count = 0; if (!prims.empty()) { - Prims::iterator pi, last_pi; + TYPENAME Prims::iterator pi, last_pi; pi = prims.begin(); last_pi = pi; for (++pi; pi != prims.end(); ++pi) { diff --git a/panda/src/builder/builderPrimTempl.I b/panda/src/builder/builderPrimTempl.I index 317b53d16e..a1b01f2138 100644 --- a/panda/src/builder/builderPrimTempl.I +++ b/panda/src/builder/builderPrimTempl.I @@ -754,7 +754,7 @@ remove_doubled_verts(int closed) { // 'sc' used without having been initialized" warning messages. SameCoord sc = SameCoord(); - Verts::iterator new_end = unique(_verts.begin(), _verts.end(), sc); + TYPENAME Verts::iterator new_end = unique(_verts.begin(), _verts.end(), sc); _verts.erase(new_end, _verts.end()); if (closed) { diff --git a/panda/src/builder/builderProperties.h b/panda/src/builder/builderProperties.h index 353844a165..b634315cb5 100644 --- a/panda/src/builder/builderProperties.h +++ b/panda/src/builder/builderProperties.h @@ -22,7 +22,9 @@ #include "builderTypes.h" -#ifndef WIN32_VC +#ifndef HAVE_IOSTREAM +// We assume if your C++ library defines , then it also +// defines . #include #endif diff --git a/panda/src/builder/mesherEdge.I b/panda/src/builder/mesherEdge.I index f27a7ed4bd..07b725069b 100644 --- a/panda/src/builder/mesherEdge.I +++ b/panda/src/builder/mesherEdge.I @@ -114,7 +114,7 @@ remove(Strip *strip) { template void MesherEdge:: change_strip(Strip *from, Strip *to) { - Strips::iterator si; + TYPENAME Strips::iterator si; for (si = _strips.begin(); si != _strips.end(); ++si) { if (*si == from) { @@ -142,7 +142,7 @@ output(ostream &out) const { out << "Edge [" << *_a << " to " << *_b << "], " << _strips.size() << " strips:"; - Strips::const_iterator si; + TYPENAME Strips::const_iterator si; for (si = _strips.begin(); si != _strips.end(); ++si) { out << " " << (*si)->_index; } diff --git a/panda/src/builder/mesherFanMaker.I b/panda/src/builder/mesherFanMaker.I index 901a0c25eb..7e4dc7b8fa 100644 --- a/panda/src/builder/mesherFanMaker.I +++ b/panda/src/builder/mesherFanMaker.I @@ -134,7 +134,7 @@ compute_angle() const { double angle = 0.0; Vertexf v0 = _vertex->get_coord_value(*_bucket); - Edges::const_iterator ei; + TYPENAME Edges::const_iterator ei; for (ei = _edges.begin(); ei != _edges.end(); ++ei) { Normalf v1 = (*ei)->_a->get_coord_value(*_bucket) - v0; Normalf v2 = (*ei)->_b->get_coord_value(*_bucket) - v0; @@ -179,8 +179,8 @@ build(pvector &unrolled_tris) { // noncoplanar or which do not share identical properties. Then // we can send each piece between the seams to unroll(). - Strips::iterator si, last_si; - Edges::iterator ei, last_ei; + TYPENAME Strips::iterator si, last_si; + TYPENAME Edges::iterator ei, last_ei; // First, rotate the fan so it begins at a seam. We do this so we // won't be left out with part of one piece at the beginning and @@ -230,12 +230,12 @@ build(pvector &unrolled_tris) { new_fan._verts.push_back(_vertex); new_fan._verts.push_back(_edges.front()->_a); - Edges::iterator ei; + TYPENAME Edges::iterator ei; for (ei = _edges.begin(); ei != _edges.end(); ++ei) { new_fan._verts.push_back((*ei)->_b); } - Strips::iterator si; + TYPENAME Strips::iterator si; for (si = _strips.begin(); si != _strips.end(); ++si) { new_fan._prims.splice(new_fan._prims.end(), (*si)->_prims); (*si)->remove_all_edges(); @@ -263,8 +263,8 @@ int MesherFanMaker:: unroll(TYPENAME Strips::iterator strip_begin, TYPENAME Strips::iterator strip_end, TYPENAME Edges::iterator edge_begin, TYPENAME Edges::iterator edge_end, pvector &unrolled_tris) { - Edges::iterator ei; - Strips::iterator si; + TYPENAME Edges::iterator ei; + TYPENAME Strips::iterator si; int num_tris = 0; for (ei = edge_begin; ei != edge_end; ++ei) { @@ -340,7 +340,7 @@ ostream &MesherFanMaker:: output(ostream &out) const { out << *_vertex << ":["; if (!_edges.empty()) { - Edges::const_iterator ei; + TYPENAME Edges::const_iterator ei; for (ei = _edges.begin(); ei != _edges.end(); ++ei) { out << " " << *(*ei)->_a; } diff --git a/panda/src/builder/mesherStrip.I b/panda/src/builder/mesherStrip.I index e5d9926e06..1fa44ebdfc 100644 --- a/panda/src/builder/mesherStrip.I +++ b/panda/src/builder/mesherStrip.I @@ -130,7 +130,7 @@ rotate_back() { template INLINE TYPENAME MesherStrip::Edge MesherStrip:: get_head_edge() const { - Verts::const_iterator vi = _verts.begin(); + TYPENAME Verts::const_iterator vi = _verts.begin(); return Edge(_verts.front(), *++vi); } @@ -145,7 +145,7 @@ get_head_edge() const { template INLINE TYPENAME MesherStrip::Edge MesherStrip:: get_tail_edge() const { - Verts::const_reverse_iterator vi = _verts.rbegin(); + TYPENAME Verts::const_reverse_iterator vi = _verts.rbegin(); return Edge(*++vi, _verts.back()); } @@ -262,7 +262,7 @@ make_prim(const BuilderBucket &bucket) { if (dest_type != BPT_tristrip && dest_type != BPT_trifan) { // The easy case: a simple primitive. p.set_attrib(_prims.front()); - Verts::iterator vi; + TYPENAME Verts::iterator vi; for (vi = _verts.begin(); vi != _verts.end(); ++vi) { const Vertex *v = *vi; nassertr(v != (Vertex *)NULL, p); @@ -279,8 +279,8 @@ make_prim(const BuilderBucket &bucket) { // Now store all the vertices, as well as each individual // triangle's attributes. - Verts::iterator vi; - Prims::iterator pi; + TYPENAME Verts::iterator vi; + TYPENAME Prims::iterator pi; pi = _prims.begin(); int count = 0; for (vi = _verts.begin(); @@ -342,8 +342,8 @@ measure_sheet(const Edge *edge, int new_row, int &num_prims, int &num_rows, _row_id = this_row_id; - Edges::iterator ei; - Edge::Strips::iterator si; + TYPENAME Edges::iterator ei; + TYPENAME Edge::Strips::iterator si; if (_type == BPT_quad) { // If this is a quad, it has four neighbors: two in the direction @@ -395,7 +395,7 @@ measure_sheet(const Edge *edge, int new_row, int &num_prims, int &num_rows, // there will only be one besides ourselves, but there may be // more. Pick the best. - Edge::Strips &strips = (*ei)->_strips; + TYPENAME Edge::Strips &strips = (*ei)->_strips; MesherStrip *mate = NULL; for (si = strips.begin(); si != strips.end(); ++si) { if ((*si)->_row_id < first_row_id) { @@ -428,7 +428,7 @@ measure_sheet(const Edge *edge, int new_row, int &num_prims, int &num_rows, if (!(*ei)->matches(*edge)) { // Here's the edge. Same drill as above. - Edge::Strips &strips = (*ei)->_strips; + TYPENAME Edge::Strips &strips = (*ei)->_strips; MesherStrip *mate = NULL; for (si = strips.begin(); si != strips.end(); ++si) { if ((*si)->_row_id < first_row_id) { @@ -455,8 +455,8 @@ measure_sheet(const Edge *edge, int new_row, int &num_prims, int &num_rows, template void MesherStrip:: cut_sheet(int first_row_id, int do_mate, const BuilderBucket &bucket) { - Edges::iterator ei; - Edge::Strips::iterator si; + TYPENAME Edges::iterator ei; + TYPENAME Edge::Strips::iterator si; // First, start the process going on any neighbors that belong to a // later row. (We must do these first, because we'll change our @@ -470,7 +470,7 @@ cut_sheet(int first_row_id, int do_mate, const BuilderBucket &bucket) { StripPtrs strip_ptrs; for (ei = _edges.begin(); ei != _edges.end(); ++ei) { - Edge::Strips &strips = (*ei)->_strips; + TYPENAME Edge::Strips &strips = (*ei)->_strips; for (si = strips.begin(); si != strips.end(); ++si) { if ((*si)->_row_id > _row_id) { // Here's a different row in the sheet! @@ -482,7 +482,7 @@ cut_sheet(int first_row_id, int do_mate, const BuilderBucket &bucket) { // Now walk the temporary list and do some damage. We pass do_mate // = true to each of these neighbors, because as far as we know, // they're the first nodes of a particular row. - StripPtrs::iterator spi; + TYPENAME StripPtrs::iterator spi; for (spi = strip_ptrs.begin(); spi != strip_ptrs.end(); ++spi) { if ((*spi)->_status == MS_alive) { (*spi)->cut_sheet(first_row_id, true, bucket); @@ -498,7 +498,7 @@ cut_sheet(int first_row_id, int do_mate, const BuilderBucket &bucket) { ei = _edges.begin(); while (ei != _edges.end() && not_any) { - Edge::Strips &strips = (*ei)->_strips; + TYPENAME Edge::Strips &strips = (*ei)->_strips; si = strips.begin(); while (si != strips.end() && not_any) { if (*si != this && (*si)->_row_id == _row_id) { @@ -586,14 +586,14 @@ template bool MesherStrip:: find_ideal_mate(MesherStrip *&mate, Edge *&common_edge, const BuilderBucket &bucket) { - Edges::iterator ei; + TYPENAME Edges::iterator ei; mate = NULL; common_edge = NULL; for (ei = _edges.begin(); ei != _edges.end(); ++ei) { - Edge::Strips &strips = (*ei)->_strips; - Edge::Strips::iterator si; + TYPENAME Edge::Strips &strips = (*ei)->_strips; + TYPENAME Edge::Strips::iterator si; for (si = strips.begin(); si != strips.end(); ++si) { if (*si != this) { if (mate==NULL || pick_mate(**si, *mate, **ei, *common_edge, @@ -649,8 +649,8 @@ mate_pieces(Edge *common_edge, MesherStrip &front, MesherStrip &back, // Now we just need to find the right place to insert it. It // belongs in the middle of the common edge, i.e. after the first // vertex that is on the common edge and before the second vertex. - Verts::iterator a = front._verts.begin(); - Verts::iterator b = a; + TYPENAME Verts::iterator a = front._verts.begin(); + TYPENAME Verts::iterator b = a; ++b; if (common_edge->contains_vertex(*a)) { @@ -1010,7 +1010,7 @@ template int MesherStrip:: count_neighbors() const { int count = 0; - Edges::const_iterator ei; + TYPENAME Edges::const_iterator ei; for (ei = _edges.begin(); ei != _edges.end(); ++ei) { count += (*ei)->_strips.size(); @@ -1026,8 +1026,8 @@ count_neighbors() const { template ostream &MesherStrip:: show_neighbors(ostream &out) const { - Edges::const_iterator ei; - Edge::Strips::const_iterator si; + TYPENAME Edges::const_iterator ei; + TYPENAME Edge::Strips::const_iterator si; for (ei = _edges.begin(); ei != _edges.end(); ++ei) { for (si = (*ei)->_strips.begin(); @@ -1051,7 +1051,7 @@ find_uncommon_vertex(const Edge *edge) const { const Vertex *a = edge->_a; const Vertex *b = edge->_b; - Edges::const_iterator ei; + TYPENAME Edges::const_iterator ei; for (ei = _edges.begin(); ei != _edges.end(); ++ei) { Edge *e = (*ei); @@ -1075,7 +1075,7 @@ find_uncommon_vertex(const Edge *edge) const { template const TYPENAME MesherStrip::Edge *MesherStrip:: find_opposite_edge(const Vertex *vertex) const { - Edges::const_iterator ei; + TYPENAME Edges::const_iterator ei; for (ei = _edges.begin(); ei != _edges.end(); ++ei) { Edge *e = (*ei); if (!e->contains_vertex(vertex)) { @@ -1099,7 +1099,7 @@ find_opposite_edge(const Edge *edge) const { const Vertex *a = edge->_a; const Vertex *b = edge->_b; - Edges::const_iterator ei; + TYPENAME Edges::const_iterator ei; for (ei = _edges.begin(); ei != _edges.end(); ++ei) { Edge *e = (*ei); if (!e->contains_vertex(a) && !e->contains_vertex(b)) { @@ -1123,7 +1123,7 @@ find_adjacent_edge(const Edge *edge) const { const Vertex *a = edge->_a; const Vertex *b = edge->_b; - Edges::const_iterator ei; + TYPENAME Edges::const_iterator ei; for (ei = _edges.begin(); ei != _edges.end(); ++ei) { Edge *e = (*ei); if (e->contains_vertex(a) != e->contains_vertex(b)) { @@ -1148,7 +1148,7 @@ rotate_to_front(const Edge *edge) { // See if we're already there. if (_verts.front() == a || _verts.front() == b) { - Verts::iterator vi = _verts.begin(); + TYPENAME Verts::iterator vi = _verts.begin(); ++vi; if (*vi == a || *vi == b) { // Yes! @@ -1170,7 +1170,7 @@ rotate_to_front(const Edge *edge) { } // Now make sure the edge actually exists. - Verts::iterator vi = _verts.begin(); + TYPENAME Verts::iterator vi = _verts.begin(); ++vi; nassertv(*vi == a || *vi == b); } @@ -1189,7 +1189,7 @@ rotate_to_back(const Edge *edge) { // See if we're already there. if (_verts.back() == a || _verts.back() == b) { - Verts::reverse_iterator vi = _verts.rbegin(); + TYPENAME Verts::reverse_iterator vi = _verts.rbegin(); ++vi; if (*vi == a || *vi == b) { // Yes! @@ -1211,7 +1211,7 @@ rotate_to_back(const Edge *edge) { } // Now make sure the edge actually exists. - Verts::reverse_iterator vi = _verts.rbegin(); + TYPENAME Verts::reverse_iterator vi = _verts.rbegin(); ++vi; nassertv(*vi == a || *vi == b); } @@ -1243,7 +1243,7 @@ invert() { if (!can_invert()) { return false; } - Verts::iterator vi, vi2; + TYPENAME Verts::iterator vi, vi2; vi = _verts.begin(); while (vi != _verts.end()) { vi2 = vi; @@ -1346,7 +1346,7 @@ would_reverse_tail(BuilderPrimType wantType) const { template void MesherStrip:: convert_to_type(BuilderPrimType wantType) { - Verts::iterator vi, vi2; + TYPENAME Verts::iterator vi, vi2; int even; if (_type==wantType) { @@ -1418,7 +1418,7 @@ convert_to_type(BuilderPrimType wantType) { template void MesherStrip:: combine_edges(MesherStrip &other, int removeSides) { - Edges::iterator ei; + TYPENAME Edges::iterator ei; for (ei = other._edges.begin(); ei != other._edges.end(); ++ei) { (*ei)->change_strip(&other, this); } @@ -1439,7 +1439,7 @@ combine_edges(MesherStrip &other, int removeSides) { Edges junk_edges; - Edges::iterator next_ei; + TYPENAME Edges::iterator next_ei; ei = _edges.begin(); while (ei != _edges.end()) { next_ei = ei; @@ -1479,7 +1479,7 @@ remove_all_edges() { junk_edges.splice(junk_edges.end(), _edges); // Now we can safely remove all the to-be-junked edges. - Edges::iterator ei; + TYPENAME Edges::iterator ei; for (ei = junk_edges.begin(); ei != junk_edges.end(); ++ei) { (*ei)->remove(this); } @@ -1632,7 +1632,7 @@ output(ostream &out) const { out << " " << _index << " ["; - Verts::const_iterator vi; + TYPENAME Verts::const_iterator vi; for (vi = _verts.begin(); vi != _verts.end(); vi++) { out << " " << **vi; } @@ -1642,7 +1642,7 @@ output(ostream &out) const { show_neighbors(out); out << " edges"; - Edges::const_iterator ei; + TYPENAME Edges::const_iterator ei; for (ei = _edges.begin(); ei != _edges.end(); ei++) { out << " " << (void *)(*ei); } diff --git a/panda/src/builder/mesherTempl.I b/panda/src/builder/mesherTempl.I index 465f022a0a..5699c965c5 100644 --- a/panda/src/builder/mesherTempl.I +++ b/panda/src/builder/mesherTempl.I @@ -53,7 +53,7 @@ add_prim(const Prim &prim, MesherStripOrigin origin) { // Get the common vertex pointers for the primitive's vertices. for (i = 0; i < num_verts; i++) { - Verts::iterator n = + TYPENAME Verts::iterator n = _verts.insert(Verts::value_type(prim.get_vertex(i), EdgePtrs())).first; vptrs[i] = &(*n).first; eptrs[i] = &(*n).second; @@ -117,11 +117,11 @@ mesh() { if (_bucket->_show_quads) { // If we're showing quads, we shouldn't do any more meshing. - Strips::iterator si; + TYPENAME Strips::iterator si; for (si = _quads.begin(); si != _quads.end(); ++si) { if ((*si)._status == MS_alive) { (*si)._status = MS_done; - } + } } for (si = _strips.begin(); si != _strips.end(); ++si) { if ((*si)._status == MS_alive) { @@ -347,13 +347,13 @@ show(ostream &out) { */ out << _verts.size() << " verts:\n"; - Verts::const_iterator vi; + TYPENAME Verts::const_iterator vi; for (vi = _verts.begin(); vi != _verts.end(); ++vi) { const Vertex &v = (*vi).first; const EdgePtrs &edges = (*vi).second; out << v << " shares " << count_vert_edges(edges) << " edges:\n"; - EdgePtrs::const_iterator ei; + TYPENAME EdgePtrs::const_iterator ei; for (ei = edges.begin(); ei != edges.end(); ++ei) { if (!(*ei)->_strips.empty() || !(*ei)->_opposite->_strips.empty()) { out << " " << **ei << "\n"; @@ -361,14 +361,21 @@ show(ostream &out) { } } + TYPENAME Strips::const_iterator si; out << _tris.size() << " tris:\n"; - copy(_tris.begin(), _tris.end(), ostream_iterator(out, "\n")); + for (si = _tris.begin(); si != _tris.end(); ++si) { + out << (*si) << "\n"; + } out << _quads.size() << " quads:\n"; - copy(_quads.begin(), _quads.end(), ostream_iterator(out, "\n")); + for (si = _quads.begin(); si != _quads.end(); ++si) { + out << (*si) << "\n"; + } out << _strips.size() << " strips:\n"; - copy(_strips.begin(), _strips.end(), ostream_iterator(out, "\n")); + for (si = _strips.begin(); si != _strips.end(); ++si) { + out << (*si) << "\n"; + } } @@ -376,7 +383,7 @@ template int MesherTempl:: count_vert_edges(const EdgePtrs &edges) const { int count = 0; - EdgePtrs::const_iterator ei; + TYPENAME EdgePtrs::const_iterator ei; for (ei = edges.begin(); ei != edges.end(); ++ei) { count += (!(*ei)->_strips.empty() || !(*ei)->_opposite->_strips.empty()); } @@ -426,7 +433,7 @@ build_sheets() { while (!pre_sheeted.empty()) { // Pick the first quad on the list. - Strips::iterator best = pre_sheeted.begin(); + TYPENAME Strips::iterator best = pre_sheeted.begin(); // If the row_id is negative, we've already built a sheet out of // this quad. Leave it alone. We also need to leave it be if it @@ -500,7 +507,7 @@ find_fans() { // Consider all vertices. Any vertex with over a certain number of // edges connected to it is eligible to become a fan. - Verts::iterator vi; + TYPENAME Verts::iterator vi; for (vi = _verts.begin(); vi != _verts.end(); ++vi) { EdgePtrs &edges = (*vi).second; @@ -519,8 +526,8 @@ find_fans() { FanMakers fans; - EdgePtrs::iterator ei; - Edge::Strips::iterator si; + TYPENAME EdgePtrs::iterator ei; + TYPENAME Edge::Strips::iterator si; for (ei = edges.begin(); ei != edges.end(); ++ei) { for (si = (*ei)->_strips.begin(); si != (*ei)->_strips.end(); @@ -537,7 +544,7 @@ find_fans() { fans.erase(unique(fans.begin(), fans.end()), fans.end()); - FanMakers::iterator fi, fi2; + TYPENAME FanMakers::iterator fi, fi2; // Now pull out connected edges. int joined_any; @@ -568,7 +575,7 @@ find_fans() { // until we're done traversing all the vertices and primitives we // had in the first place (since adding them will affect the edge // lists). - pvector::iterator ti; + TYPENAME pvector::iterator ti; for (ti = unrolled_tris.begin(); ti != unrolled_tris.end(); ++ti) { add_prim(*ti); } @@ -607,7 +614,7 @@ make_quads() { Strip *tri, *mate, *mate2; Edge *common_edge, *common_edge2; - Strips::iterator si; + TYPENAME Strips::iterator si; for (si = _tris.begin(); si != _tris.end(); ++si) { tri = &(*si); @@ -629,7 +636,7 @@ make_quads() { // Now that we've found all the tris that are sure about each other, // mate them. - SoulMates::iterator mi; + TYPENAME SoulMates::iterator mi; for (mi = soulmates.begin(); mi != soulmates.end(); ++mi) { tri = (*mi).first.first; mate = (*mi).first.second; @@ -645,7 +652,7 @@ make_quads() { } // Now move all the strips off the tri list that no longer belong. - Strips::iterator next; + TYPENAME Strips::iterator next; si = _tris.begin(); while (si != _tris.end()) { next = si; @@ -666,7 +673,7 @@ meshList(Strips &strips) { while (!strips.empty()) { // Pick the first strip on the list. - Strips::iterator best = strips.begin(); + TYPENAME Strips::iterator best = strips.begin(); if ((*best)._status == MS_alive) { (*best).mate(*_bucket); diff --git a/panda/src/chan/animChannelFixed.h b/panda/src/chan/animChannelFixed.h index d306110836..ef7bf13aa3 100644 --- a/panda/src/chan/animChannelFixed.h +++ b/panda/src/chan/animChannelFixed.h @@ -36,6 +36,8 @@ template class AnimChannelFixed : public AnimChannel { public: + typedef TYPENAME AnimChannel::ValueType ValueType; + INLINE AnimChannelFixed(AnimGroup *parent, const string &name, const ValueType &value); INLINE AnimChannelFixed(const string &name, const ValueType &value); diff --git a/panda/src/chan/animChannelMatrixXfmTable.I b/panda/src/chan/animChannelMatrixXfmTable.I index 4c789b6933..d79fd264d6 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.I +++ b/panda/src/chan/animChannelMatrixXfmTable.I @@ -40,7 +40,7 @@ has_table(char table_id) const { if (table_index < 0) { return false; } - return !(_tables[table_index] == NULL); + return !(_tables[table_index] == (const float *)NULL); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/chan/animChannelScalarTable.I b/panda/src/chan/animChannelScalarTable.I index df69a4d3a7..9d999d9cf7 100644 --- a/panda/src/chan/animChannelScalarTable.I +++ b/panda/src/chan/animChannelScalarTable.I @@ -24,7 +24,7 @@ //////////////////////////////////////////////////////////////////// INLINE bool AnimChannelScalarTable:: has_table() const { - return !(_table == NULL); + return _table != (const float *)NULL; } diff --git a/panda/src/chan/animControl.cxx b/panda/src/chan/animControl.cxx index ed596d2c4d..103c2e2058 100644 --- a/panda/src/chan/animControl.cxx +++ b/panda/src/chan/animControl.cxx @@ -258,7 +258,7 @@ pose(int frame) { nassertv(num_frames > 0); // Modulo the number of frames. - frame = frame - cfloor(frame / num_frames) * num_frames; + frame = (int)(frame - cfloor(frame / num_frames) * num_frames); nassertv(frame >= 0 && frame < num_frames); _as_of_time = ClockObject::get_global_clock()->get_frame_time(); _playing = false; diff --git a/panda/src/chan/auto_bind.cxx b/panda/src/chan/auto_bind.cxx index 18c22c37e5..78e55a6e74 100644 --- a/panda/src/chan/auto_bind.cxx +++ b/panda/src/chan/auto_bind.cxx @@ -75,7 +75,7 @@ bind_anims(const PartNodes &parts, const AnimNodes &anims, } if (chan_cat.is_info()) { - if (control == NULL) { + if (control == (AnimControl *)NULL) { chan_cat.info() << "Bind failed.\n"; } else { diff --git a/panda/src/char/computedVertices.cxx b/panda/src/char/computedVertices.cxx index a559d04f55..570ee1289d 100644 --- a/panda/src/char/computedVertices.cxx +++ b/panda/src/char/computedVertices.cxx @@ -58,7 +58,7 @@ template static void compute_morphs(ValueType *table, const pvector &morph_list, Character *character) { - pvector::const_iterator mli; + TYPENAME pvector::const_iterator mli; for (mli = morph_list.begin(); mli != morph_list.end(); ++mli) { const MorphType &morph = (*mli); const CharacterSlider *slider; @@ -71,7 +71,7 @@ compute_morphs(ValueType *table, const pvector &morph_list, typedef TYPENAME MorphType::MorphValue MorphValue; TYPENAME Morphs::const_iterator mi; for (mi = morph._morphs.begin(); mi != morph._morphs.end(); ++mi) { - typedef typename MorphValue::VecType VecType; + typedef TYPENAME MorphValue::VecType VecType; ushort index = (*mi)._index; const VecType &v = (*mi)._vector; diff --git a/panda/src/display/graphicsWindow.cxx b/panda/src/display/graphicsWindow.cxx index 475f7d7f49..941e610b61 100644 --- a/panda/src/display/graphicsWindow.cxx +++ b/panda/src/display/graphicsWindow.cxx @@ -261,7 +261,7 @@ get_channel(int index) { GraphicsPipe *pipe = _pipe; if (pipe != (GraphicsPipe *)NULL) { chan = _pipe->get_hw_channel(this, index); - if (chan == NULL) { + if (chan == (GraphicsChannel *)NULL) { display_cat.error() << "GraphicsWindow::get_channel() - got a NULL channel" << endl; } else { diff --git a/panda/src/downloader/Sources.pp b/panda/src/downloader/Sources.pp index 609125db52..76084231c3 100644 --- a/panda/src/downloader/Sources.pp +++ b/panda/src/downloader/Sources.pp @@ -29,7 +29,7 @@ multiplexStreamBuf.I multiplexStreamBuf.h \ socketStream.h socketStream.I \ urlSpec.I urlSpec.h \ - $[if $[HAVE_NET], downloadDb.I downloadDb.h downloader.I downloader.h] \ + $[if $[HAVE_NET], downloadDb.I downloadDb.h] \ $[if $[HAVE_ZLIB], decompressor.h download_utils.h] \ $[if $[HAVE_CRYPTO], patcher.cxx patcher.h patcher.I] @@ -51,7 +51,7 @@ multiplexStream.cxx multiplexStreamBuf.cxx \ socketStream.cxx \ urlSpec.cxx \ - $[if $[HAVE_NET], downloadDb.cxx downloader.cxx] \ + $[if $[HAVE_NET], downloadDb.cxx] \ $[if $[HAVE_ZLIB], decompressor.cxx download_utils.cxx] #define INSTALL_HEADERS \ @@ -63,7 +63,6 @@ config_downloader.h \ decompressor.h \ download_utils.h downloadDb.h downloadDb.I \ - downloader.h downloader.I \ extractor.h \ httpAuthorization.I httpAuthorization.h \ httpBasicAuthorization.I httpBasicAuthorization.h \ diff --git a/panda/src/downloader/bioStream.I b/panda/src/downloader/bioStream.I index db76b68736..6017ad4083 100644 --- a/panda/src/downloader/bioStream.I +++ b/panda/src/downloader/bioStream.I @@ -43,7 +43,7 @@ IBioStream(BioPtr *source) : ISocketStream(&_buf) { //////////////////////////////////////////////////////////////////// INLINE IBioStream &IBioStream:: open(BioPtr *source) { - clear(0); + clear((ios::iostate)0); _buf.open(source); return *this; } @@ -86,7 +86,7 @@ OBioStream(BioPtr *source) : OSocketStream(&_buf) { //////////////////////////////////////////////////////////////////// INLINE OBioStream &OBioStream:: open(BioPtr *source) { - clear(0); + clear((ios::iostate)0); _buf.open(source); return *this; } @@ -129,7 +129,7 @@ BioStream(BioPtr *source) : SocketStream(&_buf) { //////////////////////////////////////////////////////////////////// INLINE BioStream &BioStream:: open(BioPtr *source) { - clear(0); + clear((ios::iostate)0); _buf.open(source); return *this; } diff --git a/panda/src/downloader/bioStreamBuf.cxx b/panda/src/downloader/bioStreamBuf.cxx index ccc9200305..fb31a1b18b 100644 --- a/panda/src/downloader/bioStreamBuf.cxx +++ b/panda/src/downloader/bioStreamBuf.cxx @@ -39,10 +39,7 @@ BioStreamBuf:: BioStreamBuf() { _is_closed = false; -#ifdef WIN32_VC - // In spite of the claims of the MSDN Library to the contrary, - // Windows doesn't seem to provide an allocate() function, so we'll - // do it by hand. +#ifdef HAVE_IOSTREAM char *buf = new char[8192]; char *ebuf = buf + 8192; char *mbuf = buf + 4096; diff --git a/panda/src/downloader/chunkedStream.I b/panda/src/downloader/chunkedStream.I index 8a0cf21172..24b7fbc1bf 100644 --- a/panda/src/downloader/chunkedStream.I +++ b/panda/src/downloader/chunkedStream.I @@ -43,7 +43,7 @@ IChunkedStream(BioStreamPtr *source, HTTPChannel *doc) : ISocketStream(&_buf) { //////////////////////////////////////////////////////////////////// INLINE IChunkedStream &IChunkedStream:: open(BioStreamPtr *source, HTTPChannel *doc) { - clear(0); + clear((ios::iostate)0); _buf.open_read(source, doc); return *this; } diff --git a/panda/src/downloader/chunkedStreamBuf.cxx b/panda/src/downloader/chunkedStreamBuf.cxx index 8d092a963c..c19d75bb40 100644 --- a/panda/src/downloader/chunkedStreamBuf.cxx +++ b/panda/src/downloader/chunkedStreamBuf.cxx @@ -37,10 +37,7 @@ ChunkedStreamBuf() { _chunk_remaining = 0; _done = true; -#ifdef WIN32_VC - // In spite of the claims of the MSDN Library to the contrary, - // Windows doesn't seem to provide an allocate() function, so we'll - // do it by hand. +#ifdef HAVE_IOSTREAM char *buf = new char[4096]; char *ebuf = buf + 4096; setg(buf, ebuf, ebuf); diff --git a/panda/src/downloader/downloadDb.cxx b/panda/src/downloader/downloadDb.cxx index caf07af2b7..e5d5518948 100644 --- a/panda/src/downloader/downloadDb.cxx +++ b/panda/src/downloader/downloadDb.cxx @@ -813,7 +813,7 @@ read(istream &read_stream, bool want_server_info) { uchar *header_buf = new uchar[_header_length]; // Read the header read_stream.read((char *)header_buf, _header_length); - if (read_stream.gcount() != (size_t)_header_length) { + if (read_stream.gcount() != _header_length) { downloader_cat.error() << "DownloadDb::read() - Empty file" << endl; return false; } diff --git a/panda/src/downloader/downloader.I b/panda/src/downloader/downloader.I deleted file mode 100644 index 822886d183..0000000000 --- a/panda/src/downloader/downloader.I +++ /dev/null @@ -1,168 +0,0 @@ -// Filename: downloader.I -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://www.panda3d.org/license.txt . -// -// To contact the maintainers of this program write to -// panda3d@yahoogroups.com . -// -//////////////////////////////////////////////////////////////////// - -#include "config_downloader.h" - - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::get_file_size -// Access: Published -// Description: Returns the size of the file currently being -// downloaded, in bytes, if it is known. Returns 0 if -// the file size is not known. -// -// After a call to initiate(), this will return 0; at -// some later point, when the first response from the -// server is read, it may return the actual size of the -// file if the server told us. It is possible the -// server will not tell us the size of the file, in -// which case this will always return 0. -//////////////////////////////////////////////////////////////////// -INLINE int Downloader:: -get_file_size() const { - return _file_size; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::set_frequency -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void Downloader:: -set_frequency(float frequency) { - nassertv(frequency > 0.0); - if (_frequency != frequency) { - _frequency = frequency; - _recompute_buffer = true; - } -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::get_frequency -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE float Downloader:: -get_frequency(void) const { - return _frequency; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::set_byte_rate -// Access: Public -// Description: Note: modem speeds are reported in bits, so you -// need to convert! -//////////////////////////////////////////////////////////////////// -INLINE void Downloader:: -set_byte_rate(float bytes) { - nassertv(bytes > 0.0); - if (_byte_rate != bytes) { - _byte_rate = bytes; - _recompute_buffer = true; - } -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::get_byte_rate -// Access: Public -// Description: Returns byte rate in bytes. -//////////////////////////////////////////////////////////////////// -INLINE float Downloader:: -get_byte_rate(void) const { - return _byte_rate; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::set_disk_write_frequency -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void Downloader:: -set_disk_write_frequency(int frequency) { - nassertv(frequency > 0); - if (_disk_write_frequency != frequency) { - _disk_write_frequency = frequency; - _recompute_buffer = true; - } -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::get_disk_write_frequency -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE int Downloader:: -get_disk_write_frequency(void) const { - return _disk_write_frequency; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::get_bytes_written -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE int Downloader:: -get_bytes_written(void) const { - if (_ever_initiated == false) { - downloader_cat.warning() - << "Downloader::get_bytes_written() - Download has not been " - << "initiated" << endl; - return 0; - } - if (_current_status != NULL) - return _current_status->_total_bytes_written; - else - return _total_bytes_written; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::get_bytes_requested -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE int Downloader:: -get_bytes_requested(void) const { - if (_ever_initiated == false) { - downloader_cat.warning() - << "Downloader::get_bytes_requested() - Download has not been " - << "initiated" << endl; - return 0; - } - if (_current_status != NULL) - return _current_status->_total_bytes_requested; - else - return _total_bytes_requested; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::get_bytes_per_second -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE float Downloader:: -get_bytes_per_second(void) const { - if (_ever_initiated == false) { - downloader_cat.warning() - << "Downloader::get_bytes_per_second() - Download has not been " - << "initiated" << endl; - return 0.0; - } - nassertr(_tlast - _tfirst > 0.0, 0.0); - nassertr(_current_status != NULL, 0.0); - return (float)((double)_current_status->_total_bytes / (_tlast - _tfirst)); -} diff --git a/panda/src/downloader/downloader.cxx b/panda/src/downloader/downloader.cxx deleted file mode 100644 index 087342d344..0000000000 --- a/panda/src/downloader/downloader.cxx +++ /dev/null @@ -1,1096 +0,0 @@ -// Filename: downloader.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://www.panda3d.org/license.txt . -// -// To contact the maintainers of this program write to -// panda3d@yahoogroups.com . -// -//////////////////////////////////////////////////////////////////// - - -#include "downloader.h" -#include "config_downloader.h" -#include "urlSpec.h" -#include "error_utils.h" -#include "filename.h" - -#include -#include - -#if !defined(WIN32_VC) - #include - #include - #include - #include - #define SOCKET_ERROR -1 -#endif - -//////////////////////////////////////////////////////////////////// -// Defines -//////////////////////////////////////////////////////////////////// -const int MAX_RECEIVE_BYTES = 16384; - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -Downloader:: -Downloader(void) { - _frequency = downloader_frequency; - _byte_rate = (float) downloader_byte_rate; - _disk_write_frequency = downloader_disk_write_frequency; - nassertv(_frequency > 0 && _byte_rate > 0 && _disk_write_frequency > 0); - _receive_size = (ulong)(_byte_rate * _frequency); - _disk_buffer_size = _disk_write_frequency * _receive_size; - _buffer = new Buffer(_disk_buffer_size); - - _connected = false; - _use_proxy = false; - // We need to flush after every write in case we're interrupted - _dest_stream.setf(ios::unitbuf, 0); - _current_status = NULL; - _recompute_buffer = false; - - _tfirst = 0.0; - _tlast = 0.0; - _got_any_data = false; - _initiated = false; - _ever_initiated = false; - _TCP_stack_initialized = false; - _total_bytes_written = 0; - _total_bytes_requested = 0; - _total_bytes_requested = 0; - - _file_size = 0; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -Downloader:: -~Downloader() { - if (_connected) - disconnect_from_server(); - _buffer.clear(); - if (_initiated == true) - cleanup(); -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::connect_to_server_by_proxy -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -int Downloader:: -connect_to_server_by_proxy(const URLSpec &proxy, const string &server_name) { - if (connect_to_server(proxy.get_server(), proxy.get_port()) != EU_success) { - downloader_cat.error() - << "Downloader::connect_to_server_by_proxy() - could not connect to: " - << proxy << endl; - return EU_error_abort; - } - - _proxy_string = "http://"; - _proxy_string += server_name; - _use_proxy = true; - - return EU_success; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::connect_to_server -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -int Downloader:: -connect_to_server(const string &name, uint port) { - -#if defined(WIN32) - if (_TCP_stack_initialized == false) { - WSAData mydata; - int answer1 = WSAStartup(0x0101, &mydata); - if(answer1 != 0) { - downloader_cat.error() - << "Downloader::connect_to_server() - WSAStartup() - error: " - << handle_socket_error() << endl; - return EU_error_abort; - } - _TCP_stack_initialized = true; - } -#endif - - if (downloader_cat.is_debug()) - downloader_cat.debug() - << "Downloader connecting to server: " << name << " on port: " - << port << endl; - - _server_name = name; - - _sin.sin_family = PF_INET; - _sin.sin_port = htons(port); - ulong addr = (ulong)inet_addr(name.c_str()); - struct hostent *hp = NULL; - - if (addr == INADDR_NONE) { - hp = gethostbyname(name.c_str()); - if (hp != NULL) - (void)memcpy(&_sin.sin_addr, hp->h_addr, (uint)hp->h_length); - else { - downloader_cat.error() - << "Downloader::connect_to_server() - gethostbyname() failed on: " - << name.c_str() << " with error: " - << handle_socket_error() << endl; - return get_network_error(); - } - } else - (void)memcpy(&_sin.sin_addr, &addr, sizeof(addr)); - - return connect_to_server(); -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::connect_to_server -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -int Downloader:: -connect_to_server(void) { - if (_connected == true) - return EU_success; - - _socket = 0xffffffff; - _socket = socket(PF_INET, SOCK_STREAM, 0); - if (_socket == (int)0xffffffff) { - downloader_cat.error() - << "Downloader::connect_to_server() - socket failed: " - << handle_socket_error() << endl; - return get_network_error(); - } - - if (connect(_socket, (struct sockaddr *)&_sin, sizeof(_sin)) == - SOCKET_ERROR) { - downloader_cat.error() - << "Downloader::connect_to_server() - connect() failed: " - << handle_socket_error() << endl; - disconnect_from_server(); - return get_network_error(); - } - - _connected = true; - return EU_success; -} - -/////////////////////////////////////////////////////////////////// -// Function: Downloader::disconnect_from_server -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -void Downloader:: -disconnect_from_server(void) { - if (downloader_cat.is_debug()) - downloader_cat.debug() - << "Downloader disconnecting from server..." << endl; -#if defined(WIN32) - (void)closesocket(_socket); -#else - (void)close(_socket); -#endif - _connected = false; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::safe_send -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -int Downloader:: -safe_send(int socket, const char *data, int length, long timeout) { - if (length == 0) { - downloader_cat.error() - << "Downloader::safe_send() - requested 0 length send!" << endl; - return EU_error_abort; - } - int bytes = 0; - struct timeval tv; - tv.tv_sec = timeout; - tv.tv_usec = 0; - fd_set wset; - FD_ZERO(&wset); - while (bytes < length) { - FD_SET(socket, &wset); - int sret = select(socket + 1, NULL, &wset, NULL, &tv); - if (sret == 0) { - downloader_cat.error() - << "Downloader::safe_send() - select timed out after: " - << timeout << " seconds" << endl; - return EU_error_network_timeout; - } else if (sret == -1) { - downloader_cat.error() - << "Downloader::safe_send() - error: " << handle_socket_error() - << endl; - return get_network_error(); - } - int ret = send(socket, data, length, 0); - if (ret > 0) - bytes += ret; - else { - downloader_cat.error() - << "Downloader::safe_send() - error: " << handle_socket_error() - << endl; - return get_network_error(); - } - } - return EU_success; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::fast_receive -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -int Downloader:: -fast_receive(int socket, DownloadStatus *status, int rec_size) { - nassertr(status != NULL, EU_error_abort); - if (rec_size <= 0) { - downloader_cat.error() - << "Downloader::fast_receive() - Invalid receive size: " << rec_size - << endl; - return EU_error_abort; - } - - // Poll the socket with select() to see if there is any data - struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = 0; - fd_set rset; - FD_ZERO(&rset); - FD_SET(socket, &rset); - int sret = select(socket, &rset, NULL, NULL, &tv); - if (sret == 0) { - return EU_network_no_data; - } else if (sret == -1) { - downloader_cat.error() - << "Downloader::fast_receive() - select() error: " - << handle_socket_error() << endl; - return get_network_error(); - } - int ret = recv(socket, status->_next_in, rec_size, 0); - if (ret == 0) { - return EU_eof; - } else if (ret == -1) { - downloader_cat.error() - << "Downloader::fast_receive() - recv() error: " - << handle_socket_error() << endl; - return get_network_error(); - } - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::fast_receive() - recv() requested: " << rec_size - << " got: " << ret << " bytes" << endl; - status->_next_in += ret; - status->_bytes_in_buffer += ret; - status->_total_bytes += ret; - return EU_success; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::initiate -// Access: Published -// Description: Initiate the download of a complete file from the server. -//////////////////////////////////////////////////////////////////// -int Downloader:: -initiate(const string &file_name, Filename file_dest) { - return initiate(file_name, file_dest, 0, 0, 0, false); -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::initiate -// Access: Published -// Description: Initiate the download of a file from a server. -//////////////////////////////////////////////////////////////////// -int Downloader:: -initiate(const string &file_name, Filename file_dest, - int first_byte, int last_byte, int total_bytes, - bool partial_content) { - - if (_initiated == true) { - downloader_cat.error() - << "Downloader::initiate() - Download has already been initiated" - << endl; - return EU_error_abort; - } - - // The file size is zero until we hear otherwise from the server - _file_size = 0; - - // Connect to the server - int connect_ret = connect_to_server(); - if (connect_ret < 0) - return connect_ret; - - // Attempt to open the destination file - file_dest.set_binary(); - _dest_stream.setf(ios::unitbuf, 0); - bool result; - if (partial_content == true && first_byte > 0) - result = file_dest.open_append(_dest_stream); - else - result = file_dest.open_write(_dest_stream); - if (result == false) { - downloader_cat.error() - << "Downloader::initiate() - Error opening file: " << file_dest - << " for writing: " << strerror(errno) << endl; - return get_write_error(); - } - - // Send an HTTP request for the file to the server - string request = "GET "; - if (_use_proxy == true) - request += _proxy_string; - request += file_name; - request += " HTTP/1.1\012Host: "; - request += _server_name; - request += "\012Connection: close"; - if (partial_content == true) { - if (downloader_cat.is_debug()) - downloader_cat.debug() - << "Downloader::initiate() - Requesting byte range: " << first_byte - << "-" << last_byte << endl; - request += "\012Range: bytes="; - stringstream start_stream; - start_stream << first_byte << "-" << last_byte; - request += start_stream.str(); - } - request += "\012\012"; - int outlen = request.size(); - if (downloader_cat.is_debug()) - downloader_cat.debug() - << "Downloader::initiate() - Sending request:\n" << request << endl; - int send_ret = safe_send(_socket, request.c_str(), outlen, - (long)downloader_timeout); - if (send_ret < 0) - return send_ret; - - // Create a download status to maintain download progress information - _current_status = new DownloadStatus(_buffer->_buffer, - first_byte, last_byte, total_bytes, - partial_content); - - _tfirst = 0.0; - _tlast = 0.0; - _got_any_data = false; - _initiated = true; - _ever_initiated = true; - _download_to_ram = false; - return EU_success; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::initiate -// Access: Published -// Description: Initiate the download of a file from a server. -//////////////////////////////////////////////////////////////////// -int Downloader:: -initiate(const string &file_name) { - if (_initiated == true) { - downloader_cat.error() - << "Downloader::initiate() - Download has already been initiated" - << endl; - return EU_error_abort; - } - - // The file size is zero until we hear otherwise from the server - _file_size = 0; - - // Connect to the server - int connect_ret = connect_to_server(); - if (connect_ret < 0) - return connect_ret; - - // Send an HTTP request for the file to the server - string request = "GET "; - if (_use_proxy == true) - request += _proxy_string; - request += file_name; - request += " HTTP/1.1\012Host: "; - request += _server_name; - request += "\012Connection: close"; - request += "\012\012"; - int outlen = request.size(); - if (downloader_cat.is_debug()) - downloader_cat.debug() - << "Downloader::initiate() - Sending request:\n" << request << endl; - int send_ret = safe_send(_socket, request.c_str(), outlen, - (long)downloader_timeout); - if (send_ret < 0) - return send_ret; - - // Create a download status to maintain download progress information - _current_status = new DownloadStatus(_buffer->_buffer, 0, 0, 0, false); - - _tfirst = 0.0; - _tlast = 0.0; - _got_any_data = false; - _initiated = true; - _ever_initiated = true; - _download_to_ram = true; - _dest_string_stream = new ostringstream(); - return EU_success; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::cleanup -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -void Downloader:: -cleanup(void) { - if (_initiated == false) { - downloader_cat.error() - << "Downloader::cleanup() - Download has not been initiated" - << endl; - return; - } - - // The "Connection: close" line tells the server to close the - // connection when the download is complete - disconnect_from_server(); - _dest_stream.close(); - _total_bytes_written = _current_status->_total_bytes_written; - _total_bytes_requested = _current_status->_total_bytes_requested; - delete _current_status; - // We must set this to NULL otherwise there is a bad pointer floating around - _current_status = NULL; - _initiated = false; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::run -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -int Downloader:: -run(void) { - if (_initiated == false) { - downloader_cat.error() - << "Downloader::run() - Download has not been initiated" - << endl; - return EU_error_abort; - } - - nassertr(_current_status != NULL, EU_error_abort); - - int connect_ret = connect_to_server(); - if (connect_ret < 0) - return connect_ret; - - if (_download_to_ram == true) - return run_to_ram(); - - int ret = EU_ok; - int write_ret; - double t0 = _clock.get_real_time(); - if (_tfirst == 0.0) { - _tfirst = t0; - } - if (t0 - _tlast < _frequency) - return EU_ok; - - _tlast = _clock.get_real_time(); - - // Recompute the buffer size if necessary - if (_recompute_buffer == true) { - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::run() - Recomputing the buffer" << endl; - - // Flush the current buffer if it holds any data - if (_current_status->_bytes_in_buffer > 0) { - write_ret = write_to_disk(_current_status); - if (write_ret < 0) - return write_ret; - - ret = EU_write; - } - - // Allocate a new buffer - _buffer.clear(); - _receive_size = (ulong)(_frequency * _byte_rate); - _disk_buffer_size = _receive_size * _disk_write_frequency; - _buffer = new Buffer(_disk_buffer_size); - _current_status->_buffer = _buffer->_buffer; - _current_status->reset(); - // Reset the flag - _recompute_buffer = false; - // Reset the statistics - _tfirst = t0; - _current_status->_total_bytes = 0; - - } else if (_current_status->_bytes_in_buffer + _receive_size > ((unsigned int)_disk_buffer_size)) { - - // Flush the current buffer if the next request would overflow it - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::run() - Flushing buffer" << endl; - write_ret = write_to_disk(_current_status); - if (write_ret < 0) - return write_ret; - ret = EU_write; - } - - // Attempt to receive the bytes from the socket - int fret = 0; - // Handle the case of a fast connection - if (_receive_size > (ulong)MAX_RECEIVE_BYTES) { - int repeat = (int)(_receive_size / MAX_RECEIVE_BYTES); - int remain = (int)fmod((double)_receive_size, (double)MAX_RECEIVE_BYTES); - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::run() - fast connection - repeat: " << repeat - << " remain: " << remain << endl; - // Make multiple requests at once but do not exceed MAX_RECEIVE_BYTES - // for any single request - for (int i = 0; i <= repeat; i++) { - if (i < repeat) - fret = fast_receive(_socket, _current_status, MAX_RECEIVE_BYTES); - else if (remain > 0) - fret = fast_receive(_socket, _current_status, remain); - if (fret == EU_eof || fret < 0) { - break; - } else if (fret == EU_success) { - _got_any_data = true; - } - } - } else { // Handle the normal speed connection case - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::run() - normal connection" << endl; - fret = fast_receive(_socket, _current_status, _receive_size); - } - - _current_status->_total_bytes_requested += _receive_size; - - // Check for end of file - if (fret == EU_eof) { - if (_got_any_data == true) { - if (_current_status->_bytes_in_buffer > 0) { - write_ret = write_to_disk(_current_status); - if (write_ret < 0) - return write_ret; - } - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::run() - Got eof" << endl; - cleanup(); - return EU_success; - } else { - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::run() - Got 0 bytes" << endl; - return ret; - } - } else if (fret == EU_network_no_data) { - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::run() - No data" << endl; - return ret; - } else if (fret < 0) { - return fret; - } - - _got_any_data = true; - return ret; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::run_to_ram -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -int Downloader:: -run_to_ram(void) { - int ret = EU_ok; - int write_ret; - - double t0 = _clock.get_real_time(); - if (_tfirst == 0.0) { - _tfirst = t0; - } - if (t0 - _tlast < _frequency) - return EU_ok; - - _tlast = _clock.get_real_time(); - - // Recompute the buffer size if necessary - if (_recompute_buffer == true) { - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::run_to_ram() - Recomputing the buffer" << endl; - - // Flush the current buffer if it holds any data - if (_current_status->_bytes_in_buffer > 0) { - write_ret = write_to_ram(_current_status); - if (write_ret < 0) - return write_ret; - ret = EU_write_ram; - } - - // Allocate a new buffer - _buffer.clear(); - _receive_size = (ulong)(_frequency * _byte_rate); - _disk_buffer_size = _receive_size * _disk_write_frequency; - _buffer = new Buffer(_disk_buffer_size); - _current_status->_buffer = _buffer->_buffer; - _current_status->reset(); - // Reset the flag - _recompute_buffer = false; - // Reset the statistics - _tfirst = t0; - _current_status->_total_bytes = 0; - - } else if (_current_status->_bytes_in_buffer + _receive_size > - ((unsigned int)_disk_buffer_size)) { - - // Flush the current buffer if the next request would overflow it - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::run_to_ram() - Flushing buffer" << endl; - write_ret = write_to_ram(_current_status); - if (write_ret < 0) - return write_ret; - ret = EU_write_ram; - } - - // Attempt to receive the bytes from the socket - int fret = 0; - // Handle the case of a fast connection - if (_receive_size > (ulong)MAX_RECEIVE_BYTES) { - int repeat = (int)(_receive_size / MAX_RECEIVE_BYTES); - int remain = (int)fmod((double)_receive_size, (double)MAX_RECEIVE_BYTES); - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::run_to_ram() - fast connection - repeat: " << repeat - << " remain: " << remain << endl; - // Make multiple requests at once but do not exceed MAX_RECEIVE_BYTES - // for any single request - for (int i = 0; i <= repeat; i++) { - if (i < repeat) - fret = fast_receive(_socket, _current_status, MAX_RECEIVE_BYTES); - else if (remain > 0) - fret = fast_receive(_socket, _current_status, remain); - if (fret == EU_eof || fret < 0) { - break; - } else if (fret == EU_success) { - _got_any_data = true; - } - } - } else { // Handle the normal speed connection case - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::run_to_ram() - normal connection" << endl; - fret = fast_receive(_socket, _current_status, _receive_size); - } - - _current_status->_total_bytes_requested += _receive_size; - - // Check for end of file - if (fret == EU_eof) { - if (_got_any_data == true) { - if (_current_status->_bytes_in_buffer > 0) { - write_ret = write_to_ram(_current_status); - if (write_ret < 0) - return write_ret; - } - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::run_to_ram() - Got eof" << endl; - cleanup(); - return EU_success; - } else { - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::run_to_ram() - Got 0 bytes" << endl; - return ret; - } - } else if (fret == EU_network_no_data) { - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::run_to_ram() - No data" << endl; - return ret; - } else if (fret < 0) { - return fret; - } - - _got_any_data = true; - return ret; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::parse_http_response -// Access: Private -// Description: Check the HTTP response from the server -//////////////////////////////////////////////////////////////////// -int Downloader:: -parse_http_response(const string &resp) { - size_t ws = resp.find(" ", 0); - string httpstr = resp.substr(0, ws); -#if 0 - if (!(httpstr == "HTTP/1.1")) { - downloader_cat.error() - << "Downloader::parse_http_response() - not HTTP/1.1 - got: " - << httpstr << endl; - return EU_error_abort; - } -#endif - size_t ws2 = resp.find(" ", ws); - string numstr = resp.substr(ws, ws2); - nassertr(numstr.length() > 0, false); - int num = atoi(numstr.c_str()); - switch (num) { - case 200: - case 206: - return EU_success; - case 202: - // Accepted - server may not honor request, though - if (downloader_cat.is_debug()) - downloader_cat.debug() - << "Downloader::parse_http_response() - got a 202 Accepted - " - << "server does not guarantee to honor this request" << endl; - return EU_success; - case 201: - case 203: - case 204: - case 205: - break; - case 302: - if (downloader_cat.is_debug()) - downloader_cat.debug() - << "Downloader::parse_http_response() - got a 302 redirect" - << endl; - return EU_error_abort; - break; - case 407: - return EU_error_http_proxy_authentication; - case 408: - return EU_error_http_server_timeout; - case 503: - return EU_error_http_service_unavailable; - case 504: - return EU_error_http_gateway_timeout; - default: - break; - } - - downloader_cat.error() - << "Downloader::parse_http_response() - Invalid response: " - << resp << endl; - return EU_error_abort; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::parse_header -// Access: Private -// Description: Looks for a valid header. If it finds one, it -// calculates the header length and strips it from -// the download status structure. Function returns false -// on an error condition, otherwise true. -//////////////////////////////////////////////////////////////////// -int Downloader:: -parse_header(DownloadStatus *status) { - nassertr(status != NULL, EU_error_abort); - - if (status->_header_is_complete == true) - return EU_success; - - if (status->_bytes_in_buffer == 0) { - downloader_cat.error() - << "Downloader::parse_header() - Empty buffer!" << endl; - return EU_error_abort; - } - - string bufstr((char *)status->_start, status->_bytes_in_buffer); - size_t p = 0; - bool redirect = false; - bool authenticate = false; - while (p < bufstr.length()) { - // Server sends out CR LF (\r\n) as newline delimiter - size_t nl = bufstr.find("\015\012", p); - if (nl == string::npos) { - downloader_cat.error() - << "Downloader::parse_header() - No newlines in buffer of " - << "length: " << status->_bytes_in_buffer << endl; - return EU_error_abort; - } else if (p == 0 && nl == p) { - downloader_cat.error() - << "Downloader::parse_header() - Buffer begins with newline!" - << endl; - return EU_error_abort; - } - - string component = bufstr.substr(p, nl - p); - - // The first line of the response should say whether - // got an error or not - if (status->_first_line_complete == false) { - status->_first_line_complete = true; - int parse_ret = parse_http_response(component); - if (parse_ret == EU_success) { - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::parse_header() - Header is valid: " - << component << endl; - status->_header_is_valid = true; - } else if (parse_ret == EU_error_http_proxy_authentication) { - authenticate = true; - status->_header_is_valid = true; - } else if (parse_ret == EU_http_redirect) { - redirect = true; - status->_header_is_valid = true; - } else { - return parse_ret; - } - } - - // Look for content length and location - size_t cpos = component.find(":"); - string tline = component.substr(0, cpos); - if (tline == "Content-Length") { - tline = component.substr(cpos + 2, string::npos); - int server_download_bytes = atoi(tline.c_str()); - _file_size = server_download_bytes; - - if (status->_partial_content) { - // Ensure that our expected content length matches what the - // server gives us. - int client_download_bytes = status->_last_byte - status->_first_byte; - if (status->_first_byte == 0) - client_download_bytes += 1; - if (client_download_bytes != server_download_bytes) { - downloader_cat.error() - << "Downloader::parse_header() - server size = " - << server_download_bytes << ", client size = " - << client_download_bytes << " (" - << status->_last_byte << "-" << status->_first_byte << ")" << endl; - return EU_error_abort; - } - } - - } else if (tline == "Transfer-Encoding") { - // This code isn't designed to handle transfer encodings other - // than identity. It will certainly fail if we ever get this. - string encoding = component.substr(cpos + 2); - if (encoding == "identity") { - // No problem. - - } else { - downloader_cat.error() - << "Non-identity transfer encoding specified by server!\n"; - downloader_cat.error() - << component << "\n"; - return EU_error_abort; - } - - } else if (authenticate && tline == "Proxy-Authenticate") { - // We don't presently support authentication-demanding proxies. - downloader_cat.error() - << component << "\n"; - return EU_error_http_proxy_authentication; - - } else if (redirect == true && tline == "Location") { - tline = component.substr(cpos + 1, string::npos); - downloader_cat.error() - << "Got redirect to " << tline << endl; - return EU_error_abort; - } - - // Two consecutive (CR LF)s indicates end of HTTP header - if (nl == p) { - // Make sure we didn't get a redirect - if (redirect == true) { - downloader_cat.error() - << "Downloader::parse_header() - Got a 302 redirect but no " - << "Location directive" << endl; - return EU_error_abort; - } - if (authenticate) { - return EU_error_http_proxy_authentication; - } - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::parse_header() - Header is complete" << endl; - status->_header_is_complete = true; - - // Strip the header out of the status buffer - int header_length = nl + 2; - status->_start += header_length; - status->_bytes_in_buffer -= header_length; - - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::parse_header() - Stripping out header of size: " - << header_length << endl; - - return EU_success; - } - - p = nl + 2; - } - - if (status->_header_is_complete == false) { - if (downloader_cat.is_debug()) - downloader_cat.debug() - << "Downloader::parse_header() - Reached end of buffer without " - << "successfully parsing the header - buffer size: " - << status->_bytes_in_buffer << endl; - return EU_error_abort; - } - - return EU_success; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::write_to_disk -// Access: Private -// Description: Writes a download to disk. If there is a header, -// the pointer and size are adjusted so the header -// is excluded. Function returns false on error -// condition. -//////////////////////////////////////////////////////////////////// -int Downloader:: -write_to_disk(DownloadStatus *status) { - nassertr(status != NULL, EU_error_abort); - - // Ensure the header has been parsed successfully first - int parse_ret = parse_header(status); - if (parse_ret < 0) - return parse_ret; - - if (status->_header_is_complete == false) { - downloader_cat.error() - << "Downloader::write_to_disk() - Incomplete HTTP header - " - << "(or header was larger than download buffer) - " - << "try increasing download-buffer-size" << endl; - return EU_error_abort; - } - - // Write what we have so far to disk - if (status->_bytes_in_buffer > 0) { - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::write_to_disk() - Writing " - << status->_bytes_in_buffer << " to disk" << endl; - - _dest_stream.write(status->_start, status->_bytes_in_buffer); - _dest_stream.flush(); - status->_total_bytes_written += status->_bytes_in_buffer; - } - - status->reset(); - - return EU_success; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::write_to_ram -// Access: Private -// Description: Writes a download to memory. If there is a header, -// the pointer and size are adjusted so the header -// is excluded. Function returns false on error -// condition. -//////////////////////////////////////////////////////////////////// -int Downloader:: -write_to_ram(DownloadStatus *status) { - nassertr(status != NULL, EU_error_abort); - - // Ensure the header has been parsed successfully first - int parse_ret = parse_header(status); - if (parse_ret < 0) - return parse_ret; - - if (status->_header_is_complete == false) { - downloader_cat.error() - << "Downloader::write_to_ram() - Incomplete HTTP header - " - << "(or header was larger than download buffer) - " - << "try increasing download-buffer-size" << endl; - return EU_error_abort; - } - - // Write what we have so far to memory - if (status->_bytes_in_buffer > 0) { - if (downloader_cat.is_spam()) - downloader_cat.spam() - << "Downloader::write_to_ram() - Writing " - << status->_bytes_in_buffer << " to memory" << endl; - - _dest_string_stream->write(status->_start, status->_bytes_in_buffer); - status->_total_bytes_written += status->_bytes_in_buffer; - } - - status->reset(); - - return EU_success; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::get_ramfile -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -bool Downloader:: -get_ramfile(Ramfile &rfile) { - rfile._data = _dest_string_stream->str(); - delete _dest_string_stream; - _dest_string_stream = NULL; - return true; -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::DownloadStatus::constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -Downloader::DownloadStatus:: -DownloadStatus(char *buffer, int first_byte, int last_byte, - int total_bytes, bool partial_content) { - _first_line_complete = false; - _header_is_complete = false; - _header_is_valid = false; - _buffer = buffer; - _first_byte = first_byte; - _last_byte = last_byte; - _total_bytes = total_bytes; - // Initialize the total bytes written to include all - // the bytes from previous partial downloads. This will - // ensure that when somebody calls get_bytes_written they - // will get the total size of the file, not just the number - // of bytes for this partial download - _total_bytes_written = first_byte; - _total_bytes_requested = first_byte; - _partial_content = partial_content; - reset(); -} - -//////////////////////////////////////////////////////////////////// -// Function: Downloader::DownloadStatus::reset -// Access: Public -// Description: Resets the status buffer for more downloading after -// a write. -//////////////////////////////////////////////////////////////////// -void Downloader::DownloadStatus:: -reset(void) { - _start = _buffer; - _next_in = _start; - _bytes_in_buffer = 0; -} diff --git a/panda/src/downloader/downloader.h b/panda/src/downloader/downloader.h deleted file mode 100644 index 5040aff852..0000000000 --- a/panda/src/downloader/downloader.h +++ /dev/null @@ -1,157 +0,0 @@ -// Filename: downloader.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://www.panda3d.org/license.txt . -// -// To contact the maintainers of this program write to -// panda3d@yahoogroups.com . -// -//////////////////////////////////////////////////////////////////// -#ifndef DOWNLOADER_H -#define DOWNLOADER_H -// -//////////////////////////////////////////////////////////////////// -// Includes -//////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include - -#if defined(WIN32_VC) - #include -#else - #include // Irix seems to require this one for resolv.h. - #include - #include - #include -#endif - -class URLSpec; - -//////////////////////////////////////////////////////////////////// -// Class : Downloader -// Description : This object is used to manage downloading of data -// from an HTTP server as a background task within a -// single-threaded network application. The class can -// download a small piece at a time when run() is called -// from time to time; it is designed to both limit time -// spent in the run() call as well as limiting network -// bandwidth utilized by the download, so that CPU -// cycles and bandwidth are still available to the -// application for other purposes. -//////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS Downloader { -PUBLISHED: - Downloader(void); - virtual ~Downloader(void); - - int connect_to_server_by_proxy(const URLSpec &proxy, const string &server_name); - int connect_to_server(const string &name, uint port=80); - void disconnect_from_server(void); - - int initiate(const string &file_name, Filename file_dest); - int initiate(const string &file_name, Filename file_dest, - int first_byte, int last_byte, int total_bytes, - bool partial_content = true); - int initiate(const string &file_name); - INLINE int get_file_size() const; - - int run(void); - - bool get_ramfile(Ramfile &rfile); - - INLINE void set_frequency(float frequency); - INLINE float get_frequency(void) const; - INLINE void set_byte_rate(float bytes); - INLINE float get_byte_rate(void) const; - INLINE void set_disk_write_frequency(int frequency); - INLINE int get_disk_write_frequency(void) const; - INLINE int get_bytes_written(void) const; - INLINE int get_bytes_requested(void) const; - INLINE float get_bytes_per_second(void) const; - - void cleanup(void); - - -private: - class DownloadStatus { - public: - DownloadStatus(char *buffer, int first_byte, int last_byte, - int total_bytes, bool partial_content); - void reset(void); - - public: - bool _first_line_complete; - bool _header_is_complete; - bool _header_is_valid; - char *_start; - char *_next_in; - int _bytes_in_buffer; - int _total_bytes_written; - int _total_bytes_requested; - int _first_byte; - int _last_byte; - int _total_bytes; - bool _partial_content; - char *_buffer; - }; - - INLINE void recompute_buffer(void); - - int connect_to_server(void); - int safe_send(int socket, const char *data, int length, long timeout); - int fast_receive(int socket, DownloadStatus *status, int rec_size); - int parse_http_response(const string &resp); - int parse_header(DownloadStatus *status); - int write_to_disk(DownloadStatus *status); - int run_to_ram(void); - int write_to_ram(DownloadStatus *status); - -private: - bool _connected; - int _socket; - string _server_name; - bool _use_proxy; - string _proxy_string; - struct sockaddr_in _sin; - bool _TCP_stack_initialized; - - bool _initiated; - bool _ever_initiated; - PT(Buffer) _buffer; - int _disk_write_frequency; - float _frequency; - float _byte_rate; - ulong _receive_size; - int _disk_buffer_size; - ofstream _dest_stream; - ostringstream *_dest_string_stream; - bool _recompute_buffer; - - DownloadStatus *_current_status; - bool _got_any_data; - int _total_bytes_written; - int _total_bytes_requested; - bool _download_to_ram; - - int _file_size; - - double _tlast; - double _tfirst; - ClockObject _clock; -}; - -#include "downloader.I" - -#endif diff --git a/panda/src/downloader/downloader_composite3.cxx b/panda/src/downloader/downloader_composite3.cxx index 4063eedca7..74ca4e02cc 100644 --- a/panda/src/downloader/downloader_composite3.cxx +++ b/panda/src/downloader/downloader_composite3.cxx @@ -1,3 +1,2 @@ -#include "downloader.cxx" #include "downloadDb.cxx" diff --git a/panda/src/downloader/identityStream.I b/panda/src/downloader/identityStream.I index 54f1a7a194..96d83735eb 100644 --- a/panda/src/downloader/identityStream.I +++ b/panda/src/downloader/identityStream.I @@ -47,7 +47,7 @@ IIdentityStream(BioStreamPtr *source, HTTPChannel *doc, INLINE IIdentityStream &IIdentityStream:: open(BioStreamPtr *source, HTTPChannel *doc, bool has_content_length, size_t content_length) { - clear(0); + clear((ios::iostate)0); _buf.open_read(source, doc, has_content_length, content_length); return *this; } diff --git a/panda/src/downloader/identityStreamBuf.cxx b/panda/src/downloader/identityStreamBuf.cxx index 6cfdf300ee..dc421151ca 100644 --- a/panda/src/downloader/identityStreamBuf.cxx +++ b/panda/src/downloader/identityStreamBuf.cxx @@ -36,10 +36,7 @@ IdentityStreamBuf() { _has_content_length = true; _bytes_remaining = 0; -#ifdef WIN32_VC - // In spite of the claims of the MSDN Library to the contrary, - // Windows doesn't seem to provide an allocate() function, so we'll - // do it by hand. +#ifdef HAVE_IOSTREAM char *buf = new char[4096]; char *ebuf = buf + 4096; setg(buf, ebuf, ebuf); diff --git a/panda/src/downloader/multiplexStreamBuf.cxx b/panda/src/downloader/multiplexStreamBuf.cxx index 005598d0c6..39f94b7469 100644 --- a/panda/src/downloader/multiplexStreamBuf.cxx +++ b/panda/src/downloader/multiplexStreamBuf.cxx @@ -95,9 +95,8 @@ write_string(const string &str) { //////////////////////////////////////////////////////////////////// MultiplexStreamBuf:: MultiplexStreamBuf() { -#ifndef WIN32_VC - // These lines, which are essential on Irix and Linux, seem to be - // unnecessary and not understood on Windows. +#ifndef HAVE_IOSTREAM + // Older iostream implementations required this. allocate(); setp(base(), ebuf()); #endif @@ -229,7 +228,10 @@ sync() { void MultiplexStreamBuf:: write_chars(const char *start, int length, bool flush) { size_t orig = _line_buffer.length(); - string latest(start, length); + string latest; + if (length != 0) { + latest = string(start, length); + } string line; if (flush) { diff --git a/panda/src/egg/eggGroup.I b/panda/src/egg/eggGroup.I index d64d8fd3f0..c1d37339b0 100644 --- a/panda/src/egg/eggGroup.I +++ b/panda/src/egg/eggGroup.I @@ -595,7 +595,7 @@ clear_lod() { //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: has_lod() const { - return (!(_lod == NULL)); + return (_lod != (EggSwitchCondition *)NULL); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/egg/eggMorphList.I b/panda/src/egg/eggMorphList.I index a14680e6db..276564217a 100644 --- a/panda/src/egg/eggMorphList.I +++ b/panda/src/egg/eggMorphList.I @@ -174,7 +174,7 @@ template pair::iterator, bool> EggMorphList:: insert(const MorphType &value) { pair result; - Morphs::iterator mi; + TYPENAME Morphs::iterator mi; for (mi = _morphs.begin(); mi != _morphs.end(); ++mi) { if ((*mi) == value) { // This value is already present. diff --git a/panda/src/egg/eggNamedObject.h b/panda/src/egg/eggNamedObject.h index db0ad09bd1..65ca4d1bc1 100644 --- a/panda/src/egg/eggNamedObject.h +++ b/panda/src/egg/eggNamedObject.h @@ -19,15 +19,11 @@ #ifndef EGGNAMEDOBJECT_H #define EGGNAMEDOBJECT_H -#include +#include "pandabase.h" #include "eggObject.h" -#include -#include - -#ifndef WIN32_VC -class ostream; -#endif +#include "namable.h" +#include "referenceCount.h" //////////////////////////////////////////////////////////////////// // Class : EggNamedObject diff --git a/panda/src/egg/eggNode.I b/panda/src/egg/eggNode.I index c161cad4a4..d885d20f7a 100644 --- a/panda/src/egg/eggNode.I +++ b/panda/src/egg/eggNode.I @@ -137,7 +137,7 @@ is_local_coord() const { //////////////////////////////////////////////////////////////////// INLINE const LMatrix4d &EggNode:: get_vertex_frame() const { - if (_vertex_frame == NULL) { + if (_vertex_frame == (LMatrix4d *)NULL) { return LMatrix4d::ident_mat(); } else { return *_vertex_frame; @@ -154,7 +154,7 @@ get_vertex_frame() const { //////////////////////////////////////////////////////////////////// INLINE const LMatrix4d &EggNode:: get_node_frame() const { - if (_node_frame == NULL) { + if (_node_frame == (LMatrix4d *)NULL) { return LMatrix4d::ident_mat(); } else { return *_node_frame; @@ -169,7 +169,7 @@ get_node_frame() const { //////////////////////////////////////////////////////////////////// INLINE const LMatrix4d &EggNode:: get_vertex_frame_inv() const { - if (_vertex_frame_inv == NULL) { + if (_vertex_frame_inv == (LMatrix4d *)NULL) { return LMatrix4d::ident_mat(); } else { return *_vertex_frame_inv; @@ -185,7 +185,7 @@ get_vertex_frame_inv() const { //////////////////////////////////////////////////////////////////// INLINE const LMatrix4d &EggNode:: get_node_frame_inv() const { - if (_node_frame_inv == NULL) { + if (_node_frame_inv == (LMatrix4d *)NULL) { return LMatrix4d::ident_mat(); } else { return *_node_frame_inv; @@ -205,7 +205,7 @@ get_node_frame_inv() const { //////////////////////////////////////////////////////////////////// INLINE const LMatrix4d &EggNode:: get_vertex_to_node() const { - if (_vertex_to_node == NULL) { + if (_vertex_to_node == (LMatrix4d *)NULL) { return LMatrix4d::ident_mat(); } else { return *_vertex_to_node; diff --git a/panda/src/egg/eggObject.h b/panda/src/egg/eggObject.h index 4dce73ea41..d75daa85aa 100644 --- a/panda/src/egg/eggObject.h +++ b/panda/src/egg/eggObject.h @@ -19,13 +19,9 @@ #ifndef EGGOBJECT_H #define EGGOBJECT_H -#include +#include "pandabase.h" -#include - -#ifndef WIN32_VC -class ostream; -#endif +#include "typedReferenceCount.h" //////////////////////////////////////////////////////////////////// // Class : EggObject diff --git a/panda/src/egg/parser.yxx b/panda/src/egg/parser.yxx index da72613738..f09f60f92d 100644 --- a/panda/src/egg/parser.yxx +++ b/panda/src/egg/parser.yxx @@ -351,7 +351,7 @@ texture_body: texture->set_magfilter(f); } } else if (cmp_nocase_uh(name, "anisotropic_degree") == 0) { - texture->set_anisotropic_degree(value); + texture->set_anisotropic_degree((int)value); } else if (cmp_nocase_uh(name, "envtype") == 0) { EggTexture::EnvType e = EggTexture::string_env_type(strval); @@ -901,11 +901,11 @@ group_body: } else if (cmp_nocase_uh(name, "bin") == 0) { group->set_bin(strval); } else if (cmp_nocase_uh(name, "collide_mask") == 0) { - group->set_collide_mask(value); + group->set_collide_mask((int)value); } else if (cmp_nocase_uh(name, "from_collide_mask") == 0) { - group->set_from_collide_mask(value); + group->set_from_collide_mask((int)value); } else if (cmp_nocase_uh(name, "into_collide_mask") == 0) { - group->set_into_collide_mask(value); + group->set_into_collide_mask((int)value); } else { eggyywarning("Unknown group scalar " + name); } @@ -1492,9 +1492,9 @@ nurbs_surface_body: } else if (cmp_nocase_uh(name, "bin") == 0) { primitive->set_bin(strval); } else if (cmp_nocase_uh(name, "u_subdiv") == 0) { - primitive->set_u_subdiv(value); + primitive->set_u_subdiv((int)value); } else if (cmp_nocase_uh(name, "v_subdiv") == 0) { - primitive->set_v_subdiv(value); + primitive->set_v_subdiv((int)value); } else { eggyywarning("Unknown scalar " + name); } @@ -1556,7 +1556,7 @@ nurbs_curve_body: } else if (cmp_nocase_uh(name, "bin") == 0) { primitive->set_bin(strval); } else if (cmp_nocase_uh(name, "subdiv") == 0) { - primitive->set_subdiv(value); + primitive->set_subdiv((int)value); } else if (cmp_nocase_uh(name, "type") == 0) { EggCurve::CurveType a = EggCurve::string_curve_type(strval); if (a == EggCurve::CT_none) { diff --git a/panda/src/egg2pg/computedVerticesMakerEntity.I b/panda/src/egg2pg/computedVerticesMakerEntity.I index a34acf6990..3671b6dc27 100644 --- a/panda/src/egg2pg/computedVerticesMakerEntity.I +++ b/panda/src/egg2pg/computedVerticesMakerEntity.I @@ -66,7 +66,7 @@ add_value(const ValueType &value, const MorphType &morphs, PTA(ValueType) &table) { // First, see if we have such an entity already. ComputedVerticesMakerEntity entity(value, morphs); - MapType::const_iterator mi = _map.find(entity); + TYPENAME MapType::const_iterator mi = _map.find(entity); if (mi != _map.end()) { // We do! Return its index number. return (*mi).second; diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index 41721e3531..104fa8ebd0 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -1281,8 +1281,13 @@ make_node(EggGroup *egg_group, PandaNode *parent) { if (!expanded.insert(objecttype).second) { egg2pg_cat.error() << "Cycle in ObjectType expansions:\n"; - copy(expanded_history.begin(), expanded_history.end(), - ostream_iterator(egg2pg_cat.error(false), " -> ")); + pvector::const_iterator pi; + for (pi = expanded_history.begin(); + pi != expanded_history.end(); + ++pi) { + egg2pg_cat.error(false) + << (*pi) << " -> "; + } egg2pg_cat.error(false) << objecttype << "\n"; _error = true; break; diff --git a/panda/src/express/multifile.cxx b/panda/src/express/multifile.cxx index a2ebf01252..406c854346 100644 --- a/panda/src/express/multifile.cxx +++ b/panda/src/express/multifile.cxx @@ -1089,7 +1089,7 @@ read_index() { char this_header[_header_size]; _read->read(this_header, _header_size); - if (_read->fail() || _read->gcount() != _header_size) { + if (_read->fail() || _read->gcount() != (unsigned)_header_size) { express_cat.info() << "Unable to read Multifile header " << _multifile_name << ".\n"; close(); diff --git a/panda/src/express/pointerTo.I b/panda/src/express/pointerTo.I index ab9f31fa6b..0c4a4b758e 100644 --- a/panda/src/express/pointerTo.I +++ b/panda/src/express/pointerTo.I @@ -163,6 +163,60 @@ INLINE bool PointerToBase:: operator >= (const To *other) const { return _ptr >= other; } +//////////////////////////////////////////////////////////////////// +// Function: PointerToBase::Equivalence operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE bool PointerToBase:: +operator == (To *other) const { + return _ptr == other; +} + +//////////////////////////////////////////////////////////////////// +// Function: PointerToBase::Nonequivalence operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE bool PointerToBase:: +operator != (To *other) const { + return _ptr != other; +} + +//////////////////////////////////////////////////////////////////// +// Function: PointerToBase::Greater-than operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE bool PointerToBase:: +operator > (To *other) const { + return _ptr > other; +} + +//////////////////////////////////////////////////////////////////// +// Function: PointerToBase::Less-than-or-equal operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE bool PointerToBase:: +operator <= (To *other) const { + return _ptr <= other; +} + +//////////////////////////////////////////////////////////////////// +// Function: PointerToBase::Greater-than-or-equal operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE bool PointerToBase:: +operator >= (To *other) const { + return _ptr >= other; +} //////////////////////////////////////////////////////////////////// // Function: PointerToBase::Equivalence operator diff --git a/panda/src/express/pointerTo.h b/panda/src/express/pointerTo.h index cf3e436e9e..204f40320d 100644 --- a/panda/src/express/pointerTo.h +++ b/panda/src/express/pointerTo.h @@ -113,6 +113,11 @@ public: INLINE bool operator > (const To *other) const; INLINE bool operator <= (const To *other) const; INLINE bool operator >= (const To *other) const; + INLINE bool operator == (To *other) const; + INLINE bool operator != (To *other) const; + INLINE bool operator > (To *other) const; + INLINE bool operator <= (To *other) const; + INLINE bool operator >= (To *other) const; INLINE bool operator == (const PointerToBase &other) const; INLINE bool operator != (const PointerToBase &other) const; @@ -145,6 +150,8 @@ INLINE ostream &operator <<(ostream &out, const PointerToBase &pointer) { //////////////////////////////////////////////////////////////////// template class PointerTo : public PointerToBase { +public: + typedef TYPENAME PointerToBase::To To; PUBLISHED: INLINE PointerTo(To *ptr = (To *)NULL); INLINE PointerTo(const PointerTo ©); @@ -152,7 +159,7 @@ PUBLISHED: public: INLINE To &operator *() const; INLINE To *operator -> () const; - INLINE operator PointerToBase::To *() const; + INLINE operator TYPENAME PointerToBase::To *() const; PUBLISHED: // When downcasting to a derived class from a PointerTo, @@ -199,6 +206,8 @@ PUBLISHED: //////////////////////////////////////////////////////////////////// template class ConstPointerTo : public PointerToBase { +public: + typedef TYPENAME PointerToBase::To To; PUBLISHED: INLINE ConstPointerTo(const To *ptr = (const To *)NULL); INLINE ConstPointerTo(const PointerTo ©); @@ -207,7 +216,7 @@ PUBLISHED: public: INLINE const To &operator *() const; INLINE const To *operator -> () const; - INLINE operator const PointerToBase::To *() const; + INLINE operator const TYPENAME PointerToBase::To *() const; PUBLISHED: INLINE const To *p() const; diff --git a/panda/src/express/pointerToArray.I b/panda/src/express/pointerToArray.I index 8df22fa8a1..6a96d38402 100644 --- a/panda/src/express/pointerToArray.I +++ b/panda/src/express/pointerToArray.I @@ -288,7 +288,7 @@ erase(iterator first, iterator last) const { // Description: //////////////////////////////////////////////////////////////////// template -INLINE PointerToArray::reference PointerToArray:: +INLINE TYPENAME PointerToArray::reference PointerToArray:: operator [](size_type n) const { nassertd(_ptr != NULL) { ((PointerToArray *)this)->reassign(new RefCountObj >); @@ -299,6 +299,17 @@ operator [](size_type n) const { nassertr(n < _ptr->size(), _ptr->operator[](0)); return _ptr->operator[](n); } + +//////////////////////////////////////////////////////////////////// +// Function: PointerToArray::Indexing operator +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE TYPENAME PointerToArray::reference PointerToArray:: +operator [](int n) const { + return operator[]((size_type)n); +} #endif //////////////////////////////////////////////////////////////////// @@ -614,7 +625,7 @@ capacity() const { //////////////////////////////////////////////////////////////////// template INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: -operator[](size_type n) const { +operator [](size_type n) const { nassertd(_ptr != NULL) { ((ConstPointerToArray *)this)->reassign(new RefCountObj >); } @@ -624,6 +635,17 @@ operator[](size_type n) const { nassertr(n < _ptr->size(), _ptr->operator[](0)); return _ptr->operator[](n); } + +//////////////////////////////////////////////////////////////////// +// Function: ConstPointerToArray::Indexing operator +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: +operator [](int n) const { + return operator[]((size_type)n); +} #endif //////////////////////////////////////////////////////////////////// diff --git a/panda/src/express/pointerToArray.h b/panda/src/express/pointerToArray.h index 3885956a93..e14d651461 100644 --- a/panda/src/express/pointerToArray.h +++ b/panda/src/express/pointerToArray.h @@ -150,6 +150,7 @@ public: PUBLISHED: #if !defined(WIN32_VC) INLINE reference operator [](size_type n) const; + INLINE reference operator [](int n) const; #endif INLINE void push_back(const Element &x); INLINE void pop_back(); @@ -232,7 +233,8 @@ public: // Functions specific to vectors. INLINE size_type capacity() const; #ifndef WIN32_VC - INLINE reference operator[](size_type n) const; + INLINE reference operator [](size_type n) const; + INLINE reference operator [](int n) const; #endif INLINE reference front() const; INLINE reference back() const; diff --git a/panda/src/express/profileTimer.h b/panda/src/express/profileTimer.h index 5010ccc2dd..a6470756e3 100644 --- a/panda/src/express/profileTimer.h +++ b/panda/src/express/profileTimer.h @@ -100,7 +100,7 @@ protected: double getTime(); - friend ProfileTimer::AutoTimer; + friend class ProfileTimer::AutoTimer; }; #include "profileTimer.I" diff --git a/panda/src/express/subStream.I b/panda/src/express/subStream.I index 1f112da69c..3123f17d03 100644 --- a/panda/src/express/subStream.I +++ b/panda/src/express/subStream.I @@ -51,7 +51,7 @@ ISubStream(istream *source, streampos start, streampos end) : istream(&_buf) { //////////////////////////////////////////////////////////////////// INLINE ISubStream &ISubStream:: open(istream *source, streampos start, streampos end) { - clear(0); + clear((ios::iostate)0); _buf.open(source, start, end); return *this; } diff --git a/panda/src/express/subStreamBuf.cxx b/panda/src/express/subStreamBuf.cxx index 7f298fc5b3..d066b3c9e9 100644 --- a/panda/src/express/subStreamBuf.cxx +++ b/panda/src/express/subStreamBuf.cxx @@ -84,10 +84,8 @@ SubStreamBuf() { init_lock(); -#ifdef WIN32_VC - // In spite of the claims of the MSDN Library to the contrary, - // Windows doesn't seem to provide an allocate() function, so we'll - // do it by hand. +#ifdef HAVE_IOSTREAM + // The new-style iostream library doesn't seem to support allocate(). char *buf = new char[4096]; char *ebuf = buf + 4096; setg(buf, ebuf, ebuf); @@ -144,7 +142,12 @@ close() { // Description: Implements seeking within the stream. //////////////////////////////////////////////////////////////////// streampos SubStreamBuf:: -seekoff(streamoff off, ios::seek_dir dir, int mode) { +#ifdef HAVE_IOSTREAM +seekoff(streamoff off, ios::seekdir dir, ios::openmode mode) +#else +seekoff(streamoff off, ios::seek_dir dir, int mode) +#endif +{ // Invariant: _cur points to the file location of the buffer at // egptr(). @@ -154,7 +157,10 @@ seekoff(streamoff off, ios::seek_dir dir, int mode) { streampos new_pos = cur_pos; // Now adjust the data pointer appropriately. - switch (dir) { + + // Casting this to int to prevent GCC 3.2 compiler warnings. Very + // suspicious, need to investigate further. + switch ((int)dir) { case ios::beg: new_pos = _start + off; break; @@ -210,20 +216,15 @@ seekoff(streamoff off, ios::seek_dir dir, int mode) { // function as well. //////////////////////////////////////////////////////////////////// streampos SubStreamBuf:: -seekpos(streampos pos, int mode) { +#ifdef HAVE_IOSTREAM +seekpos(streampos pos, ios::openmode mode) +#else +seekpos(streampos pos, int mode) +#endif +{ return seekoff(pos, ios::beg, mode); } -#ifdef WIN32_VC -// Windows seems to be a little confused about the proper definition -// of seekoff(). We have to define both variants in order to get -// reliable seeking. -streampos SubStreamBuf:: -seekoff(streamoff off, ios::seekdir dir, ios::openmode mode) { - return seekoff(off, (ios::seek_dir)dir, (int)mode); -} -#endif - //////////////////////////////////////////////////////////////////// // Function: SubStreamBuf::overflow // Access: Protected, Virtual diff --git a/panda/src/express/subStreamBuf.h b/panda/src/express/subStreamBuf.h index 1b04ecfd21..7c15374000 100644 --- a/panda/src/express/subStreamBuf.h +++ b/panda/src/express/subStreamBuf.h @@ -33,11 +33,12 @@ public: void open(istream *source, streampos start, streampos end); void close(); +#ifdef HAVE_IOSTREAM + virtual streampos seekoff(streamoff off, ios::seekdir dir, ios::openmode mode); + virtual streampos seekpos(streampos pos, ios::openmode mode); +#else virtual streampos seekoff(streamoff off, ios::seek_dir dir, int mode); virtual streampos seekpos(streampos pos, int mode); - -#ifdef WIN32_VC - virtual streampos seekoff(streamoff off, ios::seekdir dir, ios::openmode mode); #endif protected: diff --git a/panda/src/express/thread.h b/panda/src/express/thread.h index 01de2affec..7df684f078 100644 --- a/panda/src/express/thread.h +++ b/panda/src/express/thread.h @@ -67,7 +67,8 @@ private: bool _started; string _name; ThreadImpl _impl; - friend ThreadImpl; + friend class ThreadDummyImpl; + friend class ThreadNsprImpl; public: diff --git a/panda/src/express/tokenBoard.I b/panda/src/express/tokenBoard.I index 20f0ecc091..da3146a5cc 100644 --- a/panda/src/express/tokenBoard.I +++ b/panda/src/express/tokenBoard.I @@ -35,7 +35,7 @@ is_done_token(int id) { } // Now we can search really_done for our desired id. - plist< PT(TokenType) >::iterator found; + TYPENAME plist< PT(TokenType) >::iterator found; found = find_if(_really_done.begin(), _really_done.end(), TokenMatch(id)); @@ -64,7 +64,7 @@ get_done_token(int id) { } // Now we can search really_done for our desired id. - plist< PT(TokenType) >::iterator found; + TYPENAME plist< PT(TokenType) >::iterator found; found = find_if(_really_done.begin(), _really_done.end(), TokenMatch(id)); diff --git a/panda/src/express/virtualFile.cxx b/panda/src/express/virtualFile.cxx index 19e6fadb8d..18ed51d07e 100644 --- a/panda/src/express/virtualFile.cxx +++ b/panda/src/express/virtualFile.cxx @@ -118,7 +118,7 @@ output(ostream &out) const { void VirtualFile:: ls(ostream &out) const { CPT(VirtualFileList) contents = scan_directory(); - if (contents == NULL) { + if (contents == (VirtualFileList *)NULL) { if (!is_directory()) { out << get_filename() << "\n"; } else { @@ -216,7 +216,7 @@ scan_local_directory(VirtualFileList *, const ov_set &) const { void VirtualFile:: r_ls_all(ostream &out, const Filename &root) const { CPT(VirtualFileList) contents = scan_directory(); - if (contents == NULL) { + if (contents == (VirtualFileList *)NULL) { return; } diff --git a/panda/src/express/zStream.I b/panda/src/express/zStream.I index 695ac5283e..a4a90f6924 100644 --- a/panda/src/express/zStream.I +++ b/panda/src/express/zStream.I @@ -43,7 +43,7 @@ IDecompressStream(istream *source, bool owns_source) : istream(&_buf) { //////////////////////////////////////////////////////////////////// INLINE IDecompressStream &IDecompressStream:: open(istream *source, bool owns_source) { - clear(0); + clear((ios::iostate)0); _buf.open_read(source, owns_source); return *this; } @@ -89,7 +89,7 @@ OCompressStream(ostream *dest, bool owns_dest, int compression_level) : //////////////////////////////////////////////////////////////////// INLINE OCompressStream &OCompressStream:: open(ostream *dest, bool owns_dest, int compression_level) { - clear(0); + clear((ios::iostate)0); _buf.open_write(dest, owns_dest, compression_level); return *this; } diff --git a/panda/src/express/zStreamBuf.cxx b/panda/src/express/zStreamBuf.cxx index 8853712500..40adb70709 100644 --- a/panda/src/express/zStreamBuf.cxx +++ b/panda/src/express/zStreamBuf.cxx @@ -37,10 +37,7 @@ ZStreamBuf() { _dest = (ostream *)NULL; _owns_dest = false; -#ifdef WIN32_VC - // In spite of the claims of the MSDN Library to the contrary, - // Windows doesn't seem to provide an allocate() function, so we'll - // do it by hand. +#ifdef HAVE_IOSTREAM char *buf = new char[4096]; char *ebuf = buf + 4096; setg(buf, ebuf, ebuf); diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index bc6045e507..4ca257fc1d 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -843,7 +843,7 @@ write_verbose(ostream &out, int indent_level) const { << get_type() << " contains " << get_num_prims() << " primitives:\n"; - if ((i_coords == NULL) && (g_coords == NULL)) { + if ((i_coords == (ushort *)NULL) && (g_coords == (Vertexf *)NULL)) { indent(out, indent_level) << "No coords\n"; } else if (i_coords!=(ushort*)0L) { diff --git a/panda/src/gobj/geomLine.cxx b/panda/src/gobj/geomLine.cxx index 8c86ab1f93..85c4aa075a 100644 --- a/panda/src/gobj/geomLine.cxx +++ b/panda/src/gobj/geomLine.cxx @@ -62,7 +62,10 @@ void GeomLine:: write_datagram(BamWriter *manager, Datagram &me) { Geom::write_datagram(manager, me); - me.add_uint32(_width); + // Changed from uint32 to float32 on 1/16/02; didn't bother to + // update the bam version on the assumption that no actual bam files + // contain GeomLine objects. + me.add_float32(_width); } //////////////////////////////////////////////////////////////////// @@ -94,7 +97,7 @@ make_GeomLine(const FactoryParams ¶ms) { void GeomLine:: fillin(DatagramIterator& scan, BamReader* manager) { Geom::fillin(scan, manager); - _width = scan.get_uint32(); + _width = scan.get_float32(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/gobj/geomLinestrip.cxx b/panda/src/gobj/geomLinestrip.cxx index 63b86beaf0..c3a981ac6a 100644 --- a/panda/src/gobj/geomLinestrip.cxx +++ b/panda/src/gobj/geomLinestrip.cxx @@ -74,7 +74,10 @@ explode() const { void GeomLinestrip:: write_datagram(BamWriter *manager, Datagram &me) { Geom::write_datagram(manager, me); - me.add_uint32(_width); + // Changed from uint32 to float32 on 1/16/02; didn't bother to + // update the bam version on the assumption that no actual bam files + // contain GeomLinestrip objects. + me.add_float32(_width); } //////////////////////////////////////////////////////////////////// @@ -106,7 +109,7 @@ make_GeomLinestrip(const FactoryParams ¶ms) { void GeomLinestrip:: fillin(DatagramIterator& scan, BamReader* manager) { Geom::fillin(scan, manager); - _width = scan.get_uint32(); + _width = scan.get_float32(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/gobj/geomPoint.cxx b/panda/src/gobj/geomPoint.cxx index 618a803bc8..227d70c6a9 100644 --- a/panda/src/gobj/geomPoint.cxx +++ b/panda/src/gobj/geomPoint.cxx @@ -70,7 +70,10 @@ draw_immediate(GraphicsStateGuardianBase *gsg, GeomContext *gc) { void GeomPoint:: write_datagram(BamWriter *manager, Datagram &me) { Geom::write_datagram(manager, me); - me.add_uint32(_size); + // Changed from uint32 to float32 on 1/16/02; didn't bother to + // update the bam version on the assumption that no actual bam files + // contain GeomPoint objects. + me.add_float32(_size); } //////////////////////////////////////////////////////////////////// @@ -102,7 +105,7 @@ make_GeomPoint(const FactoryParams ¶ms) { void GeomPoint:: fillin(DatagramIterator& scan, BamReader* manager) { Geom::fillin(scan, manager); - _size = scan.get_uint32(); + _size = scan.get_float32(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index fcee42e7c3..7efe3d437a 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -199,7 +199,7 @@ private: static TypeHandle _type_handle; - friend TextureContext; + friend class TextureContext; }; #include "texture.I" diff --git a/panda/src/pgraph/lensNode.cxx b/panda/src/pgraph/lensNode.cxx index c315216a13..bf73597fb9 100644 --- a/panda/src/pgraph/lensNode.cxx +++ b/panda/src/pgraph/lensNode.cxx @@ -84,7 +84,7 @@ make_copy() const { bool LensNode:: is_in_view(const LPoint3f &pos) { PT(BoundingVolume) bv = _lens->make_bounds(); - if (bv == NULL) { + if (bv == (BoundingVolume *)NULL) { return false; } GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, bv); diff --git a/panda/src/pgraph/loader.cxx b/panda/src/pgraph/loader.cxx index ed7d94e1e5..653a264ffe 100644 --- a/panda/src/pgraph/loader.cxx +++ b/panda/src/pgraph/loader.cxx @@ -337,7 +337,7 @@ process_request() { PT(LoaderToken) tok = _token_board->_waiting.front(); _token_board->_waiting.pop_front(); tok->_node = load_file(tok->_path); - if (tok->_node == NULL) { + if (tok->_node == (PandaNode *)NULL) { loader_cat.error() << "Loader::callback() - couldn't find file: " << tok->_path << "\n"; diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index 1207e734ee..d53bebb2ab 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -570,7 +570,7 @@ private: static TypeHandle _type_handle; friend class NodePathCollection; - friend WorkingNodePath; + friend class WorkingNodePath; }; INLINE ostream &operator << (ostream &out, const NodePath &node_path); diff --git a/panda/src/physics/linearNoiseForce.I b/panda/src/physics/linearNoiseForce.I index 3aaa7ae8c4..8ce7ba360c 100644 --- a/panda/src/physics/linearNoiseForce.I +++ b/panda/src/physics/linearNoiseForce.I @@ -33,7 +33,7 @@ prn_lookup(int index) const { //////////////////////////////////////////////////////////////////// INLINE unsigned char LinearNoiseForce:: get_prn_entry(const LPoint3f& point) const { - return prn_lookup(point[0] + prn_lookup(point[1] + prn_lookup(point[2]))); + return prn_lookup((int)(point[0] + prn_lookup((int)(point[1] + prn_lookup((int)point[2]))))); } //////////////////////////////////////////////////////////////////// @@ -43,7 +43,7 @@ get_prn_entry(const LPoint3f& point) const { //////////////////////////////////////////////////////////////////// INLINE unsigned char LinearNoiseForce:: get_prn_entry(const float x, const float y, const float z) const { - return prn_lookup(x + prn_lookup(y + prn_lookup(z))); + return prn_lookup((int)(x + prn_lookup((int)(y + prn_lookup((int)z))))); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physics/linearNoiseForce.h b/panda/src/physics/linearNoiseForce.h index 6f879b9713..2f41d2f283 100644 --- a/panda/src/physics/linearNoiseForce.h +++ b/panda/src/physics/linearNoiseForce.h @@ -19,6 +19,7 @@ #ifndef LINEARNOISEFORCE_H #define LINEARNOISEFORCE_H +#include "pandabase.h" #include "linearRandomForce.h" //////////////////////////////////////////////////////////////////// diff --git a/panda/src/putil/Sources.pp b/panda/src/putil/Sources.pp index 39c66606d2..c1d4bbf826 100644 --- a/panda/src/putil/Sources.pp +++ b/panda/src/putil/Sources.pp @@ -170,4 +170,7 @@ #define SOURCES \ test_linestream.cxx + #define LOCAL_LIBS $[LOCAL_LIBS] putil + #define OTHER_LIBS $[OTHER_LIBS] pystub + #end test_bin_target diff --git a/panda/src/putil/lineStreamBuf.I b/panda/src/putil/lineStreamBuf.I index 69eb8a69c6..2351948bb1 100644 --- a/panda/src/putil/lineStreamBuf.I +++ b/panda/src/putil/lineStreamBuf.I @@ -17,16 +17,6 @@ //////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////// -// Function: LineStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE LineStreamBuf:: -LineStreamBuf() { - _has_newline = false; -} - //////////////////////////////////////////////////////////////////// // Function: LineStreamBuf::is_text_available // Access: Public @@ -56,5 +46,7 @@ has_newline() const { //////////////////////////////////////////////////////////////////// INLINE void LineStreamBuf:: write_chars(const char *start, int length) { - _data += string(start, length); + if (length > 0) { + _data += string(start, length); + } } diff --git a/panda/src/putil/lineStreamBuf.cxx b/panda/src/putil/lineStreamBuf.cxx index 7fc3d313c6..d7308c4add 100644 --- a/panda/src/putil/lineStreamBuf.cxx +++ b/panda/src/putil/lineStreamBuf.cxx @@ -23,6 +23,23 @@ typedef int streamsize; #endif +//////////////////////////////////////////////////////////////////// +// Function: LineStreamBuf::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +LineStreamBuf:: +LineStreamBuf() { + _has_newline = false; + + // The LineStreamBuf doesn't actually need a buffer--it's happy + // writing characters one at a time, since they're just getting + // stuffed into a string. (Although the code is written portably + // enough to use a buffer correctly, if we had one.) + setg(0, 0, 0); + setp(0, 0); +} + //////////////////////////////////////////////////////////////////// // Function: LineStreamBuf::Destructor // Access: Public, Virtual diff --git a/panda/src/putil/lineStreamBuf.h b/panda/src/putil/lineStreamBuf.h index f023895939..b060ff5f15 100644 --- a/panda/src/putil/lineStreamBuf.h +++ b/panda/src/putil/lineStreamBuf.h @@ -32,7 +32,7 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA LineStreamBuf : public streambuf { public: - INLINE LineStreamBuf(); + LineStreamBuf(); virtual ~LineStreamBuf(); INLINE bool is_text_available() const; diff --git a/panda/src/testbed/pgrid.cxx b/panda/src/testbed/pgrid.cxx index 65ba0d7d8c..28c0d476fd 100644 --- a/panda/src/testbed/pgrid.cxx +++ b/panda/src/testbed/pgrid.cxx @@ -67,7 +67,7 @@ typedef enum {None,Rotation,LinearMotion} GriddedMotionType; #define GRIDCELLSIZE 5.0 static int gridwidth; // cells/side -#define MIN_WANDERAREA_DIMENSION 120.0 +#define MIN_WANDERAREA_DIMENSION 120.0f static float grid_pos_offset; // origin of grid static float wander_area_pos_offset; @@ -249,7 +249,7 @@ load_gridded_models(WindowFramework *window, } grid_pos_offset = -gridwidth*GRIDCELLSIZE/2.0; - wander_area_pos_offset = -max(fabs(grid_pos_offset),MIN_WANDERAREA_DIMENSION/2.0); + wander_area_pos_offset = -max(fabs(grid_pos_offset), MIN_WANDERAREA_DIMENSION/2.0f); // Now walk through the list again, copying models into the scene // graph as we go. diff --git a/panda/src/text/textFont.h b/panda/src/text/textFont.h index 8768e4f73e..aac0c0fb3d 100644 --- a/panda/src/text/textFont.h +++ b/panda/src/text/textFont.h @@ -29,8 +29,8 @@ class Node; class TextGlyph; -#ifdef __GNUC__ -// For some reason, gcc's doesn't define this. +#if defined(__GNUC__) && !defined(HAVE_IOSTREAM) +// For some reason, early versions of gcc's didn't define this. typedef basic_string wstring; #endif diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index 9abf21b598..0719a78388 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -496,9 +496,9 @@ intersect_regions(MouseWatcher::VRegions &result, void MouseWatcher:: remove_region_from(MouseWatcher::VRegions ®ions, MouseWatcherRegion *region) { - VRegions::iterator ri = - lower_bound(regions.begin(), regions.end(), region); - if (ri != regions.end() && (*ri) == region) { + PT(MouseWatcherRegion) ptr = region; + VRegions::iterator ri = lower_bound(regions.begin(), regions.end(), ptr); + if (ri != regions.end() && (*ri) == ptr) { // The region is in the vector. Remove it. regions.erase(ri); }